Search in sources :

Example 1 with FileNode

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

the class AbstractNodeTest method testInsertion.

@Test
public void testInsertion() {
    assertThat(testNode.getInsertIdx(new FileNode(mockFile("name")), nameComparator)).isEqualTo(0);
    assertThat(testNode.getInsertIdx(new FileNode(mockFile("file")), nameComparator)).isEqualTo(0);
    assertThat(testNode.getInsertIdx(new FileNode(mockFile("test")), nameComparator)).isEqualTo(2);
    assertThat(testNode.getInsertIdx(new FileNode(mockFile("abc")), nameComparator)).isEqualTo(0);
    assertThat(testNode.getChildCount()).isEqualTo(4);
    assertThat(((FileNode) testNode.getChildAt(0)).file().getName()).isEqualTo("abc");
    assertThat(((FileNode) testNode.getChildAt(1)).file().getName()).isEqualTo("file");
    assertThat(((FileNode) testNode.getChildAt(2)).file().getName()).isEqualTo("name");
    assertThat(((FileNode) testNode.getChildAt(3)).file().getName()).isEqualTo("test");
}
Also used : FileNode(org.sonarlint.intellij.ui.nodes.FileNode) Test(org.junit.Test)

Example 2 with FileNode

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

the class IssueTree method getSelectedFile.

@CheckForNull
private VirtualFile getSelectedFile() {
    DefaultMutableTreeNode node = getSelectedNode();
    if (!(node instanceof FileNode)) {
        return null;
    }
    FileNode fileNode = (FileNode) node;
    return fileNode.file();
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) FileNode(org.sonarlint.intellij.ui.nodes.FileNode) CheckForNull(javax.annotation.CheckForNull)

Example 3 with FileNode

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

the class IssueTreeIndexTest method setUp.

@Before
public void setUp() {
    idx = new IssueTreeIndex();
    file1 = createFile("file1");
    file2 = createFile("file1");
    node1 = new FileNode(file1);
    node2 = new FileNode(file2);
}
Also used : FileNode(org.sonarlint.intellij.ui.nodes.FileNode) Before(org.junit.Before)

Example 4 with FileNode

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

the class IssueTreeModelBuilder method setFileIssues.

private void setFileIssues(VirtualFile file, Iterable<LiveIssue> issues) {
    if (!accept(file)) {
        removeFile(file);
        return;
    }
    List<LiveIssue> filtered = filter(issues);
    if (filtered.isEmpty()) {
        removeFile(file);
        return;
    }
    boolean newFile = false;
    FileNode fNode = index.getFileNode(file);
    if (fNode == null) {
        newFile = true;
        fNode = new FileNode(file);
        index.setFileNode(fNode);
    }
    setIssues(fNode, filtered);
    if (newFile) {
        AbstractNode parent = getFilesParent();
        int idx = parent.getInsertIdx(fNode, new FileNodeComparator());
        int[] newIdx = { idx };
        model.nodesWereInserted(parent, newIdx);
        model.nodeChanged(parent);
    } else {
        model.nodeStructureChanged(fNode);
    }
}
Also used : LiveIssue(org.sonarlint.intellij.issue.LiveIssue) AbstractNode(org.sonarlint.intellij.ui.nodes.AbstractNode) FileNode(org.sonarlint.intellij.ui.nodes.FileNode)

Example 5 with FileNode

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

the class IssueTreeModelBuilder method removeFile.

private void removeFile(VirtualFile file) {
    FileNode node = index.getFileNode(file);
    if (node != null) {
        index.remove(node.file());
        model.removeNodeFromParent(node);
    }
}
Also used : FileNode(org.sonarlint.intellij.ui.nodes.FileNode)

Aggregations

FileNode (org.sonarlint.intellij.ui.nodes.FileNode)5 CheckForNull (javax.annotation.CheckForNull)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 Before (org.junit.Before)1 Test (org.junit.Test)1 LiveIssue (org.sonarlint.intellij.issue.LiveIssue)1 AbstractNode (org.sonarlint.intellij.ui.nodes.AbstractNode)1