use of org.sonarsource.sonarlint.core.client.api.exceptions.CanceledException in project sonarlint-intellij by SonarSource.
the class ServerUpdateTask method run.
public void run(@NotNull ProgressIndicator indicator) {
indicator.setText("Fetching data...");
try {
TaskProgressMonitor monitor = new TaskProgressMonitor(indicator);
ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server);
if (!onlyModules) {
UpdateResult updateResult = engine.update(serverConfiguration, monitor);
Collection<SonarAnalyzer> tooOld = updateResult.analyzers().stream().filter(SonarAnalyzer::sonarlintCompatible).filter(ServerUpdateTask::tooOld).collect(Collectors.toList());
if (!tooOld.isEmpty()) {
ApplicationManager.getApplication().invokeAndWait(() -> Messages.showWarningDialog(buildMinimumVersionFailMessage(tooOld), "Analyzers Not Loaded"), ModalityState.any());
}
log.log("Server binding '" + server.getName() + "' updated", LogOutput.Level.INFO);
}
updateModules(serverConfiguration, monitor);
} catch (CanceledException e) {
LOGGER.info("Update of server '" + server.getName() + "' was cancelled");
log.log("Update of server '" + server.getName() + "' was cancelled", LogOutput.Level.INFO);
} catch (Exception e) {
LOGGER.info("Error updating from server '" + server.getName() + "'", e);
final String msg = (e.getMessage() != null) ? e.getMessage() : ("Failed to update binding for server configuration '" + server.getName() + "'");
ApplicationManager.getApplication().invokeAndWait(new RunnableAdapter() {
@Override
public void doRun() {
Messages.showErrorDialog((Project) null, msg, "Update Failed");
}
}, ModalityState.any());
}
}
use of org.sonarsource.sonarlint.core.client.api.exceptions.CanceledException 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);
}
}
Aggregations