mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
all inspections are suppressable by default; language suppressor is needed to provide non trivial implementation
This commit is contained in:
+2
-12
@@ -26,18 +26,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
* - work with PSI or document only and
|
||||
* - don't provide {@link com.intellij.codeInsight.intention.IntentionAction} for quick fixes/suppression, making do with {@link LocalQuickFix} only.
|
||||
*/
|
||||
public abstract class BaseJavaBatchLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool implements BatchSuppressableTool {
|
||||
@NotNull
|
||||
@Override
|
||||
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
|
||||
return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(HighlightDisplayKey.find(getShortName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressedFor(@NotNull PsiElement element) {
|
||||
return isSuppressedFor(element, this);
|
||||
}
|
||||
|
||||
public abstract class BaseJavaBatchLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool {
|
||||
@Deprecated
|
||||
public static boolean isSuppressedFor(@NotNull PsiElement element, @NotNull LocalInspectionTool tool) {
|
||||
BatchSuppressManager manager = BatchSuppressManager.SERVICE.getInstance();
|
||||
String alternativeId;
|
||||
|
||||
+1
-5
@@ -42,11 +42,7 @@ public abstract class BaseJavaLocalInspectionTool extends AbstractBaseJavaLocalI
|
||||
return SuppressManager.getInstance().createSuppressActions(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressedFor(@NotNull PsiElement element) {
|
||||
return isSuppressedFor(element, this);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isSuppressedFor(@NotNull PsiElement element, @NotNull LocalInspectionTool tool) {
|
||||
return BaseJavaBatchLocalInspectionTool.isSuppressedFor(element, tool);
|
||||
}
|
||||
|
||||
+1
-11
@@ -26,7 +26,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class GlobalJavaBatchInspectionTool extends GlobalInspectionTool implements BatchSuppressableTool {
|
||||
public abstract class GlobalJavaBatchInspectionTool extends GlobalInspectionTool {
|
||||
@Override
|
||||
public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager,
|
||||
@NotNull final GlobalInspectionContext globalContext,
|
||||
@@ -38,14 +38,4 @@ public abstract class GlobalJavaBatchInspectionTool extends GlobalInspectionTool
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
|
||||
return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(HighlightDisplayKey.find(getShortName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressedFor(@NotNull final PsiElement element) {
|
||||
return BatchSuppressManager.SERVICE.getInstance().isSuppressedFor(element, getShortName());
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -26,7 +26,7 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class GlobalJavaInspectionTool extends GlobalInspectionTool implements CustomSuppressableInspectionTool {
|
||||
public abstract class GlobalJavaInspectionTool extends GlobalInspectionTool {
|
||||
@Override
|
||||
public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager,
|
||||
@NotNull final GlobalInspectionContext globalContext,
|
||||
@@ -38,10 +38,10 @@ public abstract class GlobalJavaInspectionTool extends GlobalInspectionTool impl
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@Nullable
|
||||
public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
|
||||
return SuppressManager.getInstance().createSuppressActions(HighlightDisplayKey.find(getShortName()));
|
||||
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
|
||||
return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(HighlightDisplayKey.find(getShortName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-23
@@ -15,14 +15,11 @@
|
||||
*/
|
||||
package com.intellij.codeInspection.unusedSymbol;
|
||||
|
||||
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class UnusedSymbolLocalInspectionBase extends AbstractBaseJavaLocalInspectionTool implements CustomSuppressableInspectionTool {
|
||||
public class UnusedSymbolLocalInspectionBase extends BaseJavaLocalInspectionTool {
|
||||
@NonNls public static final String SHORT_NAME = HighlightInfoType.UNUSED_SYMBOL_SHORT_NAME;
|
||||
@NonNls public static final String DISPLAY_NAME = HighlightInfoType.UNUSED_SYMBOL_DISPLAY_NAME;
|
||||
@NonNls public static final String UNUSED_PARAMETERS_SHORT_NAME = "UnusedParameters";
|
||||
@@ -33,22 +30,4 @@ public class UnusedSymbolLocalInspectionBase extends AbstractBaseJavaLocalInspec
|
||||
public boolean CLASS = true;
|
||||
public boolean PARAMETER = true;
|
||||
public boolean REPORT_PARAMETER_FOR_PUBLIC_METHODS = true;
|
||||
|
||||
@Override
|
||||
public boolean isSuppressedFor(@NotNull PsiElement element) {
|
||||
return isSuppressedFor(element, this);
|
||||
}
|
||||
public static boolean isSuppressedFor(@NotNull PsiElement element, @NotNull LocalInspectionTool tool) {
|
||||
return BaseJavaBatchLocalInspectionTool.isSuppressedFor(element, tool);
|
||||
}
|
||||
@Override
|
||||
public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
|
||||
String shortName = getShortName();
|
||||
HighlightDisplayKey key = HighlightDisplayKey.find(shortName);
|
||||
if (key == null) {
|
||||
throw new AssertionError("HighlightDisplayKey.find(" + shortName + ") is null. Inspection: "+getClass());
|
||||
}
|
||||
SuppressQuickFix[] batchSuppressActions = BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(key);
|
||||
return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionActions(batchSuppressActions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.ResourceUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.xmlb.SerializationFilter;
|
||||
@@ -46,7 +47,7 @@ import java.util.Set;
|
||||
* @since 28-Nov-2005
|
||||
*/
|
||||
@SuppressWarnings("JavadocReference")
|
||||
public abstract class InspectionProfileEntry {
|
||||
public abstract class InspectionProfileEntry implements BatchSuppressableTool{
|
||||
public static final String GENERAL_GROUP_NAME = InspectionsBundle.message("inspection.general.tools.group.name");
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.InspectionProfileEntry");
|
||||
@@ -56,6 +57,42 @@ public abstract class InspectionProfileEntry {
|
||||
private static final Object BLACK_LIST_LOCK = new Object();
|
||||
private Boolean myUseNewSerializer = null;
|
||||
|
||||
@NonNls
|
||||
@Nullable
|
||||
public String getAlternativeID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressedFor(@NotNull PsiElement element) {
|
||||
InspectionSuppressor suppressor = LanguageInspectionSuppressors.INSTANCE.forLanguage(element.getLanguage());
|
||||
if (suppressor != null) {
|
||||
String toolId = getSuppressId();
|
||||
if (suppressor.isSuppressedFor(element, toolId)) {
|
||||
return true;
|
||||
}
|
||||
final String alternativeId = getAlternativeID();
|
||||
return alternativeId != null && !alternativeId.equals(toolId) && suppressor.isSuppressedFor(element, alternativeId);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected String getSuppressId() {
|
||||
return getShortName();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
|
||||
if (element != null) {
|
||||
InspectionSuppressor suppressor = LanguageInspectionSuppressors.INSTANCE.forLanguage(element.getLanguage());
|
||||
if (suppressor != null) {
|
||||
return suppressor.getSuppressActions(element, getShortName());
|
||||
}
|
||||
}
|
||||
return SuppressQuickFix.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
public void cleanup(Project project) {
|
||||
|
||||
}
|
||||
|
||||
@@ -71,6 +71,11 @@ public abstract class LocalInspectionTool extends InspectionProfileEntry {
|
||||
return getShortName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSuppressId() {
|
||||
return getID();
|
||||
}
|
||||
|
||||
@NonNls
|
||||
@Nullable
|
||||
public String getAlternativeID() {
|
||||
|
||||
@@ -830,33 +830,23 @@ public class HighlightInfo implements Segment {
|
||||
throw new AssertionError("unknown tool: " + toolWrapper+"; key: "+myKey);
|
||||
}
|
||||
|
||||
SuppressQuickFix[] suppressFixes = null;
|
||||
if (wrappedTool instanceof CustomSuppressableInspectionTool) {
|
||||
suppressFixes = SuppressQuickFix.EMPTY_ARRAY;
|
||||
final IntentionAction[] suppressActions = ((CustomSuppressableInspectionTool)wrappedTool).getSuppressActions(element);
|
||||
if (suppressActions != null) {
|
||||
ContainerUtil.addAll(newOptions, suppressActions);
|
||||
}
|
||||
}
|
||||
if (wrappedTool instanceof BatchSuppressableTool) {
|
||||
suppressFixes = ((BatchSuppressableTool)wrappedTool).getBatchSuppressActions(element);
|
||||
}
|
||||
|
||||
if (suppressFixes == null) {
|
||||
final InspectionSuppressor suppressor = LanguageInspectionSuppressors.INSTANCE.forLanguage(element.getLanguage());
|
||||
if (suppressor != null) {
|
||||
suppressFixes = suppressor.getSuppressActions(element, wrappedTool.getShortName());
|
||||
} else {
|
||||
SuppressQuickFix[] suppressFixes = wrappedTool.getBatchSuppressActions(element);
|
||||
if (suppressFixes.length > 0) {
|
||||
ContainerUtil.addAll(newOptions, ContainerUtil.map(suppressFixes, new Function<SuppressQuickFix, IntentionAction>() {
|
||||
@Override
|
||||
public IntentionAction fun(SuppressQuickFix fix) {
|
||||
return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction(fix);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
if (suppressFixes != null) {
|
||||
ContainerUtil.addAll(newOptions, ContainerUtil.map(suppressFixes, new Function<SuppressQuickFix, IntentionAction>() {
|
||||
@Override
|
||||
public IntentionAction fun(SuppressQuickFix fix) {
|
||||
return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction(fix);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (myProblemGroup instanceof SuppressableProblemGroup) {
|
||||
final IntentionAction[] suppressActions = ((SuppressableProblemGroup)myProblemGroup).getSuppressActions(element);
|
||||
|
||||
@@ -194,24 +194,6 @@ public class SuppressionUtil extends SuppressionUtilCore {
|
||||
}
|
||||
|
||||
public static boolean inspectionResultSuppressed(@NotNull PsiElement place, @NotNull LocalInspectionTool tool) {
|
||||
if (tool instanceof CustomSuppressableInspectionTool) {
|
||||
return ((CustomSuppressableInspectionTool)tool).isSuppressedFor(place);
|
||||
}
|
||||
if (tool instanceof BatchSuppressableTool) {
|
||||
return ((BatchSuppressableTool)tool).isSuppressedFor(place);
|
||||
}
|
||||
|
||||
final InspectionSuppressor suppressor = LanguageInspectionSuppressors.INSTANCE.forLanguage(place.getLanguage());
|
||||
if (suppressor != null) {
|
||||
return suppressor.isSuppressedFor(place, tool.getID());
|
||||
}
|
||||
|
||||
String alternativeId;
|
||||
String id;
|
||||
|
||||
return isSuppressed(place, id = tool.getID()) ||
|
||||
(alternativeId = tool.getAlternativeID()) != null &&
|
||||
!alternativeId.equals(id) &&
|
||||
isSuppressed(place, alternativeId);
|
||||
return tool.isSuppressedFor(place);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,16 +90,13 @@ public class InspectionManagerEx extends InspectionManagerBase {
|
||||
if (tool instanceof CustomSuppressableInspectionTool) {
|
||||
return ((CustomSuppressableInspectionTool)tool).getSuppressActions(null);
|
||||
}
|
||||
if (tool instanceof BatchSuppressableTool) {
|
||||
LocalQuickFix[] actions = ((BatchSuppressableTool)tool).getBatchSuppressActions(null);
|
||||
return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<LocalQuickFix, SuppressIntentionAction>() {
|
||||
@Override
|
||||
public SuppressIntentionAction fun(final LocalQuickFix fix) {
|
||||
return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction((SuppressQuickFix)fix);
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
LocalQuickFix[] actions = tool.getBatchSuppressActions(null);
|
||||
return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<LocalQuickFix, SuppressIntentionAction>() {
|
||||
@Override
|
||||
public SuppressIntentionAction fun(final LocalQuickFix fix) {
|
||||
return SuppressIntentionActionFromFix.convertBatchToSuppressIntentionAction((SuppressQuickFix)fix);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-13
@@ -44,14 +44,7 @@ import java.util.regex.Matcher;
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class GroovySuppressableInspectionTool extends LocalInspectionTool implements BatchSuppressableTool {
|
||||
@NotNull
|
||||
@Override
|
||||
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
|
||||
return getSuppressActions(getShortName());
|
||||
|
||||
}
|
||||
|
||||
public abstract class GroovySuppressableInspectionTool extends LocalInspectionTool {
|
||||
public static SuppressQuickFix[] getSuppressActions(String name) {
|
||||
final HighlightDisplayKey displayKey = HighlightDisplayKey.find(name);
|
||||
return new SuppressQuickFix[] {
|
||||
@@ -61,11 +54,6 @@ public abstract class GroovySuppressableInspectionTool extends LocalInspectionTo
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressedFor(@NotNull final PsiElement element) {
|
||||
return isElementToolSuppressedIn(element, getID());
|
||||
}
|
||||
|
||||
public static boolean isElementToolSuppressedIn(final PsiElement place, final String toolId) {
|
||||
return getElementToolSuppressedIn(place, toolId) != null;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package com.jetbrains.rest.inspections;
|
||||
|
||||
import com.intellij.codeInspection.CustomSuppressableInspectionTool;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.SuppressIntentionAction;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.jetbrains.rest.RestBundle;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
@@ -27,7 +25,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* User : catherine
|
||||
*/
|
||||
public abstract class RestInspection extends LocalInspectionTool implements CustomSuppressableInspectionTool {
|
||||
public abstract class RestInspection extends LocalInspectionTool {
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -46,9 +44,10 @@ public abstract class RestInspection extends LocalInspectionTool implements Cust
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SuppressIntentionAction[] getSuppressActions(@Nullable PsiElement element) {
|
||||
return null;
|
||||
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
|
||||
return SuppressQuickFix.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.codeInspection.LocalInspectionToolSession;
|
||||
import com.intellij.codeInspection.ProblemsHolder;
|
||||
import com.intellij.codeInspection.SuppressIntentionAction;
|
||||
import com.intellij.codeInspection.SuppressQuickFix;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -230,9 +230,10 @@ public class PyDocstringInspection extends PyInspection {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SuppressIntentionAction[] getSuppressActions(@Nullable PsiElement element) {
|
||||
List<SuppressIntentionAction> result = new ArrayList<SuppressIntentionAction>();
|
||||
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
|
||||
List<SuppressQuickFix> result = new ArrayList<SuppressQuickFix>();
|
||||
if (element != null) {
|
||||
if (PsiTreeUtil.getParentOfType(element, PyFunction.class) != null) {
|
||||
result.add(new PySuppressInspectionFix(getShortName().replace("Inspection", ""), "Suppress for function", PyFunction.class));
|
||||
@@ -241,6 +242,6 @@ public class PyDocstringInspection extends PyInspection {
|
||||
result.add(new PySuppressInspectionFix(getShortName().replace("Inspection", ""), "Suppress for class", PyClass.class));
|
||||
}
|
||||
}
|
||||
return result.toArray(new SuppressIntentionAction[result.size()]);
|
||||
return result.toArray(new SuppressQuickFix[result.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,7 @@
|
||||
*/
|
||||
package com.jetbrains.python.inspections;
|
||||
|
||||
import com.intellij.codeInspection.CustomSuppressableInspectionTool;
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.SuppressIntentionAction;
|
||||
import com.intellij.codeInspection.SuppressionUtil;
|
||||
import com.intellij.codeInspection.*;
|
||||
import com.intellij.psi.PsiComment;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -41,7 +38,7 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public abstract class PyInspection extends LocalInspectionTool implements CustomSuppressableInspectionTool {
|
||||
public abstract class PyInspection extends LocalInspectionTool {
|
||||
@Nls
|
||||
@NotNull
|
||||
@Override
|
||||
@@ -60,12 +57,13 @@ public abstract class PyInspection extends LocalInspectionTool implements Custom
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SuppressIntentionAction[] getSuppressActions(@Nullable final PsiElement element) {
|
||||
List<SuppressIntentionAction> result = new ArrayList<SuppressIntentionAction>();
|
||||
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
|
||||
List<SuppressQuickFix> result = new ArrayList<SuppressQuickFix>();
|
||||
result.add(new PySuppressInspectionFix(getSuppressId(), "Suppress for statement", PyStatement.class) {
|
||||
@Override
|
||||
protected PsiElement getContainer(PsiElement context) {
|
||||
public PsiElement getContainer(PsiElement context) {
|
||||
if (PsiTreeUtil.getParentOfType(context, PyStatementList.class, false, ScopeOwner.class) != null ||
|
||||
PsiTreeUtil.getParentOfType(context, PyFunction.class, PyClass.class) == null) {
|
||||
return super.getContainer(context);
|
||||
@@ -75,7 +73,7 @@ public abstract class PyInspection extends LocalInspectionTool implements Custom
|
||||
});
|
||||
result.add(new PySuppressInspectionFix(getSuppressId(), "Suppress for function", PyFunction.class));
|
||||
result.add(new PySuppressInspectionFix(getSuppressId(), "Suppress for class", PyClass.class));
|
||||
return result.toArray(new SuppressIntentionAction[result.size()]);
|
||||
return result.toArray(new SuppressQuickFix[result.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -131,7 +129,7 @@ public abstract class PyInspection extends LocalInspectionTool implements Custom
|
||||
return m.matches() && SuppressionUtil.isInspectionToolIdMentioned(m.group(1), getSuppressId());
|
||||
}
|
||||
|
||||
private String getSuppressId() {
|
||||
protected String getSuppressId() {
|
||||
return getShortName().replace("Inspection", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.jetbrains.python.inspections.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.impl.actions.AbstractBatchSuppressByNoInspectionCommentFix;
|
||||
import com.intellij.codeInsight.daemon.impl.actions.AbstractSuppressByNoInspectionCommentFix;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
@@ -23,7 +24,7 @@ import com.jetbrains.python.psi.PyElement;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class PySuppressInspectionFix extends AbstractSuppressByNoInspectionCommentFix {
|
||||
public class PySuppressInspectionFix extends AbstractBatchSuppressByNoInspectionCommentFix {
|
||||
private final Class<? extends PyElement> myContainerClass;
|
||||
|
||||
public PySuppressInspectionFix(final String ID, final String text, final Class<? extends PyElement> containerClass) {
|
||||
@@ -33,7 +34,7 @@ public class PySuppressInspectionFix extends AbstractSuppressByNoInspectionComme
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PsiElement getContainer(PsiElement context) {
|
||||
public PsiElement getContainer(PsiElement context) {
|
||||
return PsiTreeUtil.getParentOfType(context, myContainerClass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.awt.*;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
public class SpellCheckingInspection extends LocalInspectionTool implements BatchSuppressableTool {
|
||||
public class SpellCheckingInspection extends LocalInspectionTool {
|
||||
public static final String SPELL_CHECKING_INSPECTION_TOOL_NAME = "SpellCheckingInspection";
|
||||
|
||||
@Override
|
||||
@@ -66,12 +66,8 @@ public class SpellCheckingInspection extends LocalInspectionTool implements Batc
|
||||
if(strategy instanceof SuppressibleSpellcheckingStrategy) {
|
||||
return ((SuppressibleSpellcheckingStrategy)strategy).getSuppressActions(element, getShortName());
|
||||
}
|
||||
final InspectionSuppressor suppressor = LanguageInspectionSuppressors.INSTANCE.forLanguage(language);
|
||||
if (suppressor != null) {
|
||||
return suppressor.getSuppressActions(element, getShortName());
|
||||
}
|
||||
}
|
||||
return SuppressQuickFix.EMPTY_ARRAY;
|
||||
return super.getBatchSuppressActions(element);
|
||||
}
|
||||
|
||||
private static SpellcheckingStrategy getSpellcheckingStrategy(@NotNull PsiElement element, @NotNull Language language) {
|
||||
@@ -90,8 +86,7 @@ public class SpellCheckingInspection extends LocalInspectionTool implements Batc
|
||||
if (strategy instanceof SuppressibleSpellcheckingStrategy) {
|
||||
return ((SuppressibleSpellcheckingStrategy)strategy).isSuppressedFor(element, getShortName());
|
||||
}
|
||||
final InspectionSuppressor suppressor = LanguageInspectionSuppressors.INSTANCE.forLanguage(language);
|
||||
return suppressor != null && suppressor.isSuppressedFor(element, getShortName());
|
||||
return super.isSuppressedFor(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,25 +26,14 @@ import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool implements BatchSuppressableTool {
|
||||
public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool {
|
||||
@NonNls static final String ALL = "ALL";
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
|
||||
return getSuppressFixes(getID());
|
||||
}
|
||||
|
||||
public static SuppressQuickFix[] getSuppressFixes(final String shortName) {
|
||||
final String id = HighlightDisplayKey.find(shortName).getID();
|
||||
return new SuppressQuickFix[]{new SuppressTagStatic(id), new SuppressForFile(id), new SuppressAllForFile()};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuppressedFor(@NotNull final PsiElement element) {
|
||||
return XmlSuppressionProvider.isSuppressed(element, getID());
|
||||
}
|
||||
|
||||
public class SuppressTag extends SuppressTagStatic {
|
||||
public SuppressTag() {
|
||||
super(getID());
|
||||
|
||||
Reference in New Issue
Block a user