Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use scanner tokens if the diagnostic length is non-zero #422

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public JavacProblemConverter(CompilerOptions options, Context context) {
}

/**
*
*
* @param diagnostic
* @param context
* @return a JavacProblem matching the given diagnostic, or <code>null</code> if problem is ignored
Expand Down Expand Up @@ -86,7 +86,7 @@ public JavacProblem createJavacProblem(Diagnostic<? extends JavaFileObject> diag
(int) diagnostic.getLineNumber(),
(int) diagnostic.getColumnNumber());
}

private static org.eclipse.jface.text.Position getDiagnosticPosition(Diagnostic<? extends JavaFileObject> diagnostic, Context context) {
if (diagnostic.getCode().contains(".dc")) { //javadoc
return getDefaultPosition(diagnostic);
Expand All @@ -105,7 +105,9 @@ private static org.eclipse.jface.text.Position getDiagnosticPosition(Diagnostic<
if (result != null) {
return result;
}
return getPositionUsingScanner(jcDiagnostic, context);
if (jcDiagnostic.getStartPosition() == jcDiagnostic.getEndPosition()) {
return getPositionUsingScanner(jcDiagnostic, context);
}
}
}
}
Expand Down Expand Up @@ -135,7 +137,7 @@ private static org.eclipse.jface.text.Position getPositionUsingScanner(JCDiagnos
Token prev = javacScanner.prevToken();
if( prev != null ) {
if( t.endPos == prev.endPos && t.pos == prev.pos && t.kind.equals(prev.kind)) {
t = null; // We're stuck in a loop. Give up.
t = null; // We're stuck in a loop. Give up.
}
}
}
Expand Down Expand Up @@ -291,7 +293,7 @@ private int toSeverity(int jdtProblemId, Diagnostic<? extends JavaFileObject> di
default -> ProblemSeverities.Error;
};
}

/**
* See the link below for Javac problem list:
* https://github.com/openjdk/jdk/blob/master/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
Expand Down
Loading