dead code: support multiple suppression ids

This commit is contained in:
Anna Kozlova
2012-09-06 13:07:12 +04:00
parent d474aa3f1c
commit 490de1dc12
2 changed files with 8 additions and 3 deletions
@@ -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);
@@ -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;
}
}