Skip to content

Commit

Permalink
refactor(gazelle): improve js parse-error message (#2343)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 72e57e397e370ffeb5b4f8de4dc002d604daf782
  • Loading branch information
jbedard authored and gregmagolan committed Jun 1, 2023
1 parent 5284143 commit 34e74de
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
5 changes: 3 additions & 2 deletions gazelle/js/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ func (ts *TypeScript) addProjectRule(cfg *JsGazelleConfig, args language.Generat

for result := range ts.collectAllImports(cfg, args, sourceFiles) {
if len(result.Errors) > 0 {
fmt.Println(result.SourcePath, "parse error(s):")
fmt.Printf("%s:\n", result.SourcePath)
for _, err := range result.Errors {
fmt.Println(err)
fmt.Printf("\t%s\n", err)
}
fmt.Println()
}

for _, sourceImport := range result.Imports {
Expand Down
15 changes: 9 additions & 6 deletions gazelle/js/tests/parse_errors/expectedStdout.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
subbuild/subbuild-bad.ts parse error(s):
4: Expected ";" but found "1"
subdir/subdir-bad.ts parse error(s):
3: Expected "}" but found "SyntaxError"
bad.ts parse error(s):
2: Expected ";" but found "like"
subbuild/subbuild-bad.ts:
4: Expected ";" but found "1"

subdir/subdir-bad.ts:
3: Expected "}" but found "SyntaxError"

bad.ts:
2: Expected ";" but found "like"

0 comments on commit 34e74de

Please sign in to comment.