use of com.intellij.codeInspection.ui.InspectionTree in project intellij-community by JetBrains.
the class QuickFixAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final InspectionResultsView view = getInvoker(e);
final InspectionTree tree = view.getTree();
try {
Ref<CommonProblemDescriptor[]> descriptors = Ref.create();
Set<VirtualFile> readOnlyFiles = new THashSet<>();
if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> ReadAction.run(() -> {
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
indicator.setText("Checking problem descriptors...");
descriptors.set(tree.getSelectedDescriptors(true, readOnlyFiles, false, false));
}), InspectionsBundle.message("preparing.for.apply.fix"), true, e.getProject())) {
return;
}
if (isProblemDescriptorsAcceptable() && descriptors.get().length > 0) {
doApplyFix(view.getProject(), descriptors.get(), readOnlyFiles, tree.getContext());
} else {
doApplyFix(getSelectedElements(view), view);
}
} finally {
view.setApplyingFix(false);
}
}
use of com.intellij.codeInspection.ui.InspectionTree in project intellij-community by JetBrains.
the class QuickFixAction method update.
@Override
public void update(AnActionEvent e) {
final InspectionResultsView view = getInvoker(e);
if (view == null) {
e.getPresentation().setEnabled(false);
return;
}
e.getPresentation().setVisible(false);
e.getPresentation().setEnabled(false);
final InspectionTree tree = view.getTree();
final InspectionToolWrapper toolWrapper = tree.getSelectedToolWrapper(true);
if (!view.isSingleToolInSelection() || toolWrapper != myToolWrapper) {
return;
}
if (!isProblemDescriptorsAcceptable() && tree.getSelectedElements().length > 0 || isProblemDescriptorsAcceptable() && tree.getSelectedDescriptors().length > 0) {
e.getPresentation().setVisible(true);
e.getPresentation().setEnabled(true);
}
}
use of com.intellij.codeInspection.ui.InspectionTree in project intellij-community by JetBrains.
the class OfflineInspectionResultViewTest method testOfflineView.
public void testOfflineView() throws Exception {
myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = true;
InspectionTree tree = updateTree();
TreeUtil.expandAll(tree);
PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n" + " -Declaration redundancy\n" + " -" + myUnusedToolWrapper + "\n" + " -" + getModule() + "\n" + " -<default>\n" + " -Test\n" + " -foo()\n" + " " + varMessage() + "\n" + " -main(String[])\n" + " " + varMessage() + "\n" + " -f()\n" + " -D\n" + " -b()\n" + " " + varMessage() + "\n" + " -anonymous (java.lang.Runnable)\n" + " -run()\n" + " " + varMessage() + "\n" + " -ff()\n" + " " + varMessage() + "\n" + " " + varMessage() + "\n" + " -Probable bugs\n" + " -" + myDataFlowToolWrapper + "\n" + " -Module: 'testOfflineView'\n" + " -<default>\n" + " -Test\n" + " -m()\n" + " 'equals()' called on itself\n" + " -Test2\n" + " -m123()\n" + " 'equals()' called on itself\n");
myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = false;
tree = updateTree();
PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n" + " -Declaration redundancy\n" + " -" + myUnusedToolWrapper + "\n" + " -Test\n" + " -foo()\n" + " " + varMessage() + "\n" + " -main(String[])\n" + " " + varMessage() + "\n" + " -f()\n" + " -D\n" + " -b()\n" + " " + varMessage() + "\n" + " -anonymous (java.lang.Runnable)\n" + " -run()\n" + " " + varMessage() + "\n" + " -ff()\n" + " " + varMessage() + "\n" + " " + varMessage() + "\n" + " -Probable bugs\n" + " -" + myDataFlowToolWrapper + "\n" + " -Test\n" + " 'equals()' called on itself\n" + " -Test2\n" + " 'equals()' called on itself\n");
TreeUtil.selectNode(tree, tree.getRoot());
final InspectionTreeNode root = tree.getRoot();
root.excludeElement(myView.getExcludedManager());
TreeUtil.traverse(root, node -> {
assertTrue(((InspectionTreeNode) node).isExcluded(myView.getExcludedManager()));
return true;
});
myView.getGlobalInspectionContext().getUIOptions().FILTER_RESOLVED_ITEMS = true;
tree = updateTree();
PlatformTestUtil.assertTreeEqual(tree, getProject() + "\n");
myView.getGlobalInspectionContext().getUIOptions().FILTER_RESOLVED_ITEMS = false;
tree = updateTree();
PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n" + " -Declaration redundancy\n" + " -" + myUnusedToolWrapper + "\n" + " -Test\n" + " -foo()\n" + " " + varMessage() + "\n" + " -main(String[])\n" + " " + varMessage() + "\n" + " -f()\n" + " -D\n" + " -b()\n" + " " + varMessage() + "\n" + " -anonymous (java.lang.Runnable)\n" + " -run()\n" + " " + varMessage() + "\n" + " -ff()\n" + " " + varMessage() + "\n" + " " + varMessage() + "\n" + " -Probable bugs\n" + " -" + myDataFlowToolWrapper + "\n" + " -Test\n" + " 'equals()' called on itself\n" + " -Test2\n" + " 'equals()' called on itself\n");
}
use of com.intellij.codeInspection.ui.InspectionTree in project intellij-community by JetBrains.
the class OfflineInspectionResultViewTest method testOfflineWithInvalid.
public void testOfflineWithInvalid() throws Exception {
ApplicationManager.getApplication().runWriteAction(() -> getJavaFacade().findClass("Test2").getContainingFile().delete());
myView.getGlobalInspectionContext().getUIOptions().SHOW_STRUCTURE = true;
InspectionTree tree = updateTree();
TreeUtil.expandAll(tree);
PlatformTestUtil.assertTreeEqual(tree, "-" + getProject() + "\n" + " -Declaration redundancy\n" + " -" + myUnusedToolWrapper + "\n" + " -" + getModule() + "\n" + " -<default>\n" + " -Test\n" + " -foo()\n" + " " + varMessage() + "\n" + " -main(String[])\n" + " " + varMessage() + "\n" + " -f()\n" + " -D\n" + " -b()\n" + " " + varMessage() + "\n" + " -anonymous (java.lang.Runnable)\n" + " -run()\n" + " " + varMessage() + "\n" + " -ff()\n" + " " + varMessage() + "\n" + " " + varMessage() + "\n" + " -Probable bugs\n" + " -" + myDataFlowToolWrapper + "\n" + " -Module: 'testOfflineWithInvalid'\n" + " -<default>\n" + " -Test\n" + " -m()\n" + " 'equals()' called on itself\n" + " -null\n" + " Identical qualifier and argument to <code>equals()</code> call\n");
tree.setSelectionRow(27);
final OfflineProblemDescriptorNode node = (OfflineProblemDescriptorNode) tree.getSelectionModel().getSelectionPath().getLastPathComponent();
assertFalse(node.isValid());
}
use of com.intellij.codeInspection.ui.InspectionTree in project intellij-community by JetBrains.
the class OfflineInspectionResultViewTest method updateTree.
private InspectionTree updateTree() {
myView.update();
final InspectionTree tree = myView.getTree();
TreeUtil.expandAll(tree);
return tree;
}
Aggregations