Search in sources :

Example 1 with InspectionTree

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);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) InspectionResultsView(com.intellij.codeInspection.ui.InspectionResultsView) THashSet(gnu.trove.THashSet) InspectionTree(com.intellij.codeInspection.ui.InspectionTree)

Example 2 with InspectionTree

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);
    }
}
Also used : InspectionResultsView(com.intellij.codeInspection.ui.InspectionResultsView) InspectionTree(com.intellij.codeInspection.ui.InspectionTree)

Example 3 with InspectionTree

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");
}
Also used : InspectionTree(com.intellij.codeInspection.ui.InspectionTree) InspectionTreeNode(com.intellij.codeInspection.ui.InspectionTreeNode)

Example 4 with InspectionTree

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());
}
Also used : OfflineProblemDescriptorNode(com.intellij.codeInspection.offlineViewer.OfflineProblemDescriptorNode) InspectionTree(com.intellij.codeInspection.ui.InspectionTree)

Example 5 with InspectionTree

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;
}
Also used : InspectionTree(com.intellij.codeInspection.ui.InspectionTree)

Aggregations

InspectionTree (com.intellij.codeInspection.ui.InspectionTree)6 InspectionResultsView (com.intellij.codeInspection.ui.InspectionResultsView)2 OfflineProblemDescriptorNode (com.intellij.codeInspection.offlineViewer.OfflineProblemDescriptorNode)1 InspectionTreeNode (com.intellij.codeInspection.ui.InspectionTreeNode)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 THashSet (gnu.trove.THashSet)1 Assert.assertNotNull (junit.framework.Assert.assertNotNull)1 NotNull (org.jetbrains.annotations.NotNull)1