Add support to vscode-spring-boot for custom vm args
This commit is contained in:
@@ -41,6 +41,7 @@ export interface ActivatorOptions {
|
||||
type JavaOptions = {
|
||||
heap?: string
|
||||
home?: string
|
||||
vmargs?: string[]
|
||||
}
|
||||
|
||||
function getUserDefinedJvmHeap(wsOpts : VSCode.WorkspaceConfiguration, dflt : string) : string {
|
||||
@@ -51,6 +52,15 @@ function getUserDefinedJvmHeap(wsOpts : VSCode.WorkspaceConfiguration, dflt : s
|
||||
return (javaOptions && javaOptions.heap) || dflt;
|
||||
}
|
||||
|
||||
function getUserDefinedJvmArgs(wsOpts : VSCode.WorkspaceConfiguration) : string[] {
|
||||
const dflt = [];
|
||||
if (!wsOpts) {
|
||||
return dflt;
|
||||
}
|
||||
let javaOptions : JavaOptions = wsOpts.get("java");
|
||||
return javaOptions && javaOptions.vmargs || dflt;
|
||||
}
|
||||
|
||||
function getUserDefinedJavaHome(wsOpts : VSCode.WorkspaceConfiguration) : string {
|
||||
if (!wsOpts) {
|
||||
return null;
|
||||
@@ -62,6 +72,7 @@ function getUserDefinedJavaHome(wsOpts : VSCode.WorkspaceConfiguration) : string
|
||||
export function activate(options: ActivatorOptions, context: VSCode.ExtensionContext): Thenable<LanguageClient> {
|
||||
let DEBUG = options.DEBUG;
|
||||
let jvmHeap = getUserDefinedJvmHeap(options.workspaceOptions, options.jvmHeap);
|
||||
let jvmArgs = getUserDefinedJvmArgs(options.workspaceOptions);
|
||||
if (options.CONNECT_TO_LS) {
|
||||
return VSCode.window.showInformationMessage("Start language server")
|
||||
.then((x) => connectToLS(context, options));
|
||||
@@ -132,9 +143,12 @@ export function activate(options: ActivatorOptions, context: VSCode.ExtensionCon
|
||||
if (options.checkjvm) {
|
||||
options.checkjvm(context, jvm);
|
||||
}
|
||||
if (jvmHeap) {
|
||||
if (jvmHeap && !hasHeapArg(jvmArgs)) {
|
||||
args.unshift("-Xmx"+jvmHeap);
|
||||
}
|
||||
if (jvmArgs) {
|
||||
args.unshift(...jvmArgs);
|
||||
}
|
||||
if (DEBUG) {
|
||||
args.unshift(DEBUG_ARG);
|
||||
}
|
||||
@@ -157,6 +171,13 @@ export function activate(options: ActivatorOptions, context: VSCode.ExtensionCon
|
||||
}
|
||||
}
|
||||
|
||||
function hasHeapArg(vmargs?: string[]) : boolean {
|
||||
if (vmargs) {
|
||||
return vmargs.some(a => a.startsWith("-Xmx"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function findServerJar(jarsDir) : string {
|
||||
let serverJars = FS.readdirSync(jarsDir).filter(jar =>
|
||||
jar.indexOf('language-server')>=0 &&
|
||||
@@ -171,7 +192,6 @@ function findServerJar(jarsDir) : string {
|
||||
return Path.resolve(jarsDir, serverJars[0]);
|
||||
}
|
||||
|
||||
|
||||
function connectToLS(context: VSCode.ExtensionContext, options: ActivatorOptions): Promise<LanguageClient> {
|
||||
let connectionInfo = {
|
||||
port: 5007
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "vscode-spring-boot",
|
||||
"version": "1.5.0",
|
||||
"version": "1.6.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@pivotal-tools/commons-vscode": {
|
||||
"version": "file:../commons-vscode/pivotal-tools-commons-vscode-0.2.2.tgz",
|
||||
"integrity": "sha512-OTvqzfrIjJ2f5CkT9CZomCiOVx4vz4vViDhYV3zRtG27fD+tWeD2smnPOjRupBrRwqdOKuZY8ztLFX6rJu854w==",
|
||||
"integrity": "sha512-hgbMlJKDCkG3xQsTNEKFcGgic/zuSkkqRD2HOx5xeHbPdFAuQbv7eXNNFRxaw1cLU8re/s4gHWAa56bESqP5RQ==",
|
||||
"requires": {
|
||||
"@pivotal-tools/jvm-launch-utils": "0.0.11",
|
||||
"deep-equal": "^1.0.1",
|
||||
|
||||
@@ -127,6 +127,13 @@
|
||||
],
|
||||
"default": null,
|
||||
"description": "Max JVM heap value, passed via -Xmx argument when launching spring-boot-language-server JVM process."
|
||||
},
|
||||
"spring-boot.ls.java.vmargs": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Additional 'user defined' VM args to pass to the language server process."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user