mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
dead code: support multiple suppression ids
This commit is contained in:
+2
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user