From 490de1dc12cbdcde0630e3e39be9b40e303b7082 Mon Sep 17 00:00:00 2001 From: Anna Kozlova Date: Thu, 6 Sep 2012 13:03:29 +0400 Subject: [PATCH] dead code: support multiple suppression ids --- .../deadCode/UnusedDeclarationInspection.java | 3 ++- .../intellij/codeInspection/reference/RefElementImpl.java | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index 63f7af036750..64eaa91db3af 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java @@ -96,6 +96,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool { private WeakUnreferencedFilter myFilter; private DeadHTMLComposer myComposer; @NonNls public static final String SHORT_NAME = "UnusedDeclaration"; + @NonNls private static final String ALTERNATIVE_ID = "unused"; private static final String COMMENT_OUT_QUICK_FIX = InspectionsBundle.message("inspection.dead.code.comment.quickfix"); private static final String DELETE_QUICK_FIX = InspectionsBundle.message("inspection.dead.code.safe.delete.quickfix"); @@ -351,7 +352,7 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool { PsiFile file = refElement.getContainingFile(); if (file == null) return; - final boolean isSuppressed = refElement.isSuppressed(getShortName()); + final boolean isSuppressed = refElement.isSuppressed(getShortName(), ALTERNATIVE_ID); if (!getContext().isToCheckFile(file, UnusedDeclarationInspection.this) || isSuppressed) { if (isSuppressed || !scope.contains(file)) { getEntryPointsManager().addEntryPoint(refElement, false); diff --git a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java index 3899fd5a402c..129bdde2d9ed 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java @@ -36,6 +36,7 @@ import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.SmartPointerManager; import com.intellij.psi.SmartPsiElementPointer; +import com.intellij.util.ArrayUtil; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -252,10 +253,13 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement mySuppressions = text.split("[, ]"); } - public boolean isSuppressed(final String toolId) { + public boolean isSuppressed(final String... toolId) { if (mySuppressions != null) { for (@NonNls String suppression : mySuppressions) { - if (suppression.equals(toolId) || suppression.equalsIgnoreCase(SuppressionUtil.ALL)){ + for (String id : toolId) { + if (suppression.equals(id)) return true; + } + if (suppression.equalsIgnoreCase(SuppressionUtil.ALL)){ return true; } }