Skip to content

Commit

Permalink
Fix quickfix for private abstract method in interface
Browse files Browse the repository at this point in the history
Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 authored and mickaelistria committed Jul 19, 2024
1 parent 85fc642 commit 7fa6490
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ private String convertDiagnosticMessage(String original, int problemId, Object[]
}
return original;
}

private org.eclipse.jface.text.Position getDiagnosticPosition(Diagnostic<? extends JavaFileObject> diagnostic, Context context, int problemId) {
if (diagnostic.getCode().contains(".dc") || "compiler.warn.proc.messager".equals(diagnostic.getCode())) { //javadoc
if (problemId == IProblem.JavadocMissingParamTag) {
@@ -553,7 +553,20 @@ yield switch (rootCauseCode) {
case "compiler.err.not.def.public.cant.access" -> IProblem.NotVisibleType; // TODO different according to target node
case "compiler.err.already.defined" -> IProblem.DuplicateMethod; // TODO different according to target node
case "compiler.err.var.might.not.have.been.initialized" -> IProblem.UninitializedLocalVariable;
case "compiler.err.missing.meth.body.or.decl.abstract" -> IProblem.MethodRequiresBody;
case "compiler.err.missing.meth.body.or.decl.abstract" -> {
if (diagnostic instanceof JCDiagnostic jcDiagnostic
&& jcDiagnostic.getDiagnosticPosition() instanceof JCMethodDecl jcMethodDecl
&& jcMethodDecl.sym != null
&& jcMethodDecl.sym.enclClass() != null
&& jcMethodDecl.sym.enclClass().type != null
&& jcMethodDecl.sym.enclClass().type.isInterface()) {
// javac states that the method must have a body or be abstract;
// in the case of an interface where neither are required,
// this likely means the method has a private modifier.
yield IProblem.IllegalModifierForInterfaceMethod;
}
yield IProblem.MethodRequiresBody;
}
case "compiler.err.intf.meth.cant.have.body" -> IProblem.BodyForAbstractMethod;
case "compiler.warn.empty.if" -> IProblem.EmptyControlFlowStatement;
case "compiler.warn.redundant.cast" -> IProblem.UnnecessaryCast;
@@ -661,6 +674,7 @@ yield switch (rootCauseCode) {
}
case "compiler.err.non.sealed.sealed.or.final.expected" -> IProblem.SealedMissingClassModifier;
case "compiler.err.enum.annotation.must.be.enum.constant" -> IProblem.AnnotationValueMustBeAnEnumConstant;
case "compiler.err.package.in.other.module" -> IProblem.ConflictingPackageFromOtherModules;
default -> {
ILog.get().error("Could not convert diagnostic (" + diagnostic.getCode() + ")\n" + diagnostic);
yield 0;
@@ -941,4 +955,5 @@ private int convertAmbiguous(Diagnostic<?> diagnostic) {
public void registerUnit(JavaFileObject javaFileObject, JCCompilationUnit unit) {
this.units.put(javaFileObject, unit);
}

}

0 comments on commit 7fa6490

Please sign in to comment.