Remove LANGUAGE_SERVER_VERSION constants...
... instead assume that language server version matches Eclipse bundle version. Also streamline code for finding server jar locations so it is no longer duplicated across every language server bundle.
This commit is contained in:
@@ -12,23 +12,15 @@ package org.springframework.tooling.cloudfoundry.manifest.ls;
|
||||
|
||||
import static org.springframework.tooling.ls.eclipse.commons.preferences.LanguageServerConsolePreferenceConstants.CLOUDFOUNDRY_SERVER;
|
||||
|
||||
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.List;
|
||||
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.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.JRE;
|
||||
import org.springframework.tooling.ls.eclipse.commons.STS4LanguageServerProcessStreamConnector;
|
||||
|
||||
@@ -89,50 +81,6 @@ public class CloudFoundryManifestLanguageServer extends STS4LanguageServerProces
|
||||
return cfTargetOptionSettings;
|
||||
}
|
||||
|
||||
protected String getLanguageServerJARLocation() {
|
||||
String languageServer = "manifest-yaml-language-server-" + Constants.LANGUAGE_SERVER_VERSION;
|
||||
|
||||
Bundle bundle = Platform.getBundle(Constants.PLUGIN_ID);
|
||||
String bundleVersion = bundle.getVersion().toString();
|
||||
|
||||
String languageServerLocalCopy = bundleVersion + "-" + languageServer;
|
||||
|
||||
File dataFile = bundle.getDataFile(languageServerLocalCopy);
|
||||
|
||||
Exception error = null;
|
||||
if (!dataFile.exists() || bundleVersion.endsWith("qualifier")) { // qualifier check to get the language server always copied in dev mode
|
||||
try {
|
||||
copyLanguageServerJAR(languageServer, languageServerLocalCopy);
|
||||
}
|
||||
catch (Exception e) {
|
||||
error = e;
|
||||
}
|
||||
}
|
||||
|
||||
if (bundleVersion.endsWith("qualifier")) {
|
||||
File userHome = new File(System.getProperty("user.home"));
|
||||
File locallyBuiltJar = new File(
|
||||
userHome,
|
||||
"git/sts4/headless-services/manifest-yaml-language-server/target/manifest-yaml-language-server-" + Constants.LANGUAGE_SERVER_VERSION
|
||||
);
|
||||
if (locallyBuiltJar.exists()) {
|
||||
return locallyBuiltJar.getAbsolutePath();
|
||||
}
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
return dataFile.getAbsolutePath();
|
||||
}
|
||||
|
||||
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 );
|
||||
|
||||
File dataFile = bundle.getDataFile(languageServerLocalCopy);
|
||||
Files.copy(stream, dataFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
protected void updateLanguageServer() {
|
||||
DidChangeConfigurationParams params = new DidChangeConfigurationParams(getInitializationOptions(rootPath));
|
||||
languageServer.getWorkspaceService().didChangeConfiguration(params);
|
||||
@@ -146,4 +94,13 @@ public class CloudFoundryManifestLanguageServer extends STS4LanguageServerProces
|
||||
servers.remove(server);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLanguageServerArtifactId() {
|
||||
return "manifest-yaml-language-server";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPluginId() {
|
||||
return Constants.PLUGIN_ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,5 @@ package org.springframework.tooling.cloudfoundry.manifest.ls;
|
||||
public class Constants {
|
||||
|
||||
public static final String PLUGIN_ID = "org.springframework.tooling.cloudfoundry.manifest.ls";
|
||||
public static final String LANGUAGE_SERVER_VERSION = "1.7.0-SNAPSHOT.jar";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user