use of org.sonarlint.intellij.issue.LiveIssue 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);
}
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class SonarExternalAnnotator method apply.
@Override
public void apply(@NotNull PsiFile file, AnnotationContext annotationResult, @NotNull AnnotationHolder holder) {
// In PHPStorm the same PHP file is analyzed twice (once as PHP file and once as HTML file)
if ("html".equalsIgnoreCase(file.getFileType().getName())) {
return;
}
Collection<LiveIssue> issues = annotationResult.store.getForFile(file.getVirtualFile());
issues.stream().filter(issue -> !issue.isResolved()).forEach(issue -> {
// reject non-null ranges that are no longer valid. It probably means that they were deleted from the file.
RangeMarker range = issue.getRange();
if (range == null || range.isValid()) {
addAnnotation(issue, holder);
}
});
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class SonarLintCheckinHandler method processResult.
private ReturnResult processResult(Collection<VirtualFile> affectedFiles) {
AnalysisResultIssues analysisResultIssues = SonarLintUtils.get(project, AnalysisResultIssues.class);
IssueManager issueManager = SonarLintUtils.get(project, IssueManager.class);
Map<VirtualFile, Collection<LiveIssue>> map = affectedFiles.stream().collect(Collectors.toMap(Function.identity(), issueManager::getForFile));
long numIssues = map.entrySet().stream().flatMap(e -> e.getValue().stream()).filter(i -> !i.isResolved()).count();
analysisResultIssues.set(map, "SCM changed files");
long numBlockerIssues = map.entrySet().stream().flatMap(e -> e.getValue().stream()).filter(i -> !i.isResolved()).filter(i -> "BLOCKER".equals(i.getSeverity())).count();
if (numIssues == 0) {
return ReturnResult.COMMIT;
}
long numFiles = map.keySet().size();
String msg = createMessage(numFiles, numIssues, numBlockerIssues);
if (ApplicationManager.getApplication().isHeadlessEnvironment()) {
LOGGER.info(msg);
return ReturnResult.CANCEL;
}
return showYesNoCancel(msg);
}
use of org.sonarlint.intellij.issue.LiveIssue in project sonarlint-intellij by SonarSource.
the class IssueTreeModelBuilderTest method addFile.
private void addFile(Map<VirtualFile, Collection<LiveIssue>> data, String fileName, int numIssues) {
VirtualFile file = mock(VirtualFile.class);
when(file.getName()).thenReturn(fileName);
when(file.isValid()).thenReturn(true);
PsiFile psiFile = mock(PsiFile.class);
when(psiFile.isValid()).thenReturn(true);
List<LiveIssue> issueList = new LinkedList<>();
for (int i = 0; i < numIssues; i++) {
issueList.add(mockIssuePointer(fileName, i, "rule" + i, "MAJOR", (long) i));
}
data.put(file, issueList);
}
use of org.sonarlint.intellij.issue.LiveIssue 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();
}
}
Aggregations