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 c0c58ae6e6b7..bfa47595a2ef 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/GlobalInspectionContextImpl.java @@ -356,8 +356,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp final InspectionResultsView view; if (myView == null) { - view = new InspectionResultsView(GlobalInspectionContextImpl.this, - new InspectionRVContentProviderImpl(getProject())); + view = new InspectionResultsView(GlobalInspectionContextImpl.this, createContentProvider()); } else { view = null; } @@ -682,9 +681,12 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp } } if (!ApplicationManager.getApplication().isUnitTestMode()) { - final InspectionResultsView view = createViewIfNeed(); - if (!view.isDisposed()) { - ReadAction.run(() -> view.addTools(globalTools)); + if (myView == null && !InspectionResultsView.hasProblems(globalTools, this, createContentProvider())) { + return; + } + createViewIfNeed(); + if (!myView.isDisposed()) { + ReadAction.run(() -> myView.addTools(globalTools)); } } } @@ -698,7 +700,7 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp if (newView != null) { return newView; } - newView = new InspectionResultsView(this, new InspectionRVContentProviderImpl(getProject())); + newView = new InspectionResultsView(this, createContentProvider()); addView(newView); return newView; }); @@ -1037,4 +1039,8 @@ public class GlobalInspectionContextImpl extends GlobalInspectionContextBase imp public boolean isSingleInspectionRun() { return mySingleInspectionRun; } + + private InspectionRVContentProvider createContentProvider() { + return new InspectionRVContentProviderImpl(getProject()); + } } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java index 2d4946c42c8c..a92c32acb775 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionResultsView.java @@ -993,11 +993,16 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren } public boolean hasProblems() { - final Map tools = myGlobalInspectionContext.getTools(); - for (Tools currentTools : tools.values()) { - for (ScopeToolState state : myProvider.getTools(currentTools)) { + return hasProblems(myGlobalInspectionContext.getTools().values(), myGlobalInspectionContext, myProvider); + } + + public static boolean hasProblems(@NotNull Collection tools, + @NotNull GlobalInspectionContextImpl context, + @NotNull InspectionRVContentProvider contentProvider) { + for (Tools currentTools : tools) { + for (ScopeToolState state : contentProvider.getTools(currentTools)) { InspectionToolWrapper toolWrapper = state.getTool(); - if (myProvider.checkReportedProblems(myGlobalInspectionContext, toolWrapper)) { + if (contentProvider.checkReportedProblems(context, toolWrapper)) { return true; } } @@ -1079,8 +1084,8 @@ public class InspectionResultsView extends JPanel implements Disposable, Occuren myRerun = true; if (myScope.isValid()) { AnalysisUIOptions.getInstance(myProject).save(myGlobalInspectionContext.getUIOptions()); - myGlobalInspectionContext.doInspections(myScope); myGlobalInspectionContext.setTreeState(getTree().getTreeState()); + myGlobalInspectionContext.doInspections(myScope); } } }