From 6a279fb5c86bcdcb373d83033b366c4e6526c910 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Wed, 15 Jun 2016 15:03:19 +0300 Subject: [PATCH] inspection toolwindow: disable add as entry point action if all selected elements are already EPs --- .../deadCode/UnusedDeclarationPresentation.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java index 28f3a2e9dfce..69056e49d799 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationPresentation.java @@ -23,6 +23,7 @@ import com.intellij.codeInspection.ui.*; import com.intellij.codeInspection.util.RefFilter; import com.intellij.icons.AllIcons; import com.intellij.lang.annotation.HighlightSeverity; +import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; @@ -211,6 +212,20 @@ public class UnusedDeclarationPresentation extends DefaultInspectionToolPresenta super(InspectionsBundle.message("inspection.dead.code.entry.point.quickfix"), null, KeyStroke.getKeyStroke(KeyEvent.VK_INSERT, 0), toolWrapper); } + @Override + public void update(AnActionEvent e) { + super.update(e); + if (e.getPresentation().isEnabledAndVisible()) { + final RefEntity[] elements = getInvoker(e).getTree().getSelectedElements(); + for (RefEntity element : elements) { + if (!((RefElement) element).isEntry()) { + return; + } + } + e.getPresentation().setEnabled(false); + } + } + @Override protected boolean applyFix(@NotNull RefEntity[] refElements) { final EntryPointsManager entryPointsManager = getEntryPointsManager();