Skip to content

Commit f20d928

Browse files
Respect the autobuild setting on initialization. (#3177)
- Set autobuild setting for workspace as requested
1 parent e95ec63 commit f20d928

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/LanguageServerApplication.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,13 @@
2222
import java.text.SimpleDateFormat;
2323
import java.util.Date;
2424

25-
import org.eclipse.core.resources.IWorkspace;
26-
import org.eclipse.core.resources.IWorkspaceDescription;
2725
import org.eclipse.core.resources.IWorkspaceRoot;
2826
import org.eclipse.core.resources.ResourcesPlugin;
29-
import org.eclipse.core.runtime.CoreException;
30-
import org.eclipse.core.runtime.Platform;
3127
import org.eclipse.core.runtime.jobs.Job;
3228
import org.eclipse.equinox.app.IApplication;
3329
import org.eclipse.equinox.app.IApplicationContext;
3430
import org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer;
3531
import org.eclipse.jdt.ls.core.internal.handlers.ProgressReporterManager;
36-
import org.osgi.framework.Bundle;
37-
import org.osgi.framework.BundleException;
3832

3933
public class LanguageServerApplication implements IApplication {
4034

@@ -49,7 +43,6 @@ public class LanguageServerApplication implements IApplication {
4943

5044
@Override
5145
public Object start(IApplicationContext context) throws Exception {
52-
prepareWorkspace();
5346
prepareStreams();
5447
JavaLanguageServerPlugin.startLanguageServer(this);
5548
if (JavaLanguageServerPlugin.getInstance().getProtocol() instanceof JDTLanguageServer server) {
@@ -76,18 +69,6 @@ public Object start(IApplicationContext context) throws Exception {
7669
return IApplication.EXIT_OK;
7770
}
7871

79-
private static void prepareWorkspace() throws CoreException {
80-
try {
81-
Platform.getBundle(ResourcesPlugin.PI_RESOURCES).start(Bundle.START_TRANSIENT);
82-
IWorkspace workspace = ResourcesPlugin.getWorkspace();
83-
IWorkspaceDescription description = workspace.getDescription();
84-
description.setAutoBuilding(false);
85-
workspace.setDescription(description);
86-
} catch (BundleException e) {
87-
JavaLanguageServerPlugin.logException(e.getMessage(), e);
88-
}
89-
}
90-
9172
@Override
9273
public void stop() {
9374
synchronized (waitLock) {

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/BaseInitHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ public InitializeResult initialize(InitializeParams param) {
113113
Preferences prefs = Preferences.createFrom((Map<String, Object>) settings);
114114
prefs.setRootPaths(rootPaths);
115115
preferenceManager.update(prefs);
116+
try {
117+
ProjectsManager.setAutoBuilding(preferenceManager.getPreferences().isAutobuildEnabled());
118+
} catch (CoreException e) {
119+
JavaLanguageServerPlugin.logException("Failed apply autobuilding setting", e);
120+
}
116121
if (!isWorkspaceInitialized()) {
117122
// We don't care about triggering a full build here, like in onDidChangeConfiguration
118123
try {

0 commit comments

Comments
 (0)