inspection toolwindow: use getFamilyName of suppress fixes to show in popup IDEA-156180

This commit is contained in:
Dmitry Batkovich
2016-05-24 11:12:07 +03:00
parent b4b39a0c30
commit 1cd7011a82
3 changed files with 20 additions and 9 deletions
@@ -39,12 +39,12 @@ public abstract class InspectionViewActionBase extends AnAction {
@Override
public final void update(AnActionEvent e) {
final InspectionResultsView view = getView(e);
final boolean enabled = view != null && isEnabled(view);
final boolean enabled = view != null && isEnabled(view, e);
final Presentation presentation = e.getPresentation();
presentation.setEnabled(enabled);
}
protected boolean isEnabled(@NotNull InspectionResultsView view) {
protected boolean isEnabled(@NotNull InspectionResultsView view, AnActionEvent e) {
return true;
}
@@ -49,7 +49,7 @@ public abstract class KeyAwareInspectionViewAction extends InspectionViewActionB
}
@Override
protected boolean isEnabled(@NotNull InspectionResultsView view) {
protected boolean isEnabled(@NotNull InspectionResultsView view, AnActionEvent e) {
final InspectionToolWrapper wrapper = view.getTree().getSelectedToolWrapper();
return wrapper != null && HighlightDisplayKey.find(wrapper.getShortName()) != null;
}
@@ -69,8 +69,8 @@ public abstract class KeyAwareInspectionViewAction extends InspectionViewActionB
}
@Override
protected boolean isEnabled(@NotNull InspectionResultsView view) {
final boolean enabled = super.isEnabled(view);
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 InspectionProfile profile = (InspectionProfile)InspectionProjectProfileManager.getInstance(view.getProject()).getProjectProfileImpl();
@@ -116,8 +116,8 @@ public abstract class KeyAwareInspectionViewAction extends InspectionViewActionB
}
@Override
protected boolean isEnabled(@NotNull InspectionResultsView view) {
return super.isEnabled(view) && getPsiElement(view) != null;
protected boolean isEnabled(@NotNull InspectionResultsView view, AnActionEvent e) {
return super.isEnabled(view, e) && getPsiElement(view) != null;
}
@Override
@@ -37,6 +37,7 @@ import com.intellij.openapi.command.CommandProcessor;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiElement;
import com.intellij.util.SequentialModalProgressTask;
import com.intellij.util.containers.HashSet;
import com.intellij.util.ui.tree.TreeUtil;
@@ -127,9 +128,19 @@ public class SuppressActionWrapper extends ActionGroup implements CompactActionG
}
@Override
protected boolean isEnabled(@NotNull InspectionResultsView view) {
for (SuppressableInspectionTreeNode node : getNodesToSuppress(view)) {
protected boolean isEnabled(@NotNull InspectionResultsView view, AnActionEvent e) {
final Set<SuppressableInspectionTreeNode> suppressNodes = getNodesToSuppress(view);
for (SuppressableInspectionTreeNode node : suppressNodes) {
if (node.getAvailableSuppressActions().contains(mySuppressAction)) {
String text = mySuppressAction.getFamilyName();
if (suppressNodes.size() == 1) {
final PsiElement element = node.getSuppressContent().getFirst();
if (element != null) {
mySuppressAction.isAvailable(view.getProject(), null, element);
text = mySuppressAction.getText();
}
}
e.getPresentation().setText(text);
return true;
}
}