use of org.sonarlint.intellij.ui.nodes.AbstractNode in project sonarlint-intellij by SonarSource.
the class IssueTreeModelBuilder method getPreviousNode.
@CheckForNull
private static AbstractNode getPreviousNode(AbstractNode startNode) {
AbstractNode parent = (AbstractNode) startNode.getParent();
if (parent == null) {
return null;
}
TreeNode previous = parent.getChildBefore(startNode);
if (previous == null) {
return getPreviousNode(parent);
}
return (AbstractNode) previous;
}
use of org.sonarlint.intellij.ui.nodes.AbstractNode in project sonarlint-intellij by SonarSource.
the class IssueTreeModelBuilder method getNextNode.
/**
* Next node, either the sibling if it exists, or the sibling of the parent
*/
@CheckForNull
private static AbstractNode getNextNode(AbstractNode startNode) {
AbstractNode parent = (AbstractNode) startNode.getParent();
if (parent == null) {
return null;
}
TreeNode after = parent.getChildAfter(startNode);
if (after == null) {
return getNextNode(parent);
}
return (AbstractNode) after;
}
use of org.sonarlint.intellij.ui.nodes.AbstractNode 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.AbstractNode in project sonarlint-intellij by SonarSource.
the class TreeCellRenderer method customizeCellRenderer.
@Override
public void customizeCellRenderer(@NotNull JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
AbstractNode node = (AbstractNode) value;
node.render(this);
}
use of org.sonarlint.intellij.ui.nodes.AbstractNode in project sonarlint-intellij by SonarSource.
the class AbstractNodeTest method testFileCount.
@Test
public void testFileCount() {
AbstractNode child1 = mock(AbstractNode.class);
AbstractNode child2 = mock(AbstractNode.class);
AbstractNode child3 = mock(AbstractNode.class);
when(child1.getFileCount()).thenReturn(1);
when(child1.getIssueCount()).thenReturn(1);
when(child2.getFileCount()).thenReturn(2);
when(child2.getIssueCount()).thenReturn(2);
when(child3.getFileCount()).thenReturn(3);
when(child3.getIssueCount()).thenReturn(3);
testNode.add(child1);
testNode.add(child2);
testNode.add(child3);
assertThat(testNode.getFileCount()).isEqualTo(6);
assertThat(testNode.getIssueCount()).isEqualTo(6);
assertThat(testNode.getFileCount()).isEqualTo(6);
assertThat(testNode.getIssueCount()).isEqualTo(6);
// second call should be from cache
verify(child1, times(1)).getFileCount();
verify(child1, times(1)).getIssueCount();
}
Aggregations