This commit is contained in:
Alexey Kudravtsev
2014-10-13 13:55:37 +04:00
parent 999abbb615
commit ac288174ce
22 changed files with 99 additions and 88 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,15 +36,15 @@ public interface BatchSuppressManager {
@NotNull
SuppressQuickFix[] createBatchSuppressActions(@NotNull HighlightDisplayKey key);
boolean isSuppressedFor(@NotNull PsiElement element, String toolId);
boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String toolId);
PsiElement getElementMemberSuppressedIn(@NotNull PsiDocCommentOwner owner, String inspectionToolID);
PsiElement getElementMemberSuppressedIn(@NotNull PsiDocCommentOwner owner, @NotNull String inspectionToolID);
@Nullable
PsiElement getAnnotationMemberSuppressedIn(@NotNull PsiModifierListOwner owner, String inspectionToolID);
PsiElement getAnnotationMemberSuppressedIn(@NotNull PsiModifierListOwner owner, @NotNull String inspectionToolID);
@Nullable
PsiElement getDocCommentToolSuppressedIn(@NotNull PsiDocCommentOwner owner, String inspectionToolID);
PsiElement getDocCommentToolSuppressedIn(@NotNull PsiDocCommentOwner owner, @NotNull String inspectionToolID);
@NotNull
Collection<String> getInspectionIdsSuppressedInAnnotation(@NotNull PsiModifierListOwner owner);
@@ -53,7 +53,7 @@ public interface BatchSuppressManager {
String getSuppressedInspectionIdsIn(@NotNull PsiElement element);
@Nullable
PsiElement getElementToolSuppressedIn(@NotNull PsiElement place, String toolId);
PsiElement getElementToolSuppressedIn(@NotNull PsiElement place, @NotNull String toolId);
boolean canHave15Suppressions(@NotNull PsiElement file);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,10 @@ package com.intellij.codeInsight.daemon.impl;
import com.intellij.codeInsight.FileModificationService;
import com.intellij.codeInsight.daemon.QuickFixBundle;
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.JavaSuppressionUtil;
import com.intellij.codeInspection.LocalQuickFix;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.codeInspection.SuppressionUtilCore;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
@@ -38,15 +41,16 @@ import java.util.Set;
public class RemoveSuppressWarningAction implements LocalQuickFix {
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.daemon.impl.RemoveSuppressWarningAction");
@NotNull
private final String myID;
private final String myProblemLine;
public RemoveSuppressWarningAction(final String ID, final String problemLine) {
public RemoveSuppressWarningAction(@NotNull String ID, final String problemLine) {
myID = ID;
myProblemLine = problemLine;
}
public RemoveSuppressWarningAction(String id) {
public RemoveSuppressWarningAction(@NotNull String id) {
final int idx = id.indexOf(";");
if (idx > -1) {
myID = id.substring(0, idx);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,25 +41,25 @@ public class BatchSuppressManagerImpl implements BatchSuppressManager {
}
@Override
public boolean isSuppressedFor(@NotNull final PsiElement element, final String toolId) {
public boolean isSuppressedFor(@NotNull final PsiElement element, @NotNull final String toolId) {
return JavaSuppressionUtil.getElementToolSuppressedIn(element, toolId) != null;
}
@Override
@Nullable
public PsiElement getElementMemberSuppressedIn(@NotNull final PsiDocCommentOwner owner, final String inspectionToolID) {
public PsiElement getElementMemberSuppressedIn(@NotNull final PsiDocCommentOwner owner, @NotNull final String inspectionToolID) {
return JavaSuppressionUtil.getElementMemberSuppressedIn(owner, inspectionToolID);
}
@Override
@Nullable
public PsiElement getAnnotationMemberSuppressedIn(@NotNull final PsiModifierListOwner owner, final String inspectionToolID) {
public PsiElement getAnnotationMemberSuppressedIn(@NotNull final PsiModifierListOwner owner, @NotNull final String inspectionToolID) {
return JavaSuppressionUtil.getAnnotationMemberSuppressedIn(owner, inspectionToolID);
}
@Override
@Nullable
public PsiElement getDocCommentToolSuppressedIn(@NotNull final PsiDocCommentOwner owner, final String inspectionToolID) {
public PsiElement getDocCommentToolSuppressedIn(@NotNull final PsiDocCommentOwner owner, @NotNull final String inspectionToolID) {
return JavaSuppressionUtil.getDocCommentToolSuppressedIn(owner, inspectionToolID);
}
@@ -77,7 +77,7 @@ public class BatchSuppressManagerImpl implements BatchSuppressManager {
@Override
@Nullable
public PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, final String toolId) {
public PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, @NotNull final String toolId) {
return JavaSuppressionUtil.getElementToolSuppressedIn(place, toolId);
}
@@ -110,7 +110,7 @@ public class JavaSuppressionUtil {
return result;
}
public static PsiElement getElementMemberSuppressedIn(@NotNull PsiDocCommentOwner owner, String inspectionToolID) {
public static PsiElement getElementMemberSuppressedIn(@NotNull PsiDocCommentOwner owner, @NotNull String inspectionToolID) {
PsiElement element = getDocCommentToolSuppressedIn(owner, inspectionToolID);
if (element != null) return element;
element = getAnnotationMemberSuppressedIn(owner, inspectionToolID);
@@ -128,7 +128,7 @@ public class JavaSuppressionUtil {
return null;
}
static PsiElement getAnnotationMemberSuppressedIn(@NotNull PsiModifierListOwner owner, String inspectionToolID) {
static PsiElement getAnnotationMemberSuppressedIn(@NotNull PsiModifierListOwner owner, @NotNull String inspectionToolID) {
final PsiAnnotation generatedAnnotation = AnnotationUtil.findAnnotation(owner, Generated.class.getName());
if (generatedAnnotation != null) return generatedAnnotation;
PsiModifierList modifierList = owner.getModifierList();
@@ -141,7 +141,7 @@ public class JavaSuppressionUtil {
return null;
}
static PsiElement getDocCommentToolSuppressedIn(@NotNull PsiDocCommentOwner owner, String inspectionToolID) {
static PsiElement getDocCommentToolSuppressedIn(@NotNull PsiDocCommentOwner owner, @NotNull String inspectionToolID) {
PsiDocComment docComment = owner.getDocComment();
if (docComment == null && owner.getParent() instanceof PsiDeclarationStatement) {
final PsiElement el = PsiTreeUtil.skipSiblingsBackward(owner.getParent(), PsiWhiteSpace.class);
@@ -198,7 +198,7 @@ public class JavaSuppressionUtil {
return null;
}
static PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, final String toolId) {
static PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, @NotNull final String toolId) {
if (place instanceof PsiFile) return null;
return ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
@Override
@@ -44,25 +44,25 @@ public class SuppressManagerImpl extends SuppressManager {
}
@Override
public boolean isSuppressedFor(@NotNull final PsiElement element, final String toolId) {
public boolean isSuppressedFor(@NotNull final PsiElement element, @NotNull final String toolId) {
return JavaSuppressionUtil.getElementToolSuppressedIn(element, toolId) != null;
}
@Override
@Nullable
public PsiElement getElementMemberSuppressedIn(@NotNull final PsiDocCommentOwner owner, final String inspectionToolID) {
public PsiElement getElementMemberSuppressedIn(@NotNull final PsiDocCommentOwner owner, @NotNull final String inspectionToolID) {
return JavaSuppressionUtil.getElementMemberSuppressedIn(owner, inspectionToolID);
}
@Override
@Nullable
public PsiElement getAnnotationMemberSuppressedIn(@NotNull final PsiModifierListOwner owner, final String inspectionToolID) {
public PsiElement getAnnotationMemberSuppressedIn(@NotNull final PsiModifierListOwner owner, @NotNull final String inspectionToolID) {
return JavaSuppressionUtil.getAnnotationMemberSuppressedIn(owner, inspectionToolID);
}
@Override
@Nullable
public PsiElement getDocCommentToolSuppressedIn(@NotNull final PsiDocCommentOwner owner, final String inspectionToolID) {
public PsiElement getDocCommentToolSuppressedIn(@NotNull final PsiDocCommentOwner owner, @NotNull final String inspectionToolID) {
return JavaSuppressionUtil.getDocCommentToolSuppressedIn(owner, inspectionToolID);
}
@@ -80,7 +80,7 @@ public class SuppressManagerImpl extends SuppressManager {
@Override
@Nullable
public PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, final String toolId) {
public PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, @NotNull final String toolId) {
return JavaSuppressionUtil.getElementToolSuppressedIn(place, toolId);
}
@@ -19,7 +19,7 @@ import com.intellij.codeInsight.CodeInsightSettings;
import com.intellij.codeInsight.completion.CompletionUtil;
import com.intellij.codeInsight.daemon.ImplicitUsageProvider;
import com.intellij.codeInspection.SuppressManager;
import com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstance;
import com.intellij.codeInspection.accessStaticViaInstance.AccessStaticViaInstanceBase;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.text.StringUtil;
@@ -131,7 +131,7 @@ public class JavaCompletionProcessor extends BaseScopeProcessor implements Eleme
myAllowStaticWithInstanceQualifier = !options.filterStaticAfterInstance || CodeInsightSettings.getInstance().SHOW_STATIC_AFTER_INSTANCE ||
SuppressManager.getInstance()
.isSuppressedFor(element, AccessStaticViaInstance.ACCESS_STATIC_VIA_INSTANCE);
.isSuppressedFor(element, AccessStaticViaInstanceBase.ACCESS_STATIC_VIA_INSTANCE);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,13 +52,13 @@ public class JavaInspectionExtensionsFactory extends InspectionExtensionsFactory
}
@Override
public boolean isToCheckMember(final PsiElement element, final String id) {
public boolean isToCheckMember(@NotNull final PsiElement element, @NotNull final String id) {
return SuppressManager.getInstance().getElementToolSuppressedIn(element, id) == null;
}
@Override
@Nullable
public String getSuppressedInspectionIdsIn(final PsiElement element) {
public String getSuppressedInspectionIdsIn(@NotNull final PsiElement element) {
return SuppressManager.getInstance().getSuppressedInspectionIdsIn(element);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,7 +71,7 @@ public interface GlobalInspectionContext extends UserDataHolder {
* @param inspectionToolId the ID of the inspection to check.
* @return true if the inspection is suppressed, false otherwise.
*/
boolean isSuppressed(@NotNull PsiElement element, String inspectionToolId);
boolean isSuppressed(@NotNull PsiElement element, @NotNull String inspectionToolId);
@NotNull
Project getProject();
@@ -70,14 +70,16 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
@Override
public boolean isSuppressedFor(@NotNull PsiElement element) {
Set<InspectionSuppressor> suppressors = getSuppressors(element);
String toolId = getSuppressId();
for (InspectionSuppressor suppressor : suppressors) {
if (isSuppressed(suppressor, element)) {
if (isSuppressed(toolId, suppressor, element)) {
return true;
}
}
return false;
}
@NotNull
protected String getSuppressId() {
return getShortName();
}
@@ -85,31 +87,31 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{
@NotNull
@Override
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
if (element != null) {
THashSet<SuppressQuickFix> fixes = new THashSet<SuppressQuickFix>(new TObjectHashingStrategy<SuppressQuickFix>() {
@Override
public int computeHashCode(SuppressQuickFix object) {
return object.getName().hashCode();
}
@Override
public boolean equals(SuppressQuickFix o1, SuppressQuickFix o2) {
return o1.getName().equals(o2.getName());
}
});
Set<InspectionSuppressor> suppressors = getSuppressors(element);
for (InspectionSuppressor suppressor : suppressors) {
SuppressQuickFix[] actions = suppressor.getSuppressActions(element, getShortName());
fixes.addAll(Arrays.asList(actions));
}
return fixes.toArray(new SuppressQuickFix[fixes.size()]);
if (element == null) {
return SuppressQuickFix.EMPTY_ARRAY;
}
return SuppressQuickFix.EMPTY_ARRAY;
Set<SuppressQuickFix> fixes = new THashSet<SuppressQuickFix>(new TObjectHashingStrategy<SuppressQuickFix>() {
@Override
public int computeHashCode(SuppressQuickFix object) {
return object.getName().hashCode();
}
@Override
public boolean equals(SuppressQuickFix o1, SuppressQuickFix o2) {
return o1.getName().equals(o2.getName());
}
});
Set<InspectionSuppressor> suppressors = getSuppressors(element);
for (InspectionSuppressor suppressor : suppressors) {
SuppressQuickFix[] actions = suppressor.getSuppressActions(element, getShortName());
fixes.addAll(Arrays.asList(actions));
}
return fixes.toArray(new SuppressQuickFix[fixes.size()]);
}
private boolean isSuppressed(@Nullable InspectionSuppressor suppressor, @NotNull PsiElement element) {
if (suppressor == null) return false;
String toolId = getSuppressId();
private boolean isSuppressed(@NotNull String toolId,
@NotNull InspectionSuppressor suppressor,
@NotNull PsiElement element) {
if (suppressor.isSuppressedFor(element, toolId)) {
return true;
}
@@ -23,7 +23,7 @@ public interface InspectionSuppressor {
/**
* @see com.intellij.codeInspection.CustomSuppressableInspectionTool#isSuppressedFor(com.intellij.psi.PsiElement)
*/
boolean isSuppressedFor(@NotNull PsiElement element, String toolId);
boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String toolId);
/**
* @see com.intellij.codeInspection.BatchSuppressableTool#getBatchSuppressActions(com.intellij.psi.PsiElement)
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -71,6 +71,7 @@ public abstract class LocalInspectionTool extends InspectionProfileEntry {
return getShortName();
}
@NotNull
@Override
protected String getSuppressId() {
return getID();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,10 +38,10 @@ public abstract class InspectionExtensionsFactory {
@Nullable
public abstract HTMLComposerExtension createHTMLComposerExtension(final HTMLComposer composer);
public abstract boolean isToCheckMember(PsiElement element, String id);
public abstract boolean isToCheckMember(@NotNull PsiElement element, @NotNull String id);
@Nullable
public abstract String getSuppressedInspectionIdsIn(PsiElement element);
public abstract String getSuppressedInspectionIdsIn(@NotNull PsiElement element);
public abstract boolean isProjectConfiguredToRunInspections(@NotNull Project project, boolean online);
@@ -100,6 +100,7 @@ public class InspectionEngine {
}
// public accessibility for Upsource
// returns map (toolName -> problem descriptors)
@NotNull
public static Map<String, List<ProblemDescriptor>> inspectEx(@NotNull final List<LocalInspectionToolWrapper> toolWrappers,
@NotNull final PsiFile file,
@@ -60,7 +60,7 @@ public class SuppressionUtil extends SuppressionUtilCore {
private SuppressionUtil() {
}
public static boolean isInspectionToolIdMentioned(@NotNull String inspectionsList, String inspectionToolID) {
public static boolean isInspectionToolIdMentioned(@NotNull String inspectionsList, @NotNull String inspectionToolID) {
Iterable<String> ids = StringUtil.tokenize(inspectionsList, "[, ]");
for (@NonNls String id : ids) {
@@ -71,17 +71,17 @@ public class SuppressionUtil extends SuppressionUtilCore {
}
@Nullable
public static PsiElement getStatementToolSuppressedIn(final PsiElement place,
final String toolId,
final Class<? extends PsiElement> statementClass) {
public static PsiElement getStatementToolSuppressedIn(@NotNull PsiElement place,
@NotNull String toolId,
@NotNull Class<? extends PsiElement> statementClass) {
return getStatementToolSuppressedIn(place, toolId, statementClass, SUPPRESS_IN_LINE_COMMENT_PATTERN);
}
@Nullable
public static PsiElement getStatementToolSuppressedIn(final PsiElement place,
final String toolId,
final Class<? extends PsiElement> statementClass,
final Pattern suppressInLineCommentPattern) {
public static PsiElement getStatementToolSuppressedIn(@NotNull PsiElement place,
@NotNull String toolId,
@NotNull Class<? extends PsiElement> statementClass,
@NotNull Pattern suppressInLineCommentPattern) {
PsiElement statement = PsiTreeUtil.getNonStrictParentOfType(place, statementClass);
if (statement != null) {
PsiElement prev = PsiTreeUtil.skipSiblingsBackward(statement, PsiWhiteSpace.class);
@@ -96,9 +96,9 @@ public class SuppressionUtil extends SuppressionUtilCore {
return null;
}
public static boolean isSuppressedInStatement(final PsiElement place,
final String toolId,
final Class<? extends PsiElement> statementClass) {
public static boolean isSuppressedInStatement(@NotNull final PsiElement place,
@NotNull final String toolId,
@NotNull final Class<? extends PsiElement> statementClass) {
return ApplicationManager.getApplication().runReadAction(new NullableComputable<PsiElement>() {
@Override
public PsiElement compute() {
@@ -116,7 +116,7 @@ public class SuppressionUtil extends SuppressionUtilCore {
}
@Nullable
public static Couple<String> getBlockPrefixSuffixPair(PsiElement comment) {
public static Couple<String> getBlockPrefixSuffixPair(@NotNull PsiElement comment) {
final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(comment.getLanguage());
if (commenter != null) {
final String prefix = commenter.getBlockCommentPrefix();
@@ -177,14 +177,14 @@ public class SuppressionUtil extends SuppressionUtilCore {
public static void createSuppression(@NotNull Project project,
@NotNull PsiElement container,
@NotNull String id, @NotNull Language commentLanguage) {
@NotNull String id,
@NotNull Language commentLanguage) {
final String text = SUPPRESS_INSPECTIONS_TAG_NAME + " " + id;
PsiComment comment = createComment(project, text, commentLanguage);
container.getParent().addBefore(comment, container);
}
public static boolean isSuppressed(@NotNull PsiElement psiElement, String id) {
if (id == null) return false;
public static boolean isSuppressed(@NotNull PsiElement psiElement, @NotNull String id) {
for (InspectionExtensionsFactory factory : Extensions.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
if (!factory.isToCheckMember(psiElement, id)) {
return true;
@@ -141,7 +141,7 @@ public class GlobalInspectionContextBase extends UserDataHolderBase implements G
}
@Override
public boolean isSuppressed(@NotNull PsiElement element, String id) {
public boolean isSuppressed(@NotNull PsiElement element, @NotNull String id) {
final RefManagerImpl refManager = (RefManagerImpl)getRefManager();
if (refManager.isDeclarationsFound()) {
final RefElement refElement = refManager.getReference(element);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -259,7 +259,7 @@ public abstract class RefElementImpl extends RefEntityImpl implements RefElement
mySuppressions = text.split("[, ]");
}
public boolean isSuppressed(final String... toolId) {
public boolean isSuppressed(@NotNull String... toolId) {
if (mySuppressions != null) {
for (@NonNls String suppression : mySuppressions) {
for (String id : toolId) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,8 +57,7 @@ public class EditInspectionToolsSettingsInSuppressedPlaceIntention implements In
int offset = editor.getCaretModel().getOffset();
PsiElement element = file.findElementAt(offset);
while (element != null && !(element instanceof PsiFile)) {
for (InspectionExtensionsFactory factory : Extensions
.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
for (InspectionExtensionsFactory factory : Extensions.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
final String suppressedIds = factory.getSuppressedInspectionIdsIn(element);
if (suppressedIds != null) {
String text = element.getText();
@@ -58,12 +58,12 @@ public abstract class GroovySuppressableInspectionTool extends LocalInspectionTo
};
}
public static boolean isElementToolSuppressedIn(final PsiElement place, final String toolId) {
public static boolean isElementToolSuppressedIn(final PsiElement place, @NotNull String toolId) {
return getElementToolSuppressedIn(place, toolId) != null;
}
@Nullable
public static PsiElement getElementToolSuppressedIn(final PsiElement place, final String toolId) {
public static PsiElement getElementToolSuppressedIn(final PsiElement place, @NotNull String toolId) {
if (place == null) return null;
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
@@ -45,7 +45,7 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
public boolean myHighlightIfMissingMethodsDeclared = true;
public boolean myHighlightInnerClasses = true;
public static boolean isSuppressed(PsiElement ref) {
public static boolean isSuppressed(@NotNull PsiElement ref) {
return isElementToolSuppressedIn(ref, SHORT_NAME);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,15 +15,17 @@
*/
package com.jetbrains.python.inspections;
import com.intellij.codeInspection.*;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.SuppressQuickFix;
import com.intellij.codeInspection.SuppressionUtil;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.inspections.quickfix.PySuppressInspectionFix;
import com.jetbrains.python.codeInsight.controlflow.ScopeOwner;
import com.jetbrains.python.inspections.quickfix.PySuppressInspectionFix;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.psi.impl.PyFileImpl;
import org.jetbrains.annotations.Nls;
@@ -129,6 +131,7 @@ public abstract class PyInspection extends LocalInspectionTool {
return m.matches() && SuppressionUtil.isInspectionToolIdMentioned(m.group(1), getSuppressId());
}
@NotNull
protected String getSuppressId() {
return getShortName().replace("Inspection", "");
}
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable;
public class XmlInspectionSuppressor implements InspectionSuppressor{
@Override
public boolean isSuppressedFor(@NotNull PsiElement element, String toolId) {
public boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String toolId) {
return XmlSuppressionProvider.isSuppressed(element, toolId);
}
@@ -41,6 +41,7 @@ public abstract class XmlSuppressionProvider implements InspectionSuppressor {
public abstract boolean isProviderAvailable(@NotNull PsiFile file);
@Override
public abstract boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String inspectionId);
public abstract void suppressForFile(@NotNull PsiElement element, @NotNull String inspectionId);