use of org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults in project sonarlint-core by SonarSource.
the class ConnectedModeTest method parsingErrorJava.
@Test
public void parsingErrorJava() throws IOException {
String fileContent = "pac kage its; public class MyTest { }";
Path testFile = temp.newFile("MyTestParseError.java").toPath();
Files.write(testFile, fileContent.getBytes(StandardCharsets.UTF_8));
updateGlobal();
updateModule(PROJECT_KEY_JAVA);
SaveIssueListener issueListener = new SaveIssueListener();
AnalysisResults results = engine.analyze(createAnalysisConfiguration(PROJECT_KEY_JAVA, testFile.toString()), issueListener, null, null);
assertThat(results.failedAnalysisFiles()).hasSize(1);
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method analyze.
@Override
public AnalysisResults analyze(ConnectedAnalysisConfiguration configuration, IssueListener issueListener, @Nullable LogOutput logOutput, @Nullable ProgressMonitor monitor) {
checkNotNull(configuration);
checkNotNull(issueListener);
setLogging(logOutput);
LoggedErrorHandler errorHandler = new LoggedErrorHandler(configuration.inputFiles());
SonarLintLogging.setErrorHandler(errorHandler);
return withReadLock(() -> {
try {
AnalysisResults results = getHandler().analyze(storageContainer.getGlobalExtensionContainer(), configuration, issueListener, new ProgressWrapper(monitor));
errorHandler.getErrorFiles().forEach(results.failedAnalysisFiles()::add);
return results;
} catch (RuntimeException e) {
throw SonarLintWrappedException.wrap(e);
}
});
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults in project sonarlint-core by SonarSource.
the class StandaloneSonarLintEngineImpl method analyze.
@Override
public AnalysisResults analyze(StandaloneAnalysisConfiguration configuration, IssueListener issueListener, @Nullable LogOutput logOutput, @Nullable ProgressMonitor monitor) {
checkNotNull(configuration);
checkNotNull(issueListener);
setLogging(logOutput);
LoggedErrorHandler errorHandler = new LoggedErrorHandler(configuration.inputFiles());
SonarLintLogging.setErrorHandler(errorHandler);
rwl.readLock().lock();
try {
AnalysisResults results = globalContainer.analyze(configuration, issueListener, new ProgressWrapper(monitor));
errorHandler.getErrorFiles().forEach(results.failedAnalysisFiles()::add);
return results;
} catch (RuntimeException e) {
throw SonarLintWrappedException.wrap(e);
} finally {
rwl.readLock().unlock();
}
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults in project sonarlint-intellij by SonarSource.
the class SonarLintTask method run.
@Override
public void run(ProgressIndicator indicator) {
AccumulatorIssueListener listener = new AccumulatorIssueListener();
try {
checkCanceled(indicator, myProject);
List<AnalysisResults> results = analyze(myProject, indicator, listener);
// last chance to cancel (to avoid the possibility of having interrupt flag set)
checkCanceled(indicator, myProject);
LOGGER.info("SonarLint analysis done");
indicator.setIndeterminate(false);
indicator.setFraction(.9);
List<Issue> issues = listener.getIssues();
indicator.setText("Creating SonarLint issues: " + issues.size());
List<ClientInputFile> allFailedAnalysisFiles = results.stream().flatMap(r -> r.failedAnalysisFiles().stream()).collect(Collectors.toList());
processor.process(job, indicator, issues, allFailedAnalysisFiles);
} catch (CanceledException e1) {
console.info("Analysis canceled");
return;
} catch (Throwable e) {
handleError(e, indicator);
} finally {
myProject.getMessageBus().syncPublisher(TaskListener.SONARLINT_TASK_TOPIC).ended(job);
}
}
use of org.sonarsource.sonarlint.core.client.api.common.analysis.AnalysisResults in project sonarlint-intellij by SonarSource.
the class ConnectedSonarLintFacadeTest method should_start_analysis.
@Test
public void should_start_analysis() {
AnalysisResults results = mock(AnalysisResults.class);
when(engine.analyze(any(ConnectedAnalysisConfiguration.class), any(IssueListener.class), any(LogOutput.class), any(ProgressMonitor.class))).thenReturn(results);
assertThat(facade.startAnalysis(Collections.emptyList(), mock(IssueListener.class), Collections.emptyMap(), mock(ProgressMonitor.class))).isEqualTo(results);
}
Aggregations