Search in sources :

Example 1 with IssueNode

use of org.sonarlint.intellij.ui.nodes.IssueNode in project sonarlint-intellij by SonarSource.

the class IssueTree method navigate.

@CheckForNull
private OpenFileDescriptor navigate() {
    DefaultMutableTreeNode node = getSelectedNode();
    if (!(node instanceof IssueNode)) {
        return null;
    }
    LiveIssue issue = ((IssueNode) node).issue();
    if (!issue.isValid()) {
        return null;
    }
    int offset;
    RangeMarker range = issue.getRange();
    if (range != null) {
        offset = range.getStartOffset();
    } else {
        offset = 0;
    }
    return new OpenFileDescriptor(project, issue.psiFile().getVirtualFile(), offset);
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) IssueNode(org.sonarlint.intellij.ui.nodes.IssueNode) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) RangeMarker(com.intellij.openapi.editor.RangeMarker) CheckForNull(javax.annotation.CheckForNull)

Example 2 with IssueNode

use of org.sonarlint.intellij.ui.nodes.IssueNode in project sonarlint-intellij by SonarSource.

the class IssueTreeModelBuilder method setIssues.

private static void setIssues(FileNode node, Iterable<LiveIssue> issuePointers) {
    node.removeAllChildren();
    // 15ms for 500 issues -> to improve?
    TreeSet<LiveIssue> set = new TreeSet<>(ISSUE_COMPARATOR);
    for (LiveIssue issue : issuePointers) {
        set.add(issue);
    }
    for (LiveIssue issue : set) {
        IssueNode iNode = new IssueNode(issue);
        node.add(iNode);
    }
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) TreeSet(java.util.TreeSet) IssueNode(org.sonarlint.intellij.ui.nodes.IssueNode)

Example 3 with IssueNode

use of org.sonarlint.intellij.ui.nodes.IssueNode in project sonarlint-intellij by SonarSource.

the class AbstractIssuesPanel method hasPreviousOccurence.

@Override
public boolean hasPreviousOccurence() {
    TreePath path = tree.getSelectionPath();
    if (path == null) {
        return false;
    }
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    return (node instanceof IssueNode) && !isFirst(node);
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) IssueNode(org.sonarlint.intellij.ui.nodes.IssueNode)

Example 4 with IssueNode

use of org.sonarlint.intellij.ui.nodes.IssueNode in project sonarlint-intellij by SonarSource.

the class AbstractIssuesPanel method hasNextOccurence.

@Override
public boolean hasNextOccurence() {
    // relies on the assumption that a TreeNodes will always be the last row in the table view of the tree
    TreePath path = tree.getSelectionPath();
    if (path == null) {
        return false;
    }
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
    if (node instanceof IssueNode) {
        return tree.getRowCount() != tree.getRowForPath(path) + 1;
    } else {
        return node.getChildCount() > 0;
    }
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) IssueNode(org.sonarlint.intellij.ui.nodes.IssueNode)

Example 5 with IssueNode

use of org.sonarlint.intellij.ui.nodes.IssueNode in project sonarlint-intellij by SonarSource.

the class AbstractIssuesPanel method issueTreeSelectionChanged.

protected void issueTreeSelectionChanged() {
    IssueNode[] selectedNodes = tree.getSelectedNodes(IssueNode.class, null);
    if (selectedNodes.length > 0) {
        LiveIssue issue = selectedNodes[0].issue();
        rulePanel.setRuleKey(issue);
        if (issue.getRange() != null) {
            highlighting.highlightFlowsWithHighlightersUtil(issue.getRange(), issue.getMessage(), issue.flows());
        }
        flowsTree.getEmptyText().setText("Selected issue doesn't have flows");
        flowsTreeBuilder.setFlows(issue.flows(), issue.getRange(), issue.getMessage());
        flowsTree.expandAll();
    } else {
        flowsTreeBuilder.clearFlows();
        flowsTree.getEmptyText().setText("No issue selected");
        rulePanel.setRuleKey(null);
        highlighting.removeHighlightingFlows();
    }
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) IssueNode(org.sonarlint.intellij.ui.nodes.IssueNode)

Aggregations

IssueNode (org.sonarlint.intellij.ui.nodes.IssueNode)6 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 LiveIssue (org.sonarlint.intellij.issue.LiveIssue)3 TreePath (javax.swing.tree.TreePath)2 RangeMarker (com.intellij.openapi.editor.RangeMarker)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 CheckForNull (javax.annotation.CheckForNull)1 Test (org.junit.Test)1