From cea1d3ab7167b4bf9f26eefd1e3f43bd904c7e9e Mon Sep 17 00:00:00 2001 From: anna Date: Mon, 6 Feb 2012 10:49:40 +0100 Subject: [PATCH] IRV: IDEA-80843 removal entries removes more than you expect --- .../ex/DescriptorProviderInspection.java | 19 +++++++++++++++++++ .../ui/ProblemDescriptionNode.java | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java index 2d8d5ec100a3..6503e871fc90 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/DescriptorProviderInspection.java @@ -187,6 +187,14 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem getIgnoredElements().put(refEntity, problemDescriptors); } + public void ignoreCurrentElementProblem(RefEntity refEntity, CommonProblemDescriptor descriptor) { + CommonProblemDescriptor[] descriptors = getIgnoredElements().get(refEntity); + if (descriptors == null) { + descriptors = new CommonProblemDescriptor[0]; + } + getIgnoredElements().put(refEntity, ArrayUtil.append(descriptors, descriptor)); + } + private static boolean isIgnoreProblem(QuickFix[] problemFixes, Set fixes, int idx){ if (problemFixes == null || fixes == null) { return true; @@ -451,6 +459,17 @@ public abstract class DescriptorProviderInspection extends InspectionTool implem return false; } + public boolean isProblemResolved(RefEntity refEntity, CommonProblemDescriptor descriptor) { + if (getIgnoredElements() == null) return false; + for (RefEntity entity : getIgnoredElements().keySet()) { + if (Comparing.equal(entity, refEntity)) { + final CommonProblemDescriptor[] descriptors = getIgnoredElements().get(refEntity); + return ArrayUtil.contains(descriptor, descriptors); + } + } + return false; + } + public FileStatus getProblemStatus(final CommonProblemDescriptor descriptor) { final GlobalInspectionContextImpl context = getContext(); if (context != null && context.getUIOptions().SHOW_DIFF_WITH_PREVIOUS_RUN){ 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 2610ab6d0fb5..b92dab9a6384 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/ProblemDescriptionNode.java @@ -95,11 +95,11 @@ public class ProblemDescriptionNode extends InspectionTreeNode { public boolean isResolved() { - return myElement instanceof RefElement && myTool.isElementIgnored(myElement); + return myElement instanceof RefElement && myTool.isProblemResolved(myElement, getDescriptor()); } public void ignoreElement() { - myTool.ignoreCurrentElement(getElement()); + myTool.ignoreCurrentElementProblem(getElement(), getDescriptor()); } public void amnesty() {