refactored common language server eclipse integration code into superclass and enabled progress message support for all eclipse ls integrations
This commit is contained in:
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
|
||||
org.eclipse.tm4e.ui;bundle-version="0.1.0",
|
||||
org.eclipse.lsp4j,
|
||||
org.eclipse.ui.workbench,
|
||||
org.eclipse.jface
|
||||
org.eclipse.jface,
|
||||
org.springframework.tooling.ls.eclipse.commons;bundle-version="4.0.0"
|
||||
Import-Package: com.google.gson;version="2.7.0",
|
||||
org.eclipse.jface.preference,
|
||||
org.eclipse.lsp4j.jsonrpc.messages;version="0.1.0.v20170117-0759",
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
<server
|
||||
class="org.springframework.tooling.bosh.ls.BoshLanguageServer"
|
||||
id="org.eclipse.languageserver.languages.bosh"
|
||||
clientImpl="org.springframework.tooling.ls.eclipse.commons.STS4LanguageClientImpl"
|
||||
label="BOSH Language Server">
|
||||
</server>
|
||||
<contentTypeMapping
|
||||
|
||||
@@ -20,24 +20,13 @@ import java.util.List;
|
||||
import org.eclipse.core.runtime.FileLocator;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.jdt.internal.launching.StandardVMType;
|
||||
import org.eclipse.jdt.launching.IVMInstall;
|
||||
import org.eclipse.jdt.launching.JavaRuntime;
|
||||
import org.eclipse.jface.action.IStatusLineManager;
|
||||
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Message;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.NotificationMessage;
|
||||
import org.eclipse.lsp4j.services.LanguageServer;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
|
||||
|
||||
/**
|
||||
* @author Martin Lippert
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class BoshLanguageServer extends ProcessStreamConnectionProvider {
|
||||
public class BoshLanguageServer extends STS4LanguageServerProcessStreamConnector {
|
||||
|
||||
public BoshLanguageServer() {
|
||||
List<String> commands = new ArrayList<>();
|
||||
@@ -58,44 +47,6 @@ public class BoshLanguageServer extends ProcessStreamConnectionProvider {
|
||||
setWorkingDirectory(workingDir);
|
||||
}
|
||||
|
||||
public void handleMessage(Message message, LanguageServer languageServer, String rootPath) {
|
||||
if (message instanceof NotificationMessage) {
|
||||
NotificationMessage notificationMessage = (NotificationMessage) message;
|
||||
if ("sts/progress".equals(notificationMessage.getMethod())) {
|
||||
JsonObject params = (JsonObject) notificationMessage.getParams();
|
||||
String status = params.has("statusMsg") ? params.get("statusMsg").getAsString() : "";
|
||||
showStatusMessage(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showStatusMessage(final String status) {
|
||||
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
IStatusLineManager statusLineManager = getStatusLineManager();
|
||||
if (statusLineManager != null) {
|
||||
statusLineManager.setMessage(status);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private IStatusLineManager getStatusLineManager() {
|
||||
try {
|
||||
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars().getStatusLineManager();
|
||||
}
|
||||
catch (NullPointerException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected String getJDKLocation() {
|
||||
IVMInstall jdk = JavaRuntime.getDefaultVMInstall();
|
||||
File javaExecutable = StandardVMType.findJavaExecutable(jdk.getInstallLocation());
|
||||
return javaExecutable.getAbsolutePath();
|
||||
}
|
||||
|
||||
protected String getLanguageServerJARLocation() {
|
||||
String languageServer = "bosh-language-server-" + Constants.LANGUAGE_SERVER_VERSION + "-SNAPSHOT.jar";
|
||||
|
||||
@@ -113,11 +64,6 @@ public class BoshLanguageServer extends ProcessStreamConnectionProvider {
|
||||
return dataFile.getAbsolutePath();
|
||||
}
|
||||
|
||||
protected String getWorkingDirLocation() {
|
||||
// TODO: identify a reasonable working directory for the language server process
|
||||
return System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
protected void copyLanguageServerJAR(String languageServerJarName) throws Exception {
|
||||
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
|
||||
InputStream stream = FileLocator.openStream( bundle, new Path("servers/" + languageServerJarName), false );
|
||||
|
||||
Reference in New Issue
Block a user