Skip to content

Commit 5643a2e

Browse files
authored
java server refreshing the workspace for each restart on Windows (#880)
Signed-off-by: Snjezana Peco <[email protected]> Signed-off-by: Snjezana Peco <[email protected]>
1 parent 6b37ba4 commit 5643a2e

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/javaServerStarter.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11

2-
import * as path from 'path';
3-
import * as net from 'net';
2+
import * as fs from 'fs';
43
import * as glob from 'glob';
4+
import * as net from 'net';
55
import * as os from 'os';
6-
import * as fs from 'fs';
7-
import { StreamInfo, Executable, ExecutableOptions } from 'vscode-languageclient/node';
8-
import { RequirementsData } from './requirements';
9-
import { getJavaEncoding, IS_WORKSPACE_VMARGS_ALLOWED, getKey, getJavaagentFlag, isInWorkspaceFolder } from './settings';
6+
import * as path from 'path';
7+
import { ExtensionContext, workspace } from 'vscode';
8+
import { Executable, ExecutableOptions, StreamInfo } from 'vscode-languageclient/node';
109
import { logger } from './log';
11-
import { getJavaConfiguration, deleteDirectory, ensureExists, getTimestamp } from './utils';
12-
import { workspace, ExtensionContext, window } from 'vscode';
1310
import { addLombokParam, isLombokSupportEnabled } from './lombokSupport';
11+
import { RequirementsData } from './requirements';
12+
import { getJavaagentFlag, getJavaEncoding, getKey, isInWorkspaceFolder, IS_WORKSPACE_VMARGS_ALLOWED } from './settings';
13+
import { deleteDirectory, ensureExists, getJavaConfiguration, getTimestamp } from './utils';
1414

1515
// eslint-disable-next-line no-var
1616
declare var v8debug;
@@ -30,6 +30,13 @@ export function prepareExecutable(requirements: RequirementsData, workspacePath,
3030
const executable: Executable = Object.create(null);
3131
const options: ExecutableOptions = Object.create(null);
3232
options.env = Object.assign({ syntaxserver : isSyntaxServer }, process.env);
33+
if (os.platform() === 'win32') {
34+
const vmargs = getJavaConfiguration().get('jdt.ls.vmargs', '');
35+
const watchParentProcess = '-DwatchParentProcess=false';
36+
if (vmargs.indexOf(watchParentProcess) < 0) {
37+
options.detached = true;
38+
}
39+
}
3340
executable.options = options;
3441
executable.command = path.resolve(`${requirements.tooling_jre}/bin/java`);
3542
executable.args = prepareParams(requirements, javaConfig, workspacePath, context, isSyntaxServer);
@@ -106,12 +113,6 @@ function prepareParams(requirements: RequirementsData, javaConfiguration, worksp
106113
if (vmargs.indexOf(encodingKey) < 0) {
107114
params.push(encodingKey + getJavaEncoding());
108115
}
109-
if (os.platform() === 'win32') {
110-
const watchParentProcess = '-DwatchParentProcess=';
111-
if (vmargs.indexOf(watchParentProcess) < 0) {
112-
params.push(`${watchParentProcess}false`);
113-
}
114-
}
115116
if (vmargs.indexOf('-Xlog:') < 0) {
116117
params.push('-Xlog:disable');
117118
}

0 commit comments

Comments
 (0)