Skip to content

Commit

Permalink
Java LS should lock its workspace
Browse files Browse the repository at this point in the history
Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza committed Apr 25, 2019
1 parent c7967e7 commit db570ba
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
*******************************************************************************/
package org.eclipse.jdt.ls.core.internal;

import java.io.File;

import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.osgi.service.datalocation.Location;

public class LanguageServer implements IApplication {

Expand All @@ -22,6 +26,15 @@ public class LanguageServer implements IApplication {
@Override
public Object start(IApplicationContext context) throws Exception {

Location instanceLoc = Platform.getInstanceLocation();
if (!instanceLoc.lock()) {
File workspaceFile = new File(instanceLoc.getURL().getFile());
if (workspaceFile.exists()) {
JavaLanguageServerPlugin.logError("Could not launch the server because associated workspace is currently in use by another Java LS server.");
}
return IApplication.EXIT_OK;
}

JavaLanguageServerPlugin.startLanguageServer(this);
synchronized(waitLock){
while (!shutdown) {
Expand Down

0 comments on commit db570ba

Please sign in to comment.