use of org.sonarlint.intellij.tasks.ServerUpdateTask in project sonarlint-intellij by SonarSource.
the class SonarLintProjectConfigurable method onSave.
/**
* When we save the binding, we need to:
* - Send a message for listeners interested in it
* - If we are bound to a module, update it (even if we detected no changes)
* - Clear all issues and submit an analysis on all open files
*/
private void onSave() {
SonarLintProjectNotifications.get(project).reset();
ProjectConfigurationListener projectListener = project.getMessageBus().syncPublisher(ProjectConfigurationListener.TOPIC);
if (projectSettings.isBindingEnabled() && projectSettings.getProjectKey() != null && projectSettings.getServerId() != null) {
ProjectBindingManager bindingManager = SonarLintUtils.get(project, ProjectBindingManager.class);
try {
SonarQubeServer server = bindingManager.getSonarQubeServer();
ConnectedSonarLintEngine engine = bindingManager.getConnectedEngineSkipChecks();
String moduleKey = projectSettings.getProjectKey();
ServerUpdateTask task = new ServerUpdateTask(engine, server, Collections.singletonMap(moduleKey, Collections.singletonList(project)), true);
ProgressManager.getInstance().run(task.asModal());
} catch (InvalidBindingException e) {
// nothing to do, SonarLintEngineManager should have already shown a warning
}
}
projectListener.changed(projectSettings);
}
use of org.sonarlint.intellij.tasks.ServerUpdateTask in project sonarlint-intellij by SonarSource.
the class SonarQubeServerMgmtPanel method updateServerBinding.
public static void updateServerBinding(SonarQubeServer server, ConnectedSonarLintEngine engine, boolean onlyProjects) {
Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
Map<String, List<Project>> projectsPerModule = new HashMap<>();
for (Project p : openProjects) {
SonarLintProjectSettings projectSettings = SonarLintUtils.get(p, SonarLintProjectSettings.class);
String moduleKey = projectSettings.getProjectKey();
if (projectSettings.isBindingEnabled() && server.getName().equals(projectSettings.getServerId()) && moduleKey != null) {
List<Project> projects = projectsPerModule.computeIfAbsent(moduleKey, k -> new ArrayList<>());
projects.add(p);
}
}
ServerUpdateTask task = new ServerUpdateTask(engine, server, projectsPerModule, onlyProjects);
ProgressManager.getInstance().run(task.asBackground());
}
Aggregations