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 8f989c674963..935ef03fefd6 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -598,7 +598,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp LOG.assertTrue(!ApplicationManager.getApplication().isReadAccessAllowed() || isOfflineInspections, "Must not run under read action, too unresponsive"); final List needRepeatSearchRequest = new ArrayList(); - final boolean canBeExternalUsages = scope.getScopeType() != AnalysisScope.PROJECT; + final boolean canBeExternalUsages = !(scope.getScopeType() == AnalysisScope.PROJECT && scope.isIncludeTestSource()); for (Tools tools : globalTools) { for (ScopeToolState state : tools.getTools()) { final InspectionToolWrapper toolWrapper = state.getTool(); @@ -618,8 +618,8 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp @Override public void run() { tool.runInspection(scope, inspectionManager, GlobalInspectionContextImpl.this, toolPresentation); - //skip phase when we are sure that scope already contains everything - if (canBeExternalUsages && + //skip phase when we are sure that scope already contains everything, unused declaration though needs to proceed with its suspicious code + if ((canBeExternalUsages || tool.getAdditionalJobs() != null) && tool.queryExternalUsagesRequests(inspectionManager, GlobalInspectionContextImpl.this, toolPresentation)) { needRepeatSearchRequest.add(toolWrapper); }