fix tests for inspection view

This commit is contained in:
Dmitry Batkovich
2018-11-30 17:34:24 +03:00
parent f4aea63247
commit faf16298d5
5 changed files with 30 additions and 29 deletions
@@ -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");
}
@@ -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,
@@ -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;
}
@@ -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<RefEntity, CommonProblemDescriptor> 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
@@ -181,7 +181,7 @@ public class InspectionTreeModel extends BaseTreeModel<InspectionTreeNode> {
}
private synchronized <T extends InspectionTreeNode> T getOrAdd(Object userObject, Supplier<T> 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;