Skip to content

Commit

Permalink
Map more pb
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Jul 10, 2024
1 parent 80d4fa3 commit dddf094
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ private org.eclipse.jface.text.Position getDiagnosticPosition(Diagnostic<? exten
return getDefaultPosition(diagnostic);
}
if (diagnostic instanceof JCDiagnostic jcDiagnostic) {
if (problemId == IProblem.IncompatibleExceptionInThrowsClause && jcDiagnostic.getDiagnosticPosition() instanceof JCMethodDecl method) {
int start = method.getPreferredPosition();
var unit = this.units.get(jcDiagnostic.getSource());
if (unit != null) {
int end = method.thrown.stream().mapToInt(unit.endPositions::getEndPos).max().orElse(-1);
if (end >= 0) {
return new org.eclipse.jface.text.Position(start, end - start);
}
}
}
TreePath diagnosticPath = getTreePath(jcDiagnostic);
if (problemId == IProblem.ParameterMismatch) {
// Javac points to the arg, which JDT expects the method name
Expand Down Expand Up @@ -470,6 +480,7 @@ public int toProblemId(Diagnostic<? extends JavaFileObject> diagnostic) {
case "compiler.warn.redundant.cast" -> IProblem.UnnecessaryCast;
case "compiler.err.illegal.char" -> IProblem.InvalidCharacterConstant;
case "compiler.err.enum.label.must.be.unqualified.enum" -> IProblem.UndefinedField;
case "compiler.err.bad.initializer" -> IProblem.ParsingErrorInsertToComplete;
// next are javadoc; defaulting to JavadocUnexpectedText when no better problem could be found
case "compiler.err.dc.bad.entity" -> IProblem.JavadocUnexpectedText;
case "compiler.err.dc.bad.inline.tag" -> IProblem.JavadocUnexpectedText;
Expand Down

0 comments on commit dddf094

Please sign in to comment.