Skip to content

Commit

Permalink
Pass ClientPreferences to Handler
Browse files Browse the repository at this point in the history
Signed-off-by: Rome Li <rome.li@microsoft.com>
  • Loading branch information
akaroml committed Sep 20, 2019
1 parent 6eb9f78 commit 840a5b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Expand Up @@ -254,15 +254,15 @@ public void initialized(InitializedParams params) {
// we do not have the user setting initialized yet at this point but we should
// still call to enable defaults in case client does not support configuration changes
syncCapabilitiesToSettings();
boolean isDiagnosticTagSupported = preferenceManager.getClientPreferences().isDiagnosticTagSupported();

Job initializeWorkspace = new Job("Initialize workspace") {

@Override
public IStatus run(IProgressMonitor monitor) {
try {
JobHelpers.waitForBuildJobs(60 * 60 * 1000); // 1 hour
logInfo(">> build jobs finished");
workspaceDiagnosticsHandler = new WorkspaceDiagnosticsHandler(JDTLanguageServer.this.client, pm, isDiagnosticTagSupported);
workspaceDiagnosticsHandler = new WorkspaceDiagnosticsHandler(JDTLanguageServer.this.client, pm, preferenceManager.getClientPreferences());
workspaceDiagnosticsHandler.publishDiagnostics(monitor);
workspaceDiagnosticsHandler.addResourceChangeListener();
pm.registerWatchers();
Expand Down
Expand Up @@ -42,6 +42,7 @@
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
import org.eclipse.jdt.ls.core.internal.ResourceUtils;
import org.eclipse.jdt.ls.core.internal.managers.ProjectsManager;
import org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.lsp4j.Diagnostic;
Expand All @@ -68,13 +69,13 @@ public final class WorkspaceDiagnosticsHandler implements IResourceChangeListene

@Deprecated
public WorkspaceDiagnosticsHandler(JavaClientConnection connection, ProjectsManager projectsManager) {
this(connection, projectsManager, false);
this(connection, projectsManager, null);
}

public WorkspaceDiagnosticsHandler(JavaClientConnection connection, ProjectsManager projectsManager, boolean isDiagnosticTagSupported) {
public WorkspaceDiagnosticsHandler(JavaClientConnection connection, ProjectsManager projectsManager, ClientPreferences prefs) {
this.connection = connection;
this.projectsManager = projectsManager;
this.isDiagnosticTagSupported = isDiagnosticTagSupported;
this.isDiagnosticTagSupported = prefs != null ? prefs.isDiagnosticTagSupported() : false;
}

public void addResourceChangeListener() {
Expand Down
Expand Up @@ -35,6 +35,7 @@
import org.eclipse.jdt.ls.core.internal.JavaClientConnection;
import org.eclipse.jdt.ls.core.internal.ResourceUtils;
import org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest;
import org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences;
import org.eclipse.jdt.ls.tests.Unstable;
import org.eclipse.jface.text.IDocument;
import org.eclipse.lsp4j.Diagnostic;
Expand Down Expand Up @@ -66,7 +67,7 @@ public class WorkspaceDiagnosticsHandlerTest extends AbstractProjectsManagerBase

@Before
public void setup() throws Exception {
handler = new WorkspaceDiagnosticsHandler(connection, projectsManager, true);
handler = new WorkspaceDiagnosticsHandler(connection, projectsManager, preferenceManager.getClientPreferences());
handler.addResourceChangeListener();
}

Expand Down

0 comments on commit 840a5b9

Please sign in to comment.