From 7800e0d2e7412ef005a3efd4c5dcdeaacad63e53 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Fri, 27 May 2016 19:07:37 +0300 Subject: [PATCH] inspection toolwindow: edit inspection settings ignore dummy profiles IDEA-156728 --- .../com/intellij/codeInspection/ex/QuickFixAction.java | 2 +- .../intellij/codeInspection/ui/InspectionNodeInfo.java | 2 +- .../intellij/codeInspection/ui/InspectionResultsView.java | 8 ++++---- .../com/intellij/codeInspection/ui/InspectionTree.java | 7 +++++-- .../codeInspection/ui/QuickFixPreviewPanelFactory.java | 2 +- .../codeInspection/ui/actions/EditSettingsAction.java | 2 +- .../codeInspection/ui/actions/InvokeQuickFixAction.java | 4 ++-- .../ui/actions/KeyAwareInspectionViewAction.java | 6 +++--- .../ui/actions/QuickFixesViewActionGroup.java | 2 +- .../ui/actions/suppress/SuppressActionWrapper.java | 4 ++-- 10 files changed, 21 insertions(+), 18 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java index bbce736a05f0..ad1a307a029f 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/QuickFixAction.java @@ -93,7 +93,7 @@ public class QuickFixAction extends AnAction implements CustomComponentAction { e.getPresentation().setEnabled(false); final InspectionTree tree = view.getTree(); - final InspectionToolWrapper toolWrapper = tree.getSelectedToolWrapper(); + final InspectionToolWrapper toolWrapper = tree.getSelectedToolWrapper(true); if (!view.isSingleToolInSelection() || toolWrapper != myToolWrapper) { return; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNodeInfo.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNodeInfo.java index b2103b13215c..33119f540399 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNodeInfo.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionNodeInfo.java @@ -51,7 +51,7 @@ public class InspectionNodeInfo extends JPanel { @NotNull final Project project) { setLayout(new GridBagLayout()); setBorder(IdeBorderFactory.createEmptyBorder(11, 0, 0, 0)); - final InspectionToolWrapper toolWrapper = tree.getSelectedToolWrapper(); + final InspectionToolWrapper toolWrapper = tree.getSelectedToolWrapper(true); LOG.assertTrue(toolWrapper != null); InspectionProfileImpl currentProfile = (InspectionProfileImpl)InspectionProjectProfileManager.getInstance(project).getProjectProfileImpl(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 4b52ba781eef..d9ffb038218f 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -413,12 +413,12 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren myLoadingProgressPreview = null; } if (myApplyingFix) { - final InspectionToolWrapper wrapper = myTree.getSelectedToolWrapper(); + final InspectionToolWrapper wrapper = myTree.getSelectedToolWrapper(true); LOG.assertTrue(wrapper != null); mySplitter.setSecondComponent(InspectionResultsViewUtil.getApplyingFixLabel(wrapper)); } else { if (myTree.getSelectionModel().getSelectionCount() != 1) { - if (myTree.getSelectedToolWrapper() == null) { + if (myTree.getSelectedToolWrapper(true) == null) { mySplitter.setSecondComponent(InspectionResultsViewUtil.getNothingToShowTextLabel()); } else { @@ -478,7 +478,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren editorPanel.setLayout(new BorderLayout()); final int problemCount = myTree.getSelectedProblemCount(); JComponent previewPanel = null; - final InspectionToolWrapper tool = myTree.getSelectedToolWrapper(); + final InspectionToolWrapper tool = myTree.getSelectedToolWrapper(true); if (tool != null && refEntity != null && refEntity.isValid()) { final InspectionToolPresentation presentation = myGlobalInspectionContext.getPresentation(tool); previewPanel = presentation.getCustomPreviewPanel(refEntity); @@ -939,7 +939,7 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren } public boolean isSingleToolInSelection() { - return myTree != null && myTree.getSelectedToolWrapper() != null; + return myTree != null && myTree.getSelectedToolWrapper(true) != null; } public boolean isRerun() { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java index bbf2ba7380de..04add1887b5d 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java @@ -126,7 +126,7 @@ public class InspectionTree extends Tree { } @Nullable - public InspectionToolWrapper getSelectedToolWrapper() { + public InspectionToolWrapper getSelectedToolWrapper(boolean allowDummy) { final TreePath[] paths = getSelectionPaths(); if (paths == null) return null; InspectionToolWrapper toolWrapper = null; @@ -139,6 +139,9 @@ public class InspectionTree extends Tree { } if (node instanceof InspectionNode) { InspectionToolWrapper wrapper = ((InspectionNode)node).getToolWrapper(); + if (!allowDummy && getContext().getPresentation(wrapper).isDummy()) { + continue; + } if (toolWrapper == null) { toolWrapper = wrapper; } @@ -187,7 +190,7 @@ public class InspectionTree extends Tree { public RefEntity[] getSelectedElements() { TreePath[] selectionPaths = getSelectionPaths(); if (selectionPaths != null) { - InspectionToolWrapper toolWrapper = getSelectedToolWrapper(); + InspectionToolWrapper toolWrapper = getSelectedToolWrapper(true); if (toolWrapper == null) return RefEntity.EMPTY_ELEMENTS_ARRAY; Set result = new LinkedHashSet(); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/QuickFixPreviewPanelFactory.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/QuickFixPreviewPanelFactory.java index ed1e71749c0f..ec21d4e163f2 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/QuickFixPreviewPanelFactory.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/QuickFixPreviewPanelFactory.java @@ -65,7 +65,7 @@ public class QuickFixPreviewPanelFactory { public QuickFixReadyPanel(@NotNull InspectionResultsView view, EditorEx editor) { myView = view; - myWrapper = view.getTree().getSelectedToolWrapper(); + myWrapper = view.getTree().getSelectedToolWrapper(true); LOG.assertTrue(myWrapper != null); CommonProblemDescriptor[] descriptors = myView.getTree().getSelectedDescriptors(); if (editor != null) { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java index e7a084b9c3c8..0fe131239f2c 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/EditSettingsAction.java @@ -46,7 +46,7 @@ public class EditSettingsAction extends InspectionViewActionBase { public void actionPerformed(AnActionEvent e) { final InspectionResultsView view = getView(e); final InspectionProjectProfileManager profileManager = InspectionProjectProfileManager.getInstance(view.getProject()); - final InspectionToolWrapper toolWrapper = view.getTree().getSelectedToolWrapper(); + final InspectionToolWrapper toolWrapper = view.getTree().getSelectedToolWrapper(false); InspectionProfile inspectionProfile = view.getCurrentProfile(); final boolean profileIsDefined = view.isProfileDefined(); if (!profileIsDefined) { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InvokeQuickFixAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InvokeQuickFixAction.java index 328eaac81503..6fe216e6f1e5 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InvokeQuickFixAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/InvokeQuickFixAction.java @@ -50,7 +50,7 @@ public class InvokeQuickFixAction extends AnAction { @Override public void update(AnActionEvent e) { final Presentation presentation = e.getPresentation(); - InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper(); + InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper(true); final InspectionRVContentProvider provider = myView.getProvider(); if (myView.isUpdating() && !myView.getTree().areDescriptorNodesSelected()) { presentation.setEnabled(false); @@ -82,7 +82,7 @@ public class InvokeQuickFixAction extends AnAction { @Override public void actionPerformed(AnActionEvent e) { - InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper(); + InspectionToolWrapper toolWrapper = myView.getTree().getSelectedToolWrapper(true); assert toolWrapper != null; final QuickFixAction[] quickFixes = myView.getProvider().getQuickFixes(toolWrapper, myView.getTree()); if (quickFixes == null || quickFixes.length == 0) { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java index f39a33728613..4be8fb95a714 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/KeyAwareInspectionViewAction.java @@ -60,14 +60,14 @@ public abstract class KeyAwareInspectionViewAction extends InspectionViewActionB @Override protected boolean isEnabled(@NotNull InspectionResultsView view, AnActionEvent e) { - final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(); + final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(true); return wrapper != null && HighlightDisplayKey.find(wrapper.getShortName()) != null; } @Override public void actionPerformed(AnActionEvent e) { final InspectionResultsView view = getView(e); - final HighlightDisplayKey key = HighlightDisplayKey.find(view.getTree().getSelectedToolWrapper().getShortName()); + final HighlightDisplayKey key = HighlightDisplayKey.find(view.getTree().getSelectedToolWrapper(true).getShortName()); actionPerformed(view, key); } @@ -82,7 +82,7 @@ public abstract class KeyAwareInspectionViewAction extends InspectionViewActionB protected boolean isEnabled(@NotNull InspectionResultsView view, AnActionEvent e) { final boolean enabled = super.isEnabled(view, e); if (!enabled) return false; - final HighlightDisplayKey key = HighlightDisplayKey.find(view.getTree().getSelectedToolWrapper().getShortName()); + final HighlightDisplayKey key = HighlightDisplayKey.find(view.getTree().getSelectedToolWrapper(true).getShortName()); final InspectionProfile profile = (InspectionProfile)InspectionProjectProfileManager.getInstance(view.getProject()).getProjectProfileImpl(); return profile.isToolEnabled(key); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/QuickFixesViewActionGroup.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/QuickFixesViewActionGroup.java index 994df27eef7e..c76357cd60e5 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/QuickFixesViewActionGroup.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/QuickFixesViewActionGroup.java @@ -37,7 +37,7 @@ public class QuickFixesViewActionGroup extends ActionGroup { if (view == null) { return AnAction.EMPTY_ARRAY; } - final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(); + final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(true); if (wrapper == null) return AnAction.EMPTY_ARRAY; final QuickFixAction[] fixes = view.getProvider().getQuickFixes(wrapper, view.getTree()); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/suppress/SuppressActionWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/suppress/SuppressActionWrapper.java index 5bb0da269446..04b48b194f1b 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/suppress/SuppressActionWrapper.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/suppress/SuppressActionWrapper.java @@ -65,7 +65,7 @@ public class SuppressActionWrapper extends ActionGroup implements CompactActionG public AnAction[] getChildren(@Nullable final AnActionEvent e) { final InspectionResultsView view = getView(e); if (view == null) return AnAction.EMPTY_ARRAY; - final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(); + final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(true); if (wrapper == null) return AnAction.EMPTY_ARRAY; final Set suppressActions = view.getSuppressActions(wrapper); @@ -105,7 +105,7 @@ public class SuppressActionWrapper extends ActionGroup implements CompactActionG Project project = view.getProject(); final String templatePresentationText = getTemplatePresentation().getText(); LOG.assertTrue(templatePresentationText != null); - final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(); + final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper(true); LOG.assertTrue(wrapper != null); final Set nodesAsSet = getNodesToSuppress(view); final SuppressableInspectionTreeNode[] nodes = nodesAsSet.toArray(new SuppressableInspectionTreeNode[nodesAsSet.size()]);