From ac288174ce44e2940801370dcd5b441a03370264 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 13 Oct 2014 13:42:01 +0400 Subject: [PATCH] notnull --- .../codeInspection/BatchSuppressManager.java | 12 ++--- .../impl/RemoveSuppressWarningAction.java | 12 +++-- .../BatchSuppressManagerImpl.java | 12 ++--- .../codeInspection/JavaSuppressionUtil.java | 8 ++-- .../codeInspection/SuppressManagerImpl.java | 10 ++-- .../scope/JavaCompletionProcessor.java | 4 +- .../ex/JavaInspectionExtensionsFactory.java | 6 +-- .../GlobalInspectionContext.java | 4 +- .../InspectionProfileEntry.java | 48 ++++++++++--------- .../codeInspection/InspectionSuppressor.java | 2 +- .../codeInspection/LocalInspectionTool.java | 3 +- .../lang/InspectionExtensionsFactory.java | 6 +-- .../codeInspection/InspectionEngine.java | 1 + .../codeInspection/SuppressionUtil.java | 30 ++++++------ .../ex/GlobalInspectionContextBase.java | 2 +- .../reference/RefElementImpl.java | 4 +- ...olsSettingsInSuppressedPlaceIntention.java | 5 +- .../GroovySuppressableInspectionTool.java | 4 +- .../GrUnresolvedAccessInspection.java | 2 +- .../python/inspections/PyInspection.java | 9 ++-- .../XmlInspectionSuppressor.java | 2 +- .../XmlSuppressionProvider.java | 1 + 22 files changed, 99 insertions(+), 88 deletions(-) diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/BatchSuppressManager.java b/java/java-analysis-api/src/com/intellij/codeInspection/BatchSuppressManager.java index 6a5d840246d3..467b392b9dba 100644 --- a/java/java-analysis-api/src/com/intellij/codeInspection/BatchSuppressManager.java +++ b/java/java-analysis-api/src/com/intellij/codeInspection/BatchSuppressManager.java @@ -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 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); diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RemoveSuppressWarningAction.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RemoveSuppressWarningAction.java index 867f165b61ac..c3b8ecfdcddf 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RemoveSuppressWarningAction.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/RemoveSuppressWarningAction.java @@ -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); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/BatchSuppressManagerImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/BatchSuppressManagerImpl.java index d2a2675a096e..5b6585fab2f8 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/BatchSuppressManagerImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/BatchSuppressManagerImpl.java @@ -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); } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/JavaSuppressionUtil.java b/java/java-analysis-impl/src/com/intellij/codeInspection/JavaSuppressionUtil.java index 1751468084dd..9c643b81124f 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/JavaSuppressionUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/JavaSuppressionUtil.java @@ -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() { @Override diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java index 5a143ffd1a36..015808fb9d4b 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java @@ -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); } diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java b/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java index 2523a5233e34..bb9d86e7fb32 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/scope/JavaCompletionProcessor.java @@ -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); } diff --git a/java/java-impl/src/com/intellij/codeInspection/ex/JavaInspectionExtensionsFactory.java b/java/java-impl/src/com/intellij/codeInspection/ex/JavaInspectionExtensionsFactory.java index d5f607ec819f..9952ee504539 100644 --- a/java/java-impl/src/com/intellij/codeInspection/ex/JavaInspectionExtensionsFactory.java +++ b/java/java-impl/src/com/intellij/codeInspection/ex/JavaInspectionExtensionsFactory.java @@ -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); } diff --git a/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionContext.java b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionContext.java index 4c20b76dd531..768c96f346ad 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionContext.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/GlobalInspectionContext.java @@ -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(); diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java index 3ff996a6e126..af1e65c67598 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java @@ -70,14 +70,16 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool{ @Override public boolean isSuppressedFor(@NotNull PsiElement element) { Set 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 fixes = new THashSet(new TObjectHashingStrategy() { - @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 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 fixes = new THashSet(new TObjectHashingStrategy() { + @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 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; } diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionSuppressor.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionSuppressor.java index d6ce2f4aff4a..4312c29ce905 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionSuppressor.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionSuppressor.java @@ -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) diff --git a/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java b/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java index b4cba852eba2..5405fa66f9e7 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/LocalInspectionTool.java @@ -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(); diff --git a/platform/analysis-api/src/com/intellij/codeInspection/lang/InspectionExtensionsFactory.java b/platform/analysis-api/src/com/intellij/codeInspection/lang/InspectionExtensionsFactory.java index fc7f9c328920..7ed83ea24d56 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/lang/InspectionExtensionsFactory.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/lang/InspectionExtensionsFactory.java @@ -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); diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/InspectionEngine.java b/platform/analysis-impl/src/com/intellij/codeInspection/InspectionEngine.java index d8f019a7327e..3c3260de600b 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/InspectionEngine.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/InspectionEngine.java @@ -100,6 +100,7 @@ public class InspectionEngine { } // public accessibility for Upsource + // returns map (toolName -> problem descriptors) @NotNull public static Map> inspectEx(@NotNull final List toolWrappers, @NotNull final PsiFile file, diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java b/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java index 4f1de6622a1f..d85f369e8b9a 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java @@ -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 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 statementClass) { + public static PsiElement getStatementToolSuppressedIn(@NotNull PsiElement place, + @NotNull String toolId, + @NotNull Class statementClass) { return getStatementToolSuppressedIn(place, toolId, statementClass, SUPPRESS_IN_LINE_COMMENT_PATTERN); } @Nullable - public static PsiElement getStatementToolSuppressedIn(final PsiElement place, - final String toolId, - final Class statementClass, - final Pattern suppressInLineCommentPattern) { + public static PsiElement getStatementToolSuppressedIn(@NotNull PsiElement place, + @NotNull String toolId, + @NotNull Class 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 statementClass) { + public static boolean isSuppressedInStatement(@NotNull final PsiElement place, + @NotNull final String toolId, + @NotNull final Class statementClass) { return ApplicationManager.getApplication().runReadAction(new NullableComputable() { @Override public PsiElement compute() { @@ -116,7 +116,7 @@ public class SuppressionUtil extends SuppressionUtilCore { } @Nullable - public static Couple getBlockPrefixSuffixPair(PsiElement comment) { + public static Couple 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; diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java index 4f47f39466c5..7f4f3e079f7e 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextBase.java @@ -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); diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java index 7e1cee27d1da..619ee155b175 100644 --- a/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java +++ b/platform/analysis-impl/src/com/intellij/codeInspection/reference/RefElementImpl.java @@ -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) { diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsInSuppressedPlaceIntention.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsInSuppressedPlaceIntention.java index 70e452b8a546..c4760e2af40f 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsInSuppressedPlaceIntention.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/EditInspectionToolsSettingsInSuppressedPlaceIntention.java @@ -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(); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/GroovySuppressableInspectionTool.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/GroovySuppressableInspectionTool.java index 3b1dbdd3914d..c9e6da5f1cfd 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/GroovySuppressableInspectionTool.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/GroovySuppressableInspectionTool.java @@ -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(); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java index 5b774b4168e1..feeac4b3fab2 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/codeInspection/untypedUnresolvedAccess/GrUnresolvedAccessInspection.java @@ -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); } diff --git a/python/src/com/jetbrains/python/inspections/PyInspection.java b/python/src/com/jetbrains/python/inspections/PyInspection.java index a35e2c774b05..993dcdcb22f3 100644 --- a/python/src/com/jetbrains/python/inspections/PyInspection.java +++ b/python/src/com/jetbrains/python/inspections/PyInspection.java @@ -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", ""); } diff --git a/xml/xml-psi-api/src/com/intellij/codeInspection/XmlInspectionSuppressor.java b/xml/xml-psi-api/src/com/intellij/codeInspection/XmlInspectionSuppressor.java index c0cc1e7c8d12..9cbc72604e11 100644 --- a/xml/xml-psi-api/src/com/intellij/codeInspection/XmlInspectionSuppressor.java +++ b/xml/xml-psi-api/src/com/intellij/codeInspection/XmlInspectionSuppressor.java @@ -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); } diff --git a/xml/xml-psi-api/src/com/intellij/codeInspection/XmlSuppressionProvider.java b/xml/xml-psi-api/src/com/intellij/codeInspection/XmlSuppressionProvider.java index 00e2268b803b..527187345d14 100644 --- a/xml/xml-psi-api/src/com/intellij/codeInspection/XmlSuppressionProvider.java +++ b/xml/xml-psi-api/src/com/intellij/codeInspection/XmlSuppressionProvider.java @@ -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);