AutoConfigure simple language server

It is @ConditionalOnMissingBean so actually this doesn't do anything yet
because  all our language servers still create a SimpleLanguageServer
bean manually.
This commit is contained in:
Kris De Volder
2018-10-04 11:34:22 -07:00
parent 16493cb817
commit b5e0b53170
3 changed files with 24 additions and 2 deletions

View File

@@ -17,6 +17,14 @@ public class LanguageServerProperties {
*/
private int standalonePort = 5007;
/**
* Extension id is a unique identifier associated with a type of language server.
* It is used to derive furether unique ids that should be 'scoped' to a particular
* language server. For example ids for vscode comands used to define code actions
* are derived by appending command names with this id.
*/
private String extensionId;
public boolean isStandalone() {
return standalone;
}
@@ -32,4 +40,13 @@ public class LanguageServerProperties {
public void setStandalonePort(int standalonePort) {
this.standalonePort = standalonePort;
}
public String getExtensionId() {
return extensionId;
}
public void setExtensionId(String extensionId) {
this.extensionId = extensionId;
}
}

View File

@@ -183,6 +183,7 @@ public class SimpleLanguageServer implements Sts4LanguageServer, LanguageClientA
}
public SimpleLanguageServer(String extensionId) {
Assert.isNotNull(extensionId);
this.EXTENSION_ID = extensionId;
this.CODE_ACTION_COMMAND_ID = "sts."+EXTENSION_ID+".codeAction";
}

View File

@@ -10,9 +10,8 @@
*******************************************************************************/
package org.springframework.ide.vscode.languageserver.starter;
import javax.inject.Provider;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -32,4 +31,9 @@ public class LanguageServerAutoconf {
return new LanguageServerRunner(serverName, properties, languageServerFactory);
}
@ConditionalOnMissingBean
@Bean public SimpleLanguageServer languageServer(LanguageServerProperties props) {
return new SimpleLanguageServer(props.getExtensionId());
}
}