diff --git a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index d68b2a10970d..5a00b75a97f0 100644 --- a/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java @@ -343,11 +343,12 @@ public class UnusedDeclarationInspection extends FilteringInspectionTool { final RefElementImpl refElement = (RefElementImpl)refEntity; if (!refElement.isSuspicious()) return; - final PsiElement element = refElement.getElement(); - if (element == null) return; + PsiFile file = refElement.getContainingFile(); + + if (file == null) return; final boolean isSuppressed = refElement.isSuppressed(getShortName()); - if (!getContext().isToCheckMember(element, UnusedDeclarationInspection.this) || isSuppressed) { - if (isSuppressed || !scope.contains(element)) { + if (!getContext().isToCheckFile(file, UnusedDeclarationInspection.this) || isSuppressed) { + if (isSuppressed || !scope.contains(file)) { getEntryPointsManager().addEntryPoint(refElement, false); } return; diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java index 6f083ee1eff2..61633adec49c 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -71,7 +71,10 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; public class GlobalInspectionContextImpl extends UserDataHolderBase implements GlobalInspectionContext { private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.ex.GlobalInspectionContextImpl"); @@ -346,16 +349,15 @@ public class GlobalInspectionContextImpl extends UserDataHolderBase implements G public boolean isToCheckMember(@NotNull RefElement owner, InspectionProfileEntry tool) { - final PsiElement element = owner.getElement(); - return isToCheckMember(element, tool) && !((RefElementImpl)owner).isSuppressed(tool.getShortName()); + return isToCheckFile(((RefElementImpl)owner).getContainingFile(), tool) && !((RefElementImpl)owner).isSuppressed(tool.getShortName()); } - public boolean isToCheckMember(final PsiElement element, final InspectionProfileEntry tool) { + public boolean isToCheckFile(PsiFile file, final InspectionProfileEntry tool) { final Tools tools = myTools.get(tool.getShortName()); if (tools != null) { for (ScopeToolState state : tools.getTools()) { - final NamedScope namedScope = state.getScope(element.getProject()); - if (namedScope == null || namedScope.getValue().contains(element.getContainingFile(), getCurrentProfile().getProfileManager().getScopesManager())) { + final NamedScope namedScope = state.getScope(file.getProject()); + if (namedScope == null || namedScope.getValue().contains(file, getCurrentProfile().getProfileManager().getScopesManager())) { if (state.isEnabled()) { final InspectionProfileEntry entry = state.getTool(); if (entry instanceof InspectionToolWrapper && ((InspectionToolWrapper)entry).getTool() == tool) return true; diff --git a/plugins/properties/src/com/intellij/codeInspection/duplicatePropertyInspection/DuplicatePropertyInspection.java b/plugins/properties/src/com/intellij/codeInspection/duplicatePropertyInspection/DuplicatePropertyInspection.java index e46ee8da92c3..085a8a9f5e25 100644 --- a/plugins/properties/src/com/intellij/codeInspection/duplicatePropertyInspection/DuplicatePropertyInspection.java +++ b/plugins/properties/src/com/intellij/codeInspection/duplicatePropertyInspection/DuplicatePropertyInspection.java @@ -145,7 +145,7 @@ public class DuplicatePropertyInspection extends GlobalSimpleInspectionTool { private void checkFile(final PsiFile file, final InspectionManager manager, GlobalInspectionContextImpl context, final RefManager refManager, final ProblemDescriptionsProcessor processor) { if (!(file instanceof PropertiesFile)) return; - if (!context.isToCheckMember(file, this)) return; + if (!context.isToCheckFile(file, this)) return; final PsiSearchHelper searchHelper = PsiSearchHelper.SERVICE.getInstance(file.getProject()); final PropertiesFile propertiesFile = (PropertiesFile)file; final List properties = propertiesFile.getProperties();