Search in sources :

Example 1 with InspectionTreeNode

use of com.intellij.codeInspection.ui.InspectionTreeNode 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 2 with InspectionTreeNode

use of com.intellij.codeInspection.ui.InspectionTreeNode in project intellij-community by JetBrains.

the class InspectionsFixture method describe.

public static void describe(@NotNull InspectionTreeNode node, @NotNull StringBuilder sb, int depth) {
    for (int i = 0; i < depth; i++) {
        sb.append("    ");
    }
    sb.append(node.toString());
    sb.append("\n");
    // The exact order of the results sometimes varies so sort the children alphabetically
    // instead to ensure stable test output
    List<InspectionTreeNode> children = new ArrayList<>(node.getChildCount());
    for (int i = 0, n = node.getChildCount(); i < n; i++) {
        children.add((InspectionTreeNode) node.getChildAt(i));
    }
    Collections.sort(children, new Comparator<InspectionTreeNode>() {

        @Override
        public int compare(InspectionTreeNode node1, InspectionTreeNode node2) {
            return node1.toString().compareTo(node2.toString());
        }
    });
    for (InspectionTreeNode child : children) {
        describe(child, sb, depth + 1);
    }
}
Also used : ArrayList(java.util.ArrayList) InspectionTreeNode(com.intellij.codeInspection.ui.InspectionTreeNode)

Example 3 with InspectionTreeNode

use of com.intellij.codeInspection.ui.InspectionTreeNode in project android by JetBrains.

the class InspectionsFixture method describe.

private static void describe(@NotNull InspectionTreeNode node, @NotNull StringBuilder sb, int depth) {
    for (int i = 0; i < depth; i++) {
        sb.append("    ");
    }
    sb.append(node.toString());
    sb.append("\n");
    // The exact order of the results sometimes varies so sort the children alphabetically
    // instead to ensure stable test output
    List<InspectionTreeNode> children = Lists.newArrayListWithExpectedSize(node.getChildCount());
    for (int i = 0, n = node.getChildCount(); i < n; i++) {
        children.add((InspectionTreeNode) node.getChildAt(i));
    }
    Collections.sort(children, (node1, node2) -> node1.toString().compareTo(node2.toString()));
    for (InspectionTreeNode child : children) {
        describe(child, sb, depth + 1);
    }
}
Also used : InspectionTreeNode(com.intellij.codeInspection.ui.InspectionTreeNode)

Aggregations

InspectionTreeNode (com.intellij.codeInspection.ui.InspectionTreeNode)3 InspectionTree (com.intellij.codeInspection.ui.InspectionTree)1 ArrayList (java.util.ArrayList)1