Skip to content

Commit

Permalink
Do not enable notifications if disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju committed Dec 17, 2020
1 parent ae73a22 commit 3092f8d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -633,4 +633,8 @@ public List<ServerIssue> downloadServerIssues(ProjectBinding projectBinding, Str
public List<ServerIssue> getServerIssues(ProjectBinding projectBinding, String filePath) {
return withEngine(engine -> engine.getServerIssues(projectBinding, filePath)).orElse(emptyList());
}

public ProjectBinding calculatePathPrefixes(String projectKey, List<String> ideFilePaths) {
return withEngine(engine -> engine.calculatePathPrefixes(projectKey, ideFilePaths)).orElse(new ProjectBinding(projectKey, "", ""));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@

public class ProjectStorageUpdateJob extends Job {

private final String serverId;
private final String connectionId;
private final String projectKey;

public ProjectStorageUpdateJob(String serverId, String projectKey) {
super("Update SonarLint binding data for project '" + projectKey + "' on '" + serverId + "'");
this.serverId = serverId;
public ProjectStorageUpdateJob(String connectionId, String projectKey) {
super("Update SonarLint binding data for project '" + projectKey + "' on '" + connectionId + "'");
this.connectionId = connectionId;
this.projectKey = projectKey;
}

@Override
protected IStatus run(IProgressMonitor monitor) {
try {
Optional<IConnectedEngineFacade> server = SonarLintCorePlugin.getServersManager().findById(serverId);
Optional<IConnectedEngineFacade> server = SonarLintCorePlugin.getServersManager().findById(connectionId);
server.ifPresent(s -> s.updateProjectStorage(projectKey, monitor));
return Status.OK_STATUS;
} catch (Exception e) {
return new Status(IStatus.ERROR, SonarLintCorePlugin.PLUGIN_ID, "Unable to update SonarLint binding data for project '" + projectKey + "' on '" + serverId + "'", e);
return new Status(IStatus.ERROR, SonarLintCorePlugin.PLUGIN_ID, "Unable to update SonarLint binding data for project '" + projectKey + "' on '" + connectionId + "'", e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,13 @@ public static void startupAsync() {
public static void subscribeToNotifications(ISonarLintProject project) {
SonarLintCorePlugin.getServersManager()
.resolveBinding(project)
.ifPresent(binding -> SonarLintCorePlugin.getInstance()
.notificationsManager()
.subscribe(project, getDefault().listenerFactory().create(binding.getEngineFacade())));
.ifPresent(binding -> {
if (!binding.getEngineFacade().areNotificationsDisabled()) {
SonarLintCorePlugin.getInstance()
.notificationsManager()
.subscribe(project, getDefault().listenerFactory().create(binding.getEngineFacade()));
}
});
}

public static void unsubscribeToNotifications(ISonarLintProject project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public boolean performFinish() {
String oldServerId = projectConfig.getProjectBinding().map(EclipseProjectBinding::connectionId).orElse(null);
String oldProjectKey = projectConfig.getProjectBinding().map(EclipseProjectBinding::projectKey).orElse(null);
if (!Objects.equals(serverId, oldServerId) || !Objects.equals(projectKey, oldProjectKey)) {
// We can ignore path prefixes for now, they will be update by the ProjectStorageUpdateJob
projectConfig.setProjectBinding(new EclipseProjectBinding(serverId, projectKey, "", ""));
changed = true;
}
Expand Down

0 comments on commit 3092f8d

Please sign in to comment.