Skip to content

Commit

Permalink
Map unknown compiler error by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Sep 24, 2024
1 parent 3ff84da commit 6113062
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public JavacProblem createJavacProblem(Diagnostic<? extends JavaFileObject> diag
|| (nestedDiagnostic.getSource() == null && findSymbol(nestedDiagnostic) instanceof ClassSymbol classSymbol
&& classSymbol.sourcefile == diagnostic.getSource()));
int problemId = toProblemId(useNestedDiagnostic ? nestedDiagnostic : diagnostic);
if (problemId == 0) {
if (problemId < 0) {
return null;
}
int severity = toSeverity(problemId, diagnostic);
Expand Down Expand Up @@ -822,7 +822,7 @@ yield switch (rootCauseCode) {
case "compiler.err.duplicate.class" -> IProblem.DuplicateTypes;
case "compiler.err.module.not.found", "compiler.warn.module.not.found" -> IProblem.UndefinedModule;
case "compiler.err.package.empty.or.not.found" -> IProblem.PackageDoesNotExistOrIsEmpty;
case "compiler.warn.service.provided.but.not.exported.or.used" -> 0; // ECJ doesn't have this diagnostic TODO: file upstream
case "compiler.warn.service.provided.but.not.exported.or.used" -> -1; // ECJ doesn't have this diagnostic TODO: file upstream
case "compiler.warn.missing-explicit-ctor" -> IProblem.ConstructorRelated;
case "compiler.warn.has.been.deprecated", "compiler.warn.has.been.deprecated.for.removal" -> {
var kind = getDiagnosticArgumentByType(diagnostic, Kinds.KindName.class);
Expand Down Expand Up @@ -926,7 +926,7 @@ yield switch (rootCauseCode) {
// TODO also return a IProblem.JavadocMissingParamTag for each arg
}
// most others are ignored
yield 0;
yield -1;
}
case "compiler.err.doesnt.exist" -> {
JCCompilationUnit unit = units.get(diagnostic.getSource());
Expand All @@ -949,7 +949,7 @@ yield switch (rootCauseCode) {
case "compiler.err.malformed.fp.lit" -> IProblem.InvalidFloat;
case "compiler.warn.missing.deprecated.annotation" -> {
if (!(diagnostic instanceof JCDiagnostic jcDiagnostic)) {
yield 0;
yield -1;
}
DiagnosticPosition pos = jcDiagnostic.getDiagnosticPosition();
if (pos instanceof JCTree.JCVariableDecl) {
Expand All @@ -960,14 +960,14 @@ yield switch (rootCauseCode) {
yield IProblem.TypeMissingDeprecatedAnnotation;
}
ILog.get().error("Could not convert diagnostic " + diagnostic);
yield 0;
yield -1;
}
case "compiler.warn.override.equals.but.not.hashcode" -> IProblem.ShouldImplementHashcode;
case "compiler.warn.unchecked.call.mbr.of.raw.type" -> IProblem.UnsafeRawMethodInvocation;
case "compiler.err.cant.inherit.from.sealed" -> {
Symbol.ClassSymbol sym = getDiagnosticArgumentByType(diagnostic, Symbol.ClassSymbol.class);
if (sym == null) {
yield 0;
yield -1;
}
if (sym.isInterface()) {
yield IProblem.SealedSuperInterfaceDoesNotPermit;
Expand All @@ -980,15 +980,15 @@ yield switch (rootCauseCode) {
case "compiler.err.package.in.other.module" -> IProblem.ConflictingPackageFromOtherModules;
case "compiler.err.module.decl.sb.in.module-info.java" -> {
if (!(diagnostic instanceof JCDiagnostic jcDiagnostic)) {
yield 0;
yield -1;
}
DiagnosticPosition pos = jcDiagnostic.getDiagnosticPosition();
if (pos instanceof JCTree.JCModuleDecl) {
yield IProblem.ParsingErrorOnKeywordNoSuggestion;
} else if (pos instanceof JCTree.JCModuleImport) {
}
ILog.get().error("Could not convert diagnostic " + diagnostic);
yield 0;
yield -1;
}
case "compiler.err.file.sb.on.source.or.patch.path.for.module" -> IProblem.ParsingErrorOnKeywordNoSuggestion;
case "compiler.err.package.not.visible" -> IProblem.NotVisibleType;
Expand Down Expand Up @@ -1070,8 +1070,11 @@ yield switch (rootCauseCode) {
case "compiler.err.incorrect.constructor.receiver.type" -> IProblem.IllegalTypeForExplicitThis;
case "compiler.err.incorrect.constructor.receiver.name" -> IProblem.IllegalQualifierForExplicitThis;
default -> {
ILog.get().error("Could not convert diagnostic (" + diagnostic.getCode() + ")\n" + diagnostic);
yield 0;
ILog.get().error("Could not accurately convert diagnostic (" + diagnostic.getCode() + ")\n" + diagnostic);
if (diagnostic.getKind() == javax.tools.Diagnostic.Kind.ERROR && diagnostic.getCode().startsWith("compiler.err")) {
yield IProblem.Unclassified;
}
yield -1;
}
};
}
Expand Down

0 comments on commit 6113062

Please sign in to comment.