Skip to content

Commit

Permalink
Move workspace service preparation into language server application.
Browse files Browse the repository at this point in the history
This block is not relevant when application is not started.
  • Loading branch information
mickaelistria authored and rgrunber committed Mar 1, 2023
1 parent 3537ef2 commit f2dc150
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import org.eclipse.core.internal.net.ProxySelector;
import org.eclipse.core.net.proxy.IProxyData;
import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
Expand Down Expand Up @@ -156,15 +154,6 @@ public static BundleContext getBundleContext() {
@Override
public void start(BundleContext bundleContext) throws Exception {
super.start(bundleContext);
try {
Platform.getBundle(ResourcesPlugin.PI_RESOURCES).start(Bundle.START_TRANSIENT);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription description = workspace.getDescription();
description.setAutoBuilding(false);
workspace.setDescription(description);
} catch (BundleException e) {
logException(e.getMessage(), e);
}
boolean isDebug = Boolean.getBoolean("jdt.ls.debug");
try {
redirectStandardStreams(isDebug);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal;

import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;

public class LanguageServerApplication implements IApplication {

Expand All @@ -23,6 +30,7 @@ public class LanguageServerApplication implements IApplication {

@Override
public Object start(IApplicationContext context) throws Exception {
prepareWorkspace();
JavaLanguageServerPlugin.startLanguageServer(this);
synchronized (waitLock) {
while (!shutdown) {
Expand All @@ -38,6 +46,18 @@ public Object start(IApplicationContext context) throws Exception {
return IApplication.EXIT_OK;
}

private static void prepareWorkspace() throws CoreException {
try {
Platform.getBundle(ResourcesPlugin.PI_RESOURCES).start(Bundle.START_TRANSIENT);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription description = workspace.getDescription();
description.setAutoBuilding(false);
workspace.setDescription(description);
} catch (BundleException e) {
JavaLanguageServerPlugin.logException(e.getMessage(), e);
}
}

@Override
public void stop() {
synchronized (waitLock) {
Expand Down

0 comments on commit f2dc150

Please sign in to comment.