Skip to content

Commit

Permalink
Add quickfix for redundant interface
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza committed Jan 27, 2020
1 parent b4aa67d commit d94b7d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,9 @@ private void process(IInvocationContext context, IProblemLocationCore problem, C
case IProblem.InvalidUnionTypeReferenceSequence:
LocalCorrectionsSubProcessor.addUnreachableCatchProposals(context, problem, proposals);
break;
// case IProblem.RedundantSuperinterface:
// LocalCorrectionsSubProcessor.addRedundantSuperInterfaceProposal(context,
// problem, proposals);
// break;
case IProblem.RedundantSuperinterface:
LocalCorrectionsSubProcessor.addRedundantSuperInterfaceProposal(context, problem, proposals);
break;
case IProblem.VoidMethodReturnsValue:
ReturnTypeSubProcessor.addVoidMethodReturnsProposals(context, problem, proposals);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodReference;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.ParenthesizedExpression;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.Statement;
Expand Down Expand Up @@ -695,4 +696,17 @@ public static void addCorrectAccessToStaticProposals(IInvocationContext context,
ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_STATIC, IProposalRelevance.REMOVE_STATIC_MODIFIER);
}

public static void addRedundantSuperInterfaceProposal(IInvocationContext context, IProblemLocationCore problem, Collection<ChangeCorrectionProposal> proposals) {
ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
if (!(selectedNode instanceof Name)) {
return;
}
ASTNode node = ASTNodes.getNormalizedNode(selectedNode);
ASTRewrite rewrite = ASTRewrite.create(node.getAST());
rewrite.remove(node, null);
String label = CorrectionMessages.LocalCorrectionsSubProcessor_remove_redundant_superinterface;
ASTRewriteCorrectionProposal proposal = new ASTRewriteCorrectionProposal(label, CodeActionKind.QuickFix, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_REDUNDANT_SUPER_INTERFACE);
proposals.add(proposal);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static void initialize() {
javaCoreOptions.put(JavaCore.COMPILER_RELEASE, JavaCore.ENABLED);
javaCoreOptions.put(DefaultCodeFormatterConstants.FORMATTER_USE_ON_OFF_TAGS, DefaultCodeFormatterConstants.TRUE);
javaCoreOptions.put(JavaCore.COMPILER_PB_UNHANDLED_WARNING_TOKEN, JavaCore.IGNORE);
javaCoreOptions.put(JavaCore.COMPILER_PB_REDUNDANT_SUPERINTERFACE, JavaCore.WARNING);
JavaCore.setOptions(javaCoreOptions);

// Initialize default preferences
Expand Down

0 comments on commit d94b7d3

Please sign in to comment.