use of org.sonarlint.intellij.messages.ProjectConfigurationListener 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.messages.ProjectConfigurationListener in project sonarlint-intellij by SonarSource.
the class ExcludeFileAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getProject();
VirtualFile[] files = e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
if (project == null || project.isDisposed() || files == null || files.length == 0) {
return;
}
SonarLintProjectSettings settings = SonarLintUtils.get(project, SonarLintProjectSettings.class);
List<String> exclusions = new ArrayList<>(settings.getFileExclusions());
List<String> newExclusions = Arrays.stream(files).map(vf -> toExclusion(project, vf)).filter(exclusion -> !exclusion.item().isEmpty()).map(ExclusionItem::toStringWithType).filter(path -> !exclusions.contains(path)).collect(Collectors.toList());
if (!newExclusions.isEmpty()) {
exclusions.addAll(newExclusions);
settings.setFileExclusions(exclusions);
ProjectConfigurationListener projectListener = project.getMessageBus().syncPublisher(ProjectConfigurationListener.TOPIC);
projectListener.changed(settings);
}
}
Aggregations