use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-intellij by SonarSource.
the class IssueProcessor method process.
public void process(final SonarLintJob job, ProgressIndicator indicator, final Collection<Issue> rawIssues, Collection<ClientInputFile> failedAnalysisFiles) {
Map<VirtualFile, Collection<LiveIssue>> transformedIssues;
long start = System.currentTimeMillis();
AccessToken token = ReadAction.start();
try {
transformedIssues = transformIssues(rawIssues, job.allFiles(), failedAnalysisFiles);
// this might be updated later after tracking with server issues
manager.store(transformedIssues);
} finally {
// closeable only introduced in 2016.2
token.finish();
}
String issueStr = rawIssues.size() == 1 ? "issue" : "issues";
console.debug(String.format("Processed %d %s in %d ms", rawIssues.size(), issueStr, System.currentTimeMillis() - start));
long issuesToShow = transformedIssues.entrySet().stream().mapToLong(e -> e.getValue().size()).sum();
Collection<VirtualFile> filesWithIssues = transformedIssues.entrySet().stream().filter(e -> !e.getValue().isEmpty()).map(Map.Entry::getKey).collect(Collectors.toList());
String end = issuesToShow == 1 ? " issue" : " issues";
console.info("Found " + issuesToShow + end);
if (!filesWithIssues.isEmpty() && shouldUpdateServerIssues(job.trigger())) {
serverIssueUpdater.fetchAndMatchServerIssues(filesWithIssues, indicator, job.waitForServerIssues());
}
AnalysisCallback callback = job.callback();
if (callback != null) {
Set<VirtualFile> failedVirtualFiles = failedAnalysisFiles.stream().map(f -> (VirtualFile) f.getClientObject()).collect(Collectors.toSet());
callback.onSuccess(failedVirtualFiles);
}
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.ClientInputFile in project sonarlint-intellij by SonarSource.
the class IssueTreeModelBuilderTest method mockIssuePointer.
private static LiveIssue mockIssuePointer(String path, int startOffset, String rule, String severity, @Nullable Long creationDate) {
Issue issue = mock(Issue.class);
PsiFile psiFile = mock(PsiFile.class);
when(psiFile.isValid()).thenReturn(true);
ClientInputFile f = mockFile(path);
when(issue.getInputFile()).thenReturn(f);
when(issue.getRuleKey()).thenReturn(rule);
when(issue.getRuleName()).thenReturn(rule);
when(issue.getSeverity()).thenReturn(severity);
RangeMarker marker = mock(RangeMarker.class);
when(marker.getStartOffset()).thenReturn(startOffset);
LiveIssue ip = new LiveIssue(issue, psiFile);
ip.setCreationDate(creationDate);
return ip;
}
Aggregations