use of org.sonarlint.intellij.util.TaskProgressMonitor in project sonarlint-intellij by SonarSource.
the class SonarLintTask method analyze.
private List<AnalysisResults> analyze(Project project, ProgressIndicator indicator, AccumulatorIssueListener listener) {
SonarLintAnalyzer analyzer = SonarLintUtils.get(project, SonarLintAnalyzer.class);
indicator.setIndeterminate(true);
int numModules = job.filesPerModule().keySet().size();
String suffix = "";
if (numModules > 1) {
suffix = String.format(" in %d modules", numModules);
}
int numFiles = job.allFiles().size();
if (numFiles > 1) {
indicator.setText("Running SonarLint Analysis for " + numFiles + " files" + suffix);
} else {
indicator.setText("Running SonarLint Analysis for '" + getFileName(job.allFiles().iterator().next()) + "'");
}
LOGGER.info(indicator.getText());
ProgressMonitor progressMonitor = new TaskProgressMonitor(indicator);
List<AnalysisResults> results = new LinkedList<>();
for (Map.Entry<Module, Collection<VirtualFile>> e : job.filesPerModule().entrySet()) {
results.add(analyzer.analyzeModule(e.getKey(), e.getValue(), listener, progressMonitor));
checkCanceled(indicator, myProject);
}
indicator.startNonCancelableSection();
return results;
}
use of org.sonarlint.intellij.util.TaskProgressMonitor in project sonarlint-intellij by SonarSource.
the class InformationFetchTask method run.
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setText("Connecting to " + server.getHostUrl() + "...");
indicator.setIndeterminate(false);
try {
ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server);
indicator.setText("Checking support of notifications");
notificationsSupported = SonarQubeNotifications.get().isSupported(serverConfiguration);
WsHelper wsHelper = new WsHelperImpl();
organizations = wsHelper.listOrganizations(serverConfiguration, new TaskProgressMonitor(indicator));
} catch (UnsupportedServerException e) {
organizations = Collections.emptyList();
} catch (Exception e) {
LOGGER.info("Failed to fetch information", e);
exception = e;
}
}
use of org.sonarlint.intellij.util.TaskProgressMonitor in project sonarlint-intellij by SonarSource.
the class ServerDownloadProjectTask method run.
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
TaskProgressMonitor monitor = new TaskProgressMonitor(indicator);
ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server);
this.result = engine.downloadAllModules(serverConfiguration, monitor);
} catch (Exception e) {
LOGGER.info("Failed to download list of projects", e);
this.exception = e;
}
}
use of org.sonarlint.intellij.util.TaskProgressMonitor 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());
}
}
Aggregations