Skip to content

Commit

Permalink
Allow "remove abstract" quickfix for BodyForAbstractMethod
Browse files Browse the repository at this point in the history
When using Javac, the BodyForAbstractMethod problem is well reported.
Other problems can be missing.
However, BodyForAbstractMethod seems like a good enough case per so to
enable the "remove abstract" quick fix.

This fixes AbstractMethodQuickFixTest.testAbstractMethodInConcreteClass
when running with Javac.
  • Loading branch information
mickaelistria committed Sep 2, 2024
1 parent 920a4bc commit 67ff3b0
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@
import org.eclipse.jdt.internal.corext.fix.UnimplementedCodeFixCore.MakeTypeAbstractOperation;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.internal.corext.util.JdtFlags;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.ui.text.java.IProblemLocation;
import org.eclipse.jdt.internal.ui.text.correction.IProposalRelevance;
import org.eclipse.jdt.internal.ui.text.correction.proposals.FixCorrectionProposalCore;
import org.eclipse.jdt.internal.ui.text.correction.proposals.ModifierChangeCorrectionProposalCore;
Expand All @@ -79,6 +77,8 @@
import org.eclipse.jdt.ls.core.internal.corrections.ProposalKindWrapper;
import org.eclipse.jdt.ls.core.internal.corrections.proposals.UnresolvedElementsSubProcessor;
import org.eclipse.jdt.ls.core.internal.handlers.CodeActionHandler;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.ui.text.java.IProblemLocation;
import org.eclipse.jdt.ui.text.java.correction.ASTRewriteCorrectionProposalCore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
Expand Down Expand Up @@ -541,7 +541,7 @@ public static void addAbstractMethodProposals(IInvocationContext context, IProbl
boolean hasNoBody = decl.getBody() == null;

int id = problem.getProblemId();
if (id == IProblem.AbstractMethodInAbstractClass || id == IProblem.EnumAbstractMethodMustBeImplemented || id == IProblem.AbstractMethodInEnum || parentIsAbstractClass) {
if (id == IProblem.AbstractMethodInAbstractClass || id == IProblem.EnumAbstractMethodMustBeImplemented || id == IProblem.AbstractMethodInEnum || id == IProblem.BodyForAbstractMethod || parentIsAbstractClass) {
AST ast = astRoot.getAST();
ASTRewrite rewrite = ASTRewrite.create(ast);

Expand Down Expand Up @@ -981,10 +981,10 @@ public static void addSealedMissingModifierProposal(IInvocationContext context,
if (!(selectedNode instanceof SimpleName)) {
return;
}
if (!(((SimpleName) selectedNode).getParent() instanceof TypeDeclaration)) {
if (!(selectedNode.getParent() instanceof TypeDeclaration)) {
return;
}
TypeDeclaration typeDecl = (TypeDeclaration) ((SimpleName) selectedNode).getParent();
TypeDeclaration typeDecl = (TypeDeclaration) selectedNode.getParent();
boolean isInterface = typeDecl.isInterface();

ICompilationUnit cu = context.getCompilationUnit();
Expand Down

0 comments on commit 67ff3b0

Please sign in to comment.