refactored common language server eclipse integration code into superclass and enabled progress message support for all eclipse ls integrations

This commit is contained in:
Martin Lippert
2017-11-22 20:57:56 +01:00
parent a50c09097a
commit 0e05a1a280
17 changed files with 205 additions and 250 deletions

View File

@@ -11,7 +11,6 @@
package org.springframework.tooling.boot.java.ls;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
@@ -21,18 +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.lsp4e.server.ProcessStreamConnectionProvider;
import org.osgi.framework.Bundle;
import org.springframework.tooling.ls.eclipse.commons.LanguageServerProcessReaper;
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
/**
* @author Martin Lippert
*/
@SuppressWarnings("restriction")
public class SpringBootJavaLanguageServer extends ProcessStreamConnectionProvider {
private static LanguageServerProcessReaper processReaper = new LanguageServerProcessReaper();
public class SpringBootJavaLanguageServer extends STS4LanguageServerProcessStreamConnector {
public SpringBootJavaLanguageServer() {
List<String> commands = new ArrayList<>();
@@ -43,7 +37,7 @@ public class SpringBootJavaLanguageServer extends ProcessStreamConnectionProvide
commands.add("-Dlsp.lazy.completions.disable=true");
commands.add("-Dlsp.completions.indentation.enable=true");
commands.add("-Xmx100m");
commands.add("-Xmx200m");
commands.add("-cp");
commands.add(getToolsJAR() + ":" + getLanguageServerJARLocation());
commands.add("org.springframework.boot.loader.JarLauncher");
@@ -54,29 +48,6 @@ public class SpringBootJavaLanguageServer extends ProcessStreamConnectionProvide
setWorkingDirectory(workingDir);
}
@Override
public void start() throws IOException {
super.start();
processReaper.addProcess(LanguageServerProcessReaper.getProcess(this));
}
@Override
public void stop() {
super.stop();
processReaper.removeProcess(LanguageServerProcessReaper.getProcess(this));
}
protected String getJDKLocation() {
File jre = new File(System.getProperty("java.home"));
File javaExecutable = StandardVMType.findJavaExecutable(jre);
return javaExecutable.getAbsolutePath();
}
protected String getToolsJAR() {
File jre = new File(System.getProperty("java.home"));
return new File(jre.getParent(), "lib" + Path.SEPARATOR + "tools.jar").getAbsolutePath();
}
protected String getLanguageServerJARLocation() {
String fromSysprop = System.getProperty("boot-java-ls-jar", null);
if (fromSysprop!=null) {
@@ -102,11 +73,6 @@ public class SpringBootJavaLanguageServer extends ProcessStreamConnectionProvide
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, String languageServerLocalCopy) throws Exception {
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
InputStream stream = FileLocator.openStream( bundle, new Path("servers/" + languageServerJarName), false );

View File

@@ -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",

View File

@@ -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

View File

@@ -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 );

View File

@@ -7,6 +7,7 @@
<server
class="org.springframework.tooling.cloudfoundry.manifest.ls.CloudFoundryManifestLanguageServer"
id="org.eclipse.languageserver.languages.cloudfoundrymanifest"
clientImpl="org.springframework.tooling.ls.eclipse.commons.STS4LanguageClientImpl"
label="Cloud Foundry Manifest Language Server">
</server>
<contentTypeMapping

View File

@@ -11,7 +11,6 @@
package org.springframework.tooling.cloudfoundry.manifest.ls;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.nio.file.Files;
@@ -23,23 +22,18 @@ import java.util.concurrent.CopyOnWriteArrayList;
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.lsp4e.server.ProcessStreamConnectionProvider;
import org.eclipse.lsp4j.DidChangeConfigurationParams;
import org.eclipse.lsp4j.InitializeResult;
import org.eclipse.lsp4j.jsonrpc.messages.Message;
import org.eclipse.lsp4j.jsonrpc.messages.ResponseMessage;
import org.eclipse.lsp4j.services.LanguageServer;
import org.osgi.framework.Bundle;
import org.springframework.tooling.ls.eclipse.commons.LanguageServerProcessReaper;
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
/**
* @author Martin Lippert
*/
@SuppressWarnings("restriction")
public class CloudFoundryManifestLanguageServer extends ProcessStreamConnectionProvider {
private static LanguageServerProcessReaper processReaper = new LanguageServerProcessReaper();
public class CloudFoundryManifestLanguageServer extends STS4LanguageServerProcessStreamConnector {
private LanguageServer languageServer;
private URI rootPath;
@@ -93,7 +87,6 @@ public class CloudFoundryManifestLanguageServer extends ProcessStreamConnectionP
public void stop() {
removeLanguageServer(this);
super.stop();
processReaper.removeProcess(LanguageServerProcessReaper.getProcess(this));
}
@Override
@@ -101,28 +94,6 @@ public class CloudFoundryManifestLanguageServer extends ProcessStreamConnectionP
return cfTargetOptionSettings;
}
protected String getJDKLocation() {
try {
File javaHome= new File(System.getProperty("java.home")).getCanonicalFile(); //$NON-NLS-1$
if (javaHome.exists()) {
File javaExecutable = StandardVMType.findJavaExecutable(javaHome);
if (javaExecutable != null && javaExecutable.exists()) {
return javaExecutable.getAbsolutePath();
}
}
} catch (IOException e) {
return null;
}
return null;
}
@Override
public void start() throws IOException {
super.start();
processReaper.addProcess(LanguageServerProcessReaper.getProcess(this));
}
protected String getLanguageServerJARLocation() {
String languageServer = "manifest-yaml-language-server-" + Constants.LANGUAGE_SERVER_VERSION;
@@ -144,11 +115,6 @@ public class CloudFoundryManifestLanguageServer extends ProcessStreamConnectionP
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, String languageServerLocalCopy) throws Exception {
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
InputStream stream = FileLocator.openStream( bundle, new Path("servers/" + languageServerJarName), false );

View File

@@ -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",

View File

@@ -85,6 +85,7 @@
<server
class="org.springframework.tooling.concourse.ls.ConcourseLanguageServer"
id="org.eclipse.languageserver.languages.concourse"
clientImpl="org.springframework.tooling.ls.eclipse.commons.STS4LanguageClientImpl"
label="Concourse Language Server">
</server>
<contentTypeMapping

View File

@@ -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 ConcourseLanguageServer extends ProcessStreamConnectionProvider {
public class ConcourseLanguageServer extends STS4LanguageServerProcessStreamConnector {
public ConcourseLanguageServer() {
List<String> commands = new ArrayList<>();
@@ -58,44 +47,6 @@ public class ConcourseLanguageServer 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 = "concourse-language-server-" + Constants.LANGUAGE_SERVER_VERSION + "-SNAPSHOT.jar";
@@ -113,11 +64,6 @@ public class ConcourseLanguageServer 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 );

View File

@@ -4,7 +4,8 @@ Bundle-Name: Eclipse Language Server Commons
Bundle-SymbolicName: org.springframework.tooling.ls.eclipse.commons;singleton:=true
Bundle-Version: 4.0.0.qualifier
Bundle-Vendor: Pivotal, Inc.
Require-Bundle: org.eclipse.ui,
Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.9.0",
org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.lsp4e;bundle-version="0.3.0",
org.eclipse.lsp4j.jsonrpc,

View File

@@ -0,0 +1,89 @@
/*******************************************************************************
* Copyright (c) 2016-2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.tooling.ls.eclipse.commons;
public class ProgressParams {
/**
* An id representing the enitity for which progress messages are to be shown.
*/
private String id;
/**
* Updates the current statusMsg associated with a given the id. If null, then the message
* is cleared.
*/
private String statusMsg;
public ProgressParams() {
}
public ProgressParams(String id, String statusMsg) {
super();
this.id = id;
this.statusMsg = statusMsg;
}
@Override
public String toString() {
return "ProgressParams [id=" + id + ", statusMsg=" + statusMsg + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((statusMsg == null) ? 0 : statusMsg.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ProgressParams other = (ProgressParams) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (statusMsg == null) {
if (other.statusMsg != null)
return false;
} else if (!statusMsg.equals(other.statusMsg))
return false;
return true;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getStatusMsg() {
return statusMsg;
}
public void setStatusMsg(String statusMsg) {
this.statusMsg = statusMsg;
}
}

View File

@@ -23,9 +23,9 @@ public interface STS4LanguageClient extends LanguageClient {
@JsonNotification("sts/highlight")
void highlight(HighlightParams highlights);
// TODO: @JsonNotification("sts/progress")
// void progress(ProgressParams progressEvent);
//
@JsonNotification("sts/progress")
void progress(ProgressParams progressEvent);
// TODO: @JsonRequest("sts/moveCursor")
// CompletableFuture<Object> moveCursor(CursorMovement cursorMovement);

View File

@@ -20,6 +20,7 @@ import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
@@ -147,4 +148,31 @@ public class STS4LanguageClientImpl extends LanguageClientImpl implements STS4La
}
}
@Override
public void progress(ProgressParams progressEvent) {
String status = progressEvent.getStatusMsg() != null ? progressEvent.getStatusMsg() : "";
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;
}
}
}

View File

@@ -0,0 +1,62 @@
/*******************************************************************************
* Copyright (c) 2017 Pivotal, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.tooling.ls.eclipse.commons;
import java.io.File;
import java.io.IOException;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.internal.launching.StandardVMType;
import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider;
@SuppressWarnings("restriction")
public class STS4LanguageServerProcessStreamConnector extends ProcessStreamConnectionProvider {
private static LanguageServerProcessReaper processReaper = new LanguageServerProcessReaper();
@Override
public void start() throws IOException {
super.start();
processReaper.addProcess(LanguageServerProcessReaper.getProcess(this));
}
@Override
public void stop() {
super.stop();
processReaper.removeProcess(LanguageServerProcessReaper.getProcess(this));
}
protected String getJDKLocation() {
try {
File javaHome= new File(System.getProperty("java.home")).getCanonicalFile(); //$NON-NLS-1$
if (javaHome.exists()) {
File javaExecutable = StandardVMType.findJavaExecutable(javaHome);
if (javaExecutable != null && javaExecutable.exists()) {
return javaExecutable.getAbsolutePath();
}
}
} catch (IOException e) {
return null;
}
return null;
}
protected String getToolsJAR() {
File jre = new File(System.getProperty("java.home"));
return new File(jre.getParent(), "lib" + Path.SEPARATOR + "tools.jar").getAbsolutePath();
}
protected String getWorkingDirLocation() {
return System.getProperty("user.dir");
}
}

View File

@@ -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",

View File

@@ -81,6 +81,7 @@
<server
class="org.springframework.tooling.properties.ls.SpringBootPropertiesLanguageServer"
id="org.eclipse.languageserver.languages.springbootproperties"
clientImpl="org.springframework.tooling.ls.eclipse.commons.STS4LanguageClientImpl"
label="Spring Boot Properties Language Server">
</server>
<contentTypeMapping

View File

@@ -12,7 +12,6 @@ package org.springframework.tooling.properties.ls;
import java.io.File;
import java.io.InputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
@@ -21,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 SpringBootPropertiesLanguageServer extends ProcessStreamConnectionProvider {
public class SpringBootPropertiesLanguageServer extends STS4LanguageServerProcessStreamConnector {
public SpringBootPropertiesLanguageServer() {
List<String> commands = new ArrayList<>();
@@ -59,45 +47,6 @@ public class SpringBootPropertiesLanguageServer extends ProcessStreamConnectionP
setWorkingDirectory(workingDir);
}
@Override
public void handleMessage(Message message, LanguageServer languageServer, URI 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 = "boot-properties-language-server-" + Constants.LANGUAGE_SERVER_VERSION + "-SNAPSHOT.jar";
@@ -115,11 +64,6 @@ public class SpringBootPropertiesLanguageServer extends ProcessStreamConnectionP
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 );