use of org.sonarlint.intellij.ui.nodes.LocationNode in project sonarlint-intellij by SonarSource.
the class FlowsTreeModelBuilder method setSingleFlow.
private void setSingleFlow(LiveIssue.Flow flow, RangeMarker rangeMarker, @Nullable String message) {
summary = new SummaryNode();
LocationNode primaryLocation = new LocationNode(rangeMarker, message);
primaryLocation.setBold(true);
summary.add(primaryLocation);
List<LiveIssue.IssueLocation> reversedLocations = new ArrayList<>(flow.locations());
Collections.reverse(reversedLocations);
int i = 1;
for (LiveIssue.IssueLocation location : reversedLocations) {
LocationNode locationNode = new LocationNode(i++, location.location(), location.message());
primaryLocation.add(locationNode);
}
model.setRoot(summary);
}
use of org.sonarlint.intellij.ui.nodes.LocationNode in project sonarlint-intellij by SonarSource.
the class FlowsTreeModelBuilder method setMultipleFlows.
private void setMultipleFlows(List<LiveIssue.Flow> flows, RangeMarker rangeMarker, @Nullable String message) {
summary = new SummaryNode();
LocationNode primaryLocation = new LocationNode(rangeMarker, message);
summary.add(primaryLocation);
int i = 1;
for (LiveIssue.Flow f : flows) {
LabelNode label = new LabelNode("Flow " + i);
primaryLocation.add(label);
List<LiveIssue.IssueLocation> reversedLocations = new ArrayList<>(f.locations());
Collections.reverse(reversedLocations);
int j = 1;
for (LiveIssue.IssueLocation location : reversedLocations) {
LocationNode locationNode = new LocationNode(j, location.location(), location.message());
label.add(locationNode);
j++;
}
i++;
}
model.setRoot(summary);
}
use of org.sonarlint.intellij.ui.nodes.LocationNode in project sonarlint-intellij by SonarSource.
the class FlowsTreeModelBuilder method setFlatList.
private void setFlatList(List<LiveIssue.Flow> flows, RangeMarker rangeMarker, @Nullable String message) {
summary = new SummaryNode();
LocationNode primaryLocation = new LocationNode(rangeMarker, message);
primaryLocation.setBold(true);
summary.add(primaryLocation);
flows.stream().flatMap(flow -> flow.locations().stream()).sorted(Comparator.comparing(i -> i.location().getStartOffset())).forEachOrdered(location -> {
LocationNode locationNode = new LocationNode(location.location(), location.message());
primaryLocation.add(locationNode);
});
model.setRoot(summary);
}
use of org.sonarlint.intellij.ui.nodes.LocationNode in project sonarlint-intellij by SonarSource.
the class FlowsTree method init.
private void init() {
setRootVisible(false);
setShowsRootHandles(false);
setCellRenderer(new TreeCellRenderer());
this.selectionModel.addTreeSelectionListener(e -> {
if (e.getSource() != null) {
TreePath newPath = e.getNewLeadSelectionPath();
if (newPath != null) {
Object o = newPath.getLastPathComponent();
if (!(o instanceof LocationNode)) {
FlowsTree.this.setSelectionPath(e.getOldLeadSelectionPath());
} else {
navigateToSelected();
}
}
}
});
TreeWillExpandListener l = new TreeWillExpandListener() {
@Override
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
// nothing to do
}
@Override
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
throw new ExpandVetoException(event);
}
};
addTreeWillExpandListener(l);
}
use of org.sonarlint.intellij.ui.nodes.LocationNode in project sonarlint-intellij by SonarSource.
the class FlowsTree method navigateToSelected.
private void navigateToSelected() {
DefaultMutableTreeNode node = getSelectedNode();
if (!(node instanceof LocationNode)) {
return;
}
RangeMarker rangeMarker = ((LocationNode) node).rangeMarker();
if (rangeMarker == null || !rangeMarker.isValid()) {
return;
}
PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(rangeMarker.getDocument());
if (psiFile != null) {
new OpenFileDescriptor(project, psiFile.getVirtualFile(), rangeMarker.getStartOffset()).navigate(false);
}
}
Aggregations