Allow overriding vscode language server options
JAVA_HOME and heap can now be overridden by the user from vscode worspace settings, in a similar way for all our language servers, by setting XXX.java.home and XXX.java.heap configuration keys.
This commit is contained in:
@@ -31,13 +31,14 @@ export interface ActivatorOptions {
|
||||
extensionId: string;
|
||||
clientOptions: LanguageClientOptions;
|
||||
jvmHeap?: string;
|
||||
workspaceOptions?: VSCode.WorkspaceConfiguration;
|
||||
workspaceOptions: VSCode.WorkspaceConfiguration;
|
||||
checkjvm?: (context: VSCode.ExtensionContext, jvm: JVM) => any;
|
||||
preferJdk?: boolean;
|
||||
}
|
||||
|
||||
type JavaOptions = {
|
||||
heap?: string
|
||||
home?: string
|
||||
}
|
||||
|
||||
function getUserDefinedJvmHeap(wsOpts : VSCode.WorkspaceConfiguration, dflt : string) : string {
|
||||
@@ -48,6 +49,14 @@ function getUserDefinedJvmHeap(wsOpts : VSCode.WorkspaceConfiguration, dflt : s
|
||||
return (javaOptions && javaOptions.heap) || dflt;
|
||||
}
|
||||
|
||||
function getUserDefinedJavaHome(wsOpts : VSCode.WorkspaceConfiguration) : string {
|
||||
if (!wsOpts) {
|
||||
return null;
|
||||
}
|
||||
let javaOptions : JavaOptions = wsOpts.get("java");
|
||||
return javaOptions && javaOptions.home;
|
||||
}
|
||||
|
||||
export function activate(options: ActivatorOptions, context: VSCode.ExtensionContext): Thenable<LanguageClient> {
|
||||
let DEBUG = options.DEBUG;
|
||||
let jvmHeap = getUserDefinedJvmHeap(options.workspaceOptions, options.jvmHeap);
|
||||
@@ -74,7 +83,7 @@ export function activate(options: ActivatorOptions, context: VSCode.ExtensionCon
|
||||
|
||||
let findJRE = options.preferJdk ? findJdk : findJvm;
|
||||
|
||||
return findJRE()
|
||||
return findJRE(getUserDefinedJavaHome(options.workspaceOptions))
|
||||
.catch(error => {
|
||||
VSCode.window.showErrorMessage("Error trying to find JVM: "+error);
|
||||
return Promise.reject(error);
|
||||
|
||||
Reference in New Issue
Block a user