Skip to content

Commit e3c511b

Browse files
committed
Support resolution of VS Code predefined variables in settings.
Signed-off-by: Roland Grunberg <[email protected]>
1 parent e4aeb87 commit e3c511b

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1989,7 +1989,8 @@
19891989
"vscode-languageclient": "8.2.0-next.3",
19901990
"winreg-utf8": "^0.1.1",
19911991
"winston": "^3.2.1",
1992-
"winston-daily-rotate-file": "^4.7.1"
1992+
"winston-daily-rotate-file": "^4.7.1",
1993+
"vscode-variables": "^1.0.1"
19931994
},
19941995
"overrides": {
19951996
"vscode-languageserver-protocol": "3.17.6-next.1"

src/javaServerStarter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { logger } from './log';
1111
import { addLombokParam, isLombokSupportEnabled } from './lombokSupport';
1212
import { RequirementsData } from './requirements';
1313
import { IS_WORKSPACE_VMARGS_ALLOWED, getJavaEncoding, getJavaagentFlag, getKey, isInWorkspaceFolder } from './settings';
14-
import { deleteDirectory, ensureExists, getJavaConfiguration, getTimestamp, getVersion } from './utils';
14+
import { deleteDirectory, ensureExists, getJavaConfiguration, getTimestamp, getVersion, getVSCodeVariablesMap } from './utils';
1515
import { log } from 'console';
1616

1717
// eslint-disable-next-line no-var
@@ -39,7 +39,7 @@ const DEPENDENCY_COLLECTOR_IMPL_BF= 'bf';
3939
export function prepareExecutable(requirements: RequirementsData, workspacePath, context: ExtensionContext, isSyntaxServer: boolean): Executable {
4040
const executable: Executable = Object.create(null);
4141
const options: ExecutableOptions = Object.create(null);
42-
options.env = Object.assign({ syntaxserver : isSyntaxServer }, process.env);
42+
options.env = Object.assign({ syntaxserver: isSyntaxServer }, process.env, getVSCodeVariablesMap());
4343
if (os.platform() === 'win32') {
4444
const vmargs = getJavaConfiguration().get('jdt.ls.vmargs', '');
4545
const watchParentProcess = '-DwatchParentProcess=false';

src/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { workspace, WorkspaceConfiguration, commands, Uri, version } from 'vscod
66
import { Commands } from './commands';
77
import { IJavaRuntime } from 'jdk-utils';
88
import { getSupportedJreNames, listJdks, sortJdksBySource, sortJdksByVersion } from './jdkUtils';
9+
const vscodeVariables = require('vscode-variables');
910

1011
export function getJavaConfiguration(): WorkspaceConfiguration {
1112
return workspace.getConfiguration('java');
@@ -347,3 +348,12 @@ export function getVersion(extensionPath: string): string {
347348

348349
return '0.0.0';
349350
}
351+
352+
export function getVSCodeVariablesMap(): any {
353+
const keys = [
354+
"userHome", "workspaceFolder", "workspaceFolderBasename"
355+
];
356+
const res = {};
357+
keys.forEach(key => res[key] = vscodeVariables(`\${${key}}`));
358+
return res;
359+
}

0 commit comments

Comments
 (0)