diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/InspectionResultViewTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/InspectionResultViewTest.java index 9545ae1cd843..1cde63451a56 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/InspectionResultViewTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/InspectionResultViewTest.java @@ -41,14 +41,15 @@ public class InspectionResultViewTest extends LightJava9ModulesCodeInsightFixtur updateTree(view); TreeUtil.expandAll(view.getTree()); - PlatformTestUtil.assertTreeEqual(view.getTree(), "-" + getProject() + "\n" + + updateTree(view); + PlatformTestUtil.assertTreeEqual(view.getTree(), "-InspectionViewTree\n" + " -Java\n" + " -Code maturity\n" + - " -MarkedForRemoval\n" + + " -Usage of API marked for removal\n" + " -some.module\n" + " 'M2' is deprecated and marked for removal(LIKE_DEPRECATED)\n" + " -Declaration redundancy\n" + - " -Java9RedundantRequiresStatement\n" + + " -Redundant 'requires' statement in module-info\n" + " -some.module\n" + " Redundant directive 'requires M2'\n"); @@ -57,16 +58,17 @@ public class InspectionResultViewTest extends LightJava9ModulesCodeInsightFixtur updateTree(view); TreeUtil.expandAll(view.getTree()); - PlatformTestUtil.assertTreeEqual(view.getTree(), "-" + getProject() + "\n" + + updateTree(view); + PlatformTestUtil.assertTreeEqual(view.getTree(), "-InspectionViewTree\n" + " -Java\n" + " -Code maturity\n" + - " -MarkedForRemoval\n" + - " -Module: 'light_idea_test_case'\n" + + " -Usage of API marked for removal\n" + + " -light_idea_test_case\n" + " -some.module\n" + " 'M2' is deprecated and marked for removal(LIKE_DEPRECATED)\n" + " -Declaration redundancy\n" + - " -Java9RedundantRequiresStatement\n" + - " -Module: 'light_idea_test_case'\n" + + " -Redundant 'requires' statement in module-info\n" + + " -light_idea_test_case\n" + " -some.module\n" + " Redundant directive 'requires M2'\n"); } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java index 83ba4b415f84..abe8d7c76921 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionRVContentProvider.java @@ -272,7 +272,8 @@ public abstract class InspectionRVContentProvider { String packageName = entry.getKey(); Module module = container.getModule(context.getProject()); InspectionTreeNode moduleNode = module != null ? model.createModuleNode(module, parent) : null; - currentParent = model.createPackageNode(packageName, moduleNode == null ? parent : moduleNode); + InspectionTreeNode actualParent = moduleNode == null ? parent : moduleNode; + currentParent = packageName == null ? actualParent : model.createPackageNode(packageName, actualParent); } RefElementNode node = container.createNode(context.getPresentation(toolWrapper), model, diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionPackageNode.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionPackageNode.java index a4a3b15daedd..ccc9954d1d09 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionPackageNode.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionPackageNode.java @@ -17,13 +17,14 @@ package com.intellij.codeInspection.ui; import com.intellij.util.PlatformIcons; +import org.jetbrains.annotations.NotNull; import javax.swing.Icon; public class InspectionPackageNode extends InspectionTreeNode { private final String myPackageName; - public InspectionPackageNode(String packageName, InspectionTreeModel model) { + public InspectionPackageNode(@NotNull String packageName, InspectionTreeModel model) { super(model); myPackageName = packageName; } diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java index dcd41ef9d177..c7e5de7cb077 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTree.java @@ -59,17 +59,17 @@ import static com.intellij.codeInspection.CommonProblemDescriptor.DESCRIPTOR_COM public class InspectionTree extends Tree { private static final Logger LOG = Logger.getInstance(InspectionTree.class); - @NotNull private final GlobalInspectionContextImpl myContext; private final InspectionTreeModel myModel; private boolean myQueueUpdate; private final OccurenceNavigator myOccurenceNavigator = new MyOccurrenceNavigator(); + private final InspectionResultsView myView; public InspectionTree(@NotNull GlobalInspectionContextImpl context, @NotNull InspectionResultsView view) { + myView = view; myModel = new InspectionTreeModel(); setModel(new AsyncTreeModel(myModel, view)); - myContext = context; setCellRenderer(new InspectionTreeCellRenderer(view)); setRootVisible(false); @@ -78,10 +78,9 @@ public class InspectionTree extends Tree { if (!ApplicationManager.getApplication().isUnitTestMode()) { getSelectionModel().addTreeSelectionListener(e -> { if (isUnderQueueUpdate()) return; - InspectionResultsView view1 = getContext().getView(); - if (view1 != null && !view1.isDisposed()) { - view1.syncRightPanel(); - if (view1.isAutoScrollMode()) { + if (!myView.isDisposed()) { + myView.syncRightPanel(); + if (myView.isAutoScrollMode()) { OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(this), false); } } @@ -93,9 +92,8 @@ public class InspectionTree extends Tree { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { - InspectionResultsView view1 = getContext().getView(); - if (view1 != null && !view1.isDisposed()) { - OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(view1), false); + if (myView != null && !myView.isDisposed()) { + OpenSourceUtil.openSourcesFrom(DataManager.getInstance().getDataContext(myView), false); } } } @@ -115,9 +113,8 @@ public class InspectionTree extends Tree { EdtInvocationManager.getInstance().invokeLater(() -> { expandPath(new TreePath(myModel.getRoot())); SmartExpander.installOn(InspectionTree.this); - InspectionResultsView v = getContext().getView(); - if (v != null && !v.isDisposed()) { - v.syncRightPanel(); + if (myView != null && !myView.isDisposed()) { + myView.syncRightPanel(); } }); } @@ -162,10 +159,10 @@ public class InspectionTree extends Tree { public InspectionToolWrapper getSelectedToolWrapper(boolean allowDummy) { final TreePath[] paths = getSelectionPaths(); if (paths == null) { - InspectionProfileImpl profile = myContext.getView().getCurrentProfile(); + InspectionProfileImpl profile = myView.getCurrentProfile(); String singleToolName = profile.getSingleTool(); if (singleToolName != null) { - InspectionToolWrapper tool = profile.getInspectionTool(singleToolName, myContext.getProject()); + InspectionToolWrapper tool = profile.getInspectionTool(singleToolName, myView.getProject()); LOG.assertTrue(tool != null); return tool; } @@ -345,7 +342,7 @@ public class InspectionTree extends Tree { if (isSingleInspectionRun) { return parent; } - return myModel.createInspectionNode(toolWrapper, myContext.getCurrentProfile(), parent); + return myModel.createInspectionNode(toolWrapper, myView.getCurrentProfile(), parent); } @NotNull @@ -359,7 +356,7 @@ public class InspectionTree extends Tree { } InspectionTreeNode currentNode = groupedBySeverity - ? myModel.createSeverityGroupNode(myContext.getCurrentProfile().getProfileManager().getSeverityRegistrar(), + ? myModel.createSeverityGroupNode(myView.getCurrentProfile().getProfileManager().getSeverityRegistrar(), errorLevel, myModel.getRoot()) : myModel.getRoot(); @@ -496,7 +493,7 @@ public class InspectionTree extends Tree { return node.getChildren().stream().allMatch(this::shouldDelete); } else if (node instanceof InspectionNode) { - InspectionToolPresentation presentation = myContext.getPresentation(((InspectionNode)node).getToolWrapper()); + InspectionToolPresentation presentation = myView.getGlobalInspectionContext().getPresentation(((InspectionNode)node).getToolWrapper()); SynchronizedBidiMultiMap problemElements = presentation.getProblemElements(); if (problemElements.isEmpty()) { return true; @@ -508,7 +505,7 @@ public class InspectionTree extends Tree { @NotNull public GlobalInspectionContextImpl getContext() { - return myContext; + return myView.getGlobalInspectionContext(); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeModel.java b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeModel.java index 62e141d6f8fb..c822f1be8609 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeModel.java +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/InspectionTreeModel.java @@ -181,7 +181,7 @@ public class InspectionTreeModel extends BaseTreeModel { } private synchronized T getOrAdd(Object userObject, Supplier supplier, InspectionTreeNode parent) { - LOG.assertTrue(!ApplicationManager.getApplication().isDispatchThread()); + LOG.assertTrue(ApplicationManager.getApplication().isUnitTestMode() || !ApplicationManager.getApplication().isDispatchThread()); Children children = myChildren.computeIfAbsent(parent, __ -> new Children()); if (userObject == null) { userObject = ObjectUtils.NULL;