Skip to content

Commit 32a0771

Browse files
authored
Mention source file name for JDT parsing exceptions (#10093)
If JDT fails to parse a file, the thrown exception can be very cryptic. This at least adds the name of the source unit to the thrown exception.
1 parent a339938 commit 32a0771

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

dev/core/src/com/google/gwt/dev/javac/JdtCompiler.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.gwt.core.ext.UnableToCompleteException;
2020
import com.google.gwt.dev.CompilerContext;
2121
import com.google.gwt.dev.jdt.TypeRefVisitor;
22+
import com.google.gwt.dev.jjs.InternalCompilerException;
2223
import com.google.gwt.dev.jjs.ast.JDeclaredType;
2324
import com.google.gwt.dev.util.arg.SourceLevel;
2425
import com.google.gwt.dev.util.collect.Lists;
@@ -197,11 +198,17 @@ public ParserImpl(ProblemReporter problemReporter, boolean optimizeStringLiteral
197198
@Override
198199
public CompilationUnitDeclaration parse(ICompilationUnit sourceUnit,
199200
CompilationResult compilationResult) {
200-
// Never dietParse(), otherwise GwtIncompatible annotations in anonymoous inner classes
201+
// Never dietParse(), otherwise GwtIncompatible annotations in anonymous inner classes
201202
// would be ignored.
202203
boolean saveDiet = this.diet;
203204
this.diet = false;
204-
CompilationUnitDeclaration decl = super.parse(sourceUnit, compilationResult);
205+
CompilationUnitDeclaration decl;
206+
try {
207+
decl = super.parse(sourceUnit, compilationResult);
208+
} catch (RuntimeException ex) {
209+
throw new InternalCompilerException("Problem parsing "
210+
+ new String(sourceUnit.getFileName()), ex);
211+
}
205212
this.diet = saveDiet;
206213
// Remove @GwtIncompatible classes and members.
207214
// It is safe to remove @GwtIncompatible types, fields and methods on incomplete ASTs due

0 commit comments

Comments
 (0)