diff options
author | Tor Norbye <tnorbye@google.com> | 2013-05-08 15:46:07 -0700 |
---|---|---|
committer | Tor Norbye <tnorbye@google.com> | 2013-05-08 15:46:07 -0700 |
commit | a6eac331b3d9f0d4168b12356ea256c83f4e9c05 (patch) | |
tree | 923ceb497c43ea183351321bb4b9e388851a7854 /xml/openapi/src/com/intellij | |
parent | 934b9431b0b827a132df794e307fe5a2b70de00b (diff) | |
download | idea-a6eac331b3d9f0d4168b12356ea256c83f4e9c05.tar.gz |
Snapshot f5ae6e3be7e12e1ef9e12f48fe3a674266288e4e from master branch of git://git.jetbrains.org/idea/community.git
Change-Id: I756af70fb2910aa2687e94e28338fb9727bce518
Diffstat (limited to 'xml/openapi/src/com/intellij')
-rw-r--r-- | xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java | 60 |
1 files changed, 31 insertions, 29 deletions
diff --git a/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java b/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java index 59fbf53aa173..5292a1ac6af1 100644 --- a/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java +++ b/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java @@ -16,22 +16,22 @@ package com.intellij.codeInspection; -import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.xml.XmlFile; import com.intellij.psi.xml.XmlTag; -import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool implements CustomSuppressableInspectionTool { +public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool implements BatchSuppressableTool { @NonNls static final String ALL = "ALL"; + @NotNull @Override - public SuppressIntentionAction[] getSuppressActions(final PsiElement element) { - return new SuppressIntentionAction[]{new SuppressTag(), new SuppressForFile(getID()), new SuppressAllForFile()}; + public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) { + return new SuppressQuickFix[]{new SuppressTag(), new SuppressForFile(getID()), new SuppressAllForFile()}; } @Override @@ -40,81 +40,83 @@ public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool } public class SuppressTag extends SuppressTagStatic { - public SuppressTag() { super(getID()); } } - public static class SuppressTagStatic extends SuppressIntentionAction { + public static class SuppressTagStatic implements SuppressQuickFix { private final String id; public SuppressTagStatic(@NotNull String id) { this.id = id; } - @Override @NotNull - public String getText() { + @Override + public String getName() { return InspectionsBundle.message("xml.suppressable.for.tag.title"); } @Override - @NotNull - public String getFamilyName() { - return getText(); + public boolean isAvailable(@NotNull Project project, @NotNull PsiElement context) { + return context.isValid(); } @Override - public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) { - return PsiTreeUtil.getParentOfType(element, XmlTag.class) != null; + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { + PsiElement element = descriptor.getPsiElement(); + if (PsiTreeUtil.getParentOfType(element, XmlTag.class) == null) return; + XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForTag(element, id); } @Override - public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { - XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForTag(element, id); + @NotNull + public String getFamilyName() { + return getName(); } } - public static class SuppressForFile extends SuppressIntentionAction { + public static class SuppressForFile implements SuppressQuickFix { private final String myInspectionId; public SuppressForFile(@NotNull String inspectionId) { myInspectionId = inspectionId; } - @Override @NotNull - public String getText() { + @Override + public String getName() { return InspectionsBundle.message("xml.suppressable.for.file.title"); } @Override - @NotNull - public String getFamilyName() { - return getText(); + public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { + PsiElement element = descriptor.getPsiElement(); + if (element == null || !element.isValid() || !(element.getContainingFile() instanceof XmlFile)) return; + XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForFile(element, myInspectionId); } @Override - public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException { - XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForFile(element, myInspectionId); + public boolean isAvailable(@NotNull Project project, @NotNull PsiElement context) { + return context.isValid(); } @Override - public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) { - return element.isValid() && element.getContainingFile() instanceof XmlFile; + @NotNull + public String getFamilyName() { + return getName(); } } public static class SuppressAllForFile extends SuppressForFile { - public SuppressAllForFile() { super(ALL); } - @Override @NotNull - public String getText() { + @Override + public String getName() { return InspectionsBundle.message("xml.suppressable.all.for.file.title"); } } |