diff --git a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java index b301fdf6f673..81fad076d06a 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/offlineViewer/OfflineProblemDescriptorNode.java @@ -35,6 +35,7 @@ import com.intellij.codeInspection.ui.ProblemDescriptionNode; import com.intellij.lang.Language; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.util.Computable; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.FileStatus; import com.intellij.psi.*; import com.intellij.psi.util.PsiUtilCore; @@ -52,10 +53,11 @@ public class OfflineProblemDescriptorNode extends ProblemDescriptionNode { @NotNull LocalInspectionToolWrapper toolWrapper, @NotNull InspectionToolPresentation presentation, @NotNull OfflineProblemDescriptor offlineDescriptor) { - super(refEntity, descriptor, toolWrapper, presentation); + super(refEntity, descriptor, toolWrapper, presentation, false); if (descriptor == null) { setUserObject(offlineDescriptor); } + init(presentation.getContext().getProject()); } static OfflineProblemDescriptorNode create(@NotNull OfflineProblemDescriptor offlineDescriptor, @@ -66,16 +68,20 @@ public class OfflineProblemDescriptorNode extends ProblemDescriptionNode { return new OfflineProblemDescriptorNode(refElement, descriptor, toolWrapper, presentation, offlineDescriptor); } - @Override - public boolean calculateIsValid() { - return true; - } - @Override public FileStatus getNodeStatus() { return FileStatus.NOT_CHANGED; } + @NotNull + @Override + protected String calculatePresentableName() { + String presentableName = super.calculatePresentableName(); + return presentableName.isEmpty() && getUserObject() instanceof OfflineProblemDescriptor + ? StringUtil.notNullize(((OfflineProblemDescriptor)getUserObject()).getDescription()) + : presentableName; + } + private static PsiElement[] getElementsIntersectingRange(PsiFile file, final int startOffset, final int endOffset) { final FileViewProvider viewProvider = file.getViewProvider(); final Set result = new LinkedHashSet(); 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 ca8499c636eb..f77074eb1b80 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -66,8 +66,10 @@ import com.intellij.util.ConcurrencyUtil; import com.intellij.util.EditSourceOnDoubleClickHandler; import com.intellij.util.OpenSourceUtil; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.containers.FactoryMap; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.tree.TreeUtil; +import gnu.trove.THashSet; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -123,7 +125,13 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren private EditorEx myPreviewEditor; private InspectionTreeLoadingProgressAware myLoadingProgressPreview; private final ExcludedInspectionTreeNodesManager myExcludedInspectionTreeNodesManager; - private final Set mySuppressedNodes = new HashSet<>(); + private final FactoryMap> mySuppressedNodes = new FactoryMap>() { + @Nullable + @Override + protected Set create(String key) { + return new THashSet<>(); + } + }; private final ConcurrentMap> mySuppressActions = new ConcurrentHashMap<>(); private final Object myTreeStructureUpdateLock = new Object(); @@ -608,8 +616,8 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren }); } - public Set getSuppressedNodes() { - return mySuppressedNodes; + public Set getSuppressedNodes(String toolId) { + return mySuppressedNodes.get(toolId); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java index 1a9a2a8e700c..6fd9db74e607 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java @@ -49,6 +49,14 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode { CommonProblemDescriptor descriptor, @NotNull InspectionToolWrapper toolWrapper, @NotNull InspectionToolPresentation presentation) { + this(element, descriptor, toolWrapper, presentation, true); + } + + protected ProblemDescriptionNode(RefEntity element, + CommonProblemDescriptor descriptor, + @NotNull InspectionToolWrapper toolWrapper, + @NotNull InspectionToolPresentation presentation, + boolean doInit) { super(descriptor, presentation); myElement = element; myDescriptor = descriptor; @@ -57,7 +65,9 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode { myLevel = descriptor instanceof ProblemDescriptor ? profile.getErrorLevel(HighlightDisplayKey.find(toolWrapper.getShortName()), ((ProblemDescriptor)descriptor).getStartElement()) : profile.getTools(toolWrapper.getID(), element.getRefManager().getProject()).getLevel(); - init(presentation.getContext().getProject()); + if (doInit) { + init(presentation.getContext().getProject()); + } } @Override @@ -94,10 +104,10 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode { @Override protected boolean calculateIsValid() { + if (myDescriptor == null) return false; if (myElement instanceof RefElement && !myElement.isValid()) return false; - final CommonProblemDescriptor descriptor = getDescriptor(); - if (descriptor instanceof ProblemDescriptor) { - final PsiElement psiElement = ((ProblemDescriptor)descriptor).getPsiElement(); + if (myDescriptor instanceof ProblemDescriptor) { + final PsiElement psiElement = ((ProblemDescriptor)myDescriptor).getPsiElement(); return psiElement != null && psiElement.isValid(); } return true; @@ -137,6 +147,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode { } } + @NotNull @Override protected String calculatePresentableName() { CommonProblemDescriptor descriptor = getDescriptor(); @@ -148,7 +159,7 @@ public class ProblemDescriptionNode extends SuppressableInspectionTreeNode { } public boolean isQuickFixAppliedFromView() { - return myPresentation.isProblemResolved(getElement(), myDescriptor) && !isAlreadySuppressedFromView(); + return (myDescriptor != null && myPresentation.isProblemResolved(getElement(), myDescriptor)) && !isAlreadySuppressedFromView(); } @Nullable diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/SuppressableInspectionTreeNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/SuppressableInspectionTreeNode.java index d913ad648ecf..fd7cdad70989 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/SuppressableInspectionTreeNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/SuppressableInspectionTreeNode.java @@ -54,13 +54,7 @@ public abstract class SuppressableInspectionTreeNode extends CachedInspectionTre public final boolean isAlreadySuppressedFromView() { final Object usrObj = getUserObject(); LOG.assertTrue(usrObj != null); - return myView.getSuppressedNodes().contains(usrObj); - } - - public final void markAsSuppressedFromView() { - final Object usrObj = getUserObject(); - LOG.assertTrue(usrObj != null); - myView.getSuppressedNodes().add(usrObj); + return myView.getSuppressedNodes(myPresentation.getToolWrapper().getShortName()).contains(usrObj); } @Nullable diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/suppress/SuppressActionSequentialTask.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/suppress/SuppressActionSequentialTask.java index 2313ed8ebce7..17e11113e532 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/suppress/SuppressActionSequentialTask.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/suppress/SuppressActionSequentialTask.java @@ -145,7 +145,7 @@ public class SuppressActionSequentialTask implements SequentialTask { final CommonProblemDescriptor[] descriptors = myContext.getPresentation(wrapper).getIgnoredElements().get(entity); if (descriptors != null) { for (CommonProblemDescriptor problemDescriptor : descriptors) { - myContext.getView().getSuppressedNodes().add(problemDescriptor); + myContext.getView().getSuppressedNodes(wrapper.getShortName()).add(problemDescriptor); } } final List children = entity.getChildren(); @@ -156,7 +156,7 @@ public class SuppressActionSequentialTask implements SequentialTask { } } } - myContext.getView().getSuppressedNodes().add(descriptor); + myContext.getView().getSuppressedNodes(wrapper.getShortName()).add(descriptor); } catch (IncorrectOperationException e1) { LOG.error(e1);