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");
}
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();
}
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);
}
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);
}
}
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);
}
}
Aggregations