Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@
"dependencies": {
"await-lock": "^2.2.2",
"jdk-utils": "^0.4.4",
"vscode-variables": "^1.0.1",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it a package officially support by microsoft?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe so, source: https://github.com/DominicVonk/vscode-variables

I can implement the replacement logic manually if preferred, it's straightforward for simple cases like ${workspaceFolder} but vscode-variables does a good job at providing full functionality especially supporting multi root to end users

Copy link
Copy Markdown
Contributor

@chagong chagong Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if you can implement "resolve variables" in our repo. I think it only needs to resolve paths, no need to include commands & config stuff. Resolve commands might have some security concern.

"fs-extra": "^11.1.0",
"get-port": "^5.1.1",
"lodash": "^4.17.23",
Expand Down
15 changes: 12 additions & 3 deletions extension/src/util/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ import { RootProject } from "../rootProject/RootProject";
import * as fse from "fs-extra";
import * as path from "path";
import { findDefaultRuntimeFromSettings, getMajorVersion, listJdks } from "./jdkUtils";
const vscodeVariables = require('vscode-variables');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use import syntax

type AutoDetect = "on" | "off";

export function resolvePathVariables(pathStr: string | null): string | null {
if (!pathStr) {
return pathStr;
}
return vscodeVariables(pathStr);
}

export const REQUIRED_JDK_VERSION = 17;

export function getConfigIsAutoDetectionEnabled(rootProject: RootProject): boolean {
Expand All @@ -26,7 +35,7 @@ export function getJdtlsConfigJavaHome(): string | null {
}

export function getConfigJavaImportGradleJavaHome(): string | null {
return vscode.workspace.getConfiguration("java").get<string | null>("import.gradle.java.home", null);
return resolvePathVariables(vscode.workspace.getConfiguration("java").get<string | null>("import.gradle.java.home", null));
}

export function getJavaExecutablePathFromJavaHome(javaHome: string): string {
Expand Down Expand Up @@ -105,7 +114,7 @@ export function checkEnvJavaExecutable(): boolean {
}

export function getConfigJavaImportGradleUserHome(): string | null {
return vscode.workspace.getConfiguration("java").get<string | null>("import.gradle.user.home", null);
return resolvePathVariables(vscode.workspace.getConfiguration("java").get<string | null>("import.gradle.user.home", null));
}

export function getConfigJavaImportGradleJvmArguments(): string | null {
Expand All @@ -121,7 +130,7 @@ export function getConfigJavaImportGradleVersion(): string | null {
}

export function getConfigJavaImportGradleHome(): string | null {
return vscode.workspace.getConfiguration("java").get<string | null>("import.gradle.home", null);
return resolvePathVariables(vscode.workspace.getConfiguration("java").get<string | null>("import.gradle.home", null));
}

export function getConfigIsDebugEnabled(): boolean {
Expand Down
Loading