From 6a424fd9e981683170041dffe1e9df7e22330037 Mon Sep 17 00:00:00 2001 From: Luke Aguilar Date: Sun, 29 Mar 2026 22:43:50 +1100 Subject: [PATCH 1/2] Add support for vscode expansions Signed-off-by: Luke Aguilar --- src/settings.ts | 4 ++-- src/utils.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/settings.ts b/src/settings.ts index 1e3330ed2..eee8d8367 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -5,7 +5,7 @@ import * as path from 'path'; import { commands, ConfigurationTarget, env, ExtensionContext, Position, Range, Selection, SnippetString, TextDocument, Uri, window, workspace, WorkspaceConfiguration, WorkspaceFolder } from 'vscode'; import { Commands } from './commands'; import { cleanupLombokCache } from './lombokSupport'; -import { ensureExists, getJavaConfiguration } from './utils'; +import { ensureExists, getJavaConfiguration, resolvePathVariables } from './utils'; import { apiManager } from './apiManager'; import { isActive, setActive, smartSemicolonDetection } from './smartSemicolonDetection'; import { BuildFileSelector, IMPORT_METHOD, PICKED_BUILD_FILES } from './buildFilesSelector'; @@ -242,7 +242,7 @@ export async function checkJavaPreferences(context: ExtensionContext): Promise<{ } return { - javaHome, + javaHome: resolvePathVariables(javaHome), preference }; } diff --git a/src/utils.ts b/src/utils.ts index 02a0becd5..4ebee6b97 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -284,6 +284,8 @@ export async function getJavaConfig(javaHome: string) { javaConfig.implementationCodeLens = deprecatedImplementations ? "types" : "none"; } + javaConfig.import.gradle.java.home = resolvePathVariables(javaConfig.import.gradle.java.home); + return javaConfig; } @@ -363,6 +365,18 @@ export function getVSCodeVariablesMap(): any { return res; } +export function resolvePathVariables(pathStr: string): string { + if (!pathStr) { + return pathStr; + } + const requiresWorkspace = pathStr.includes('${workspaceFolder}') || + pathStr.includes('${workspaceFolderBasename}'); + if (requiresWorkspace && !workspace.workspaceFolders?.length) { + return pathStr; + } + return vscodeVariables(pathStr); +} + /** * Check if the extension version is a pre-release version or running an insider editor. * @param context The extension context or extension path From 4ff5418c4fe27058ca9dc0a946d4a0a8d808b74d Mon Sep 17 00:00:00 2001 From: Luke Aguilar Date: Sun, 29 Mar 2026 22:49:51 +1100 Subject: [PATCH 2/2] simplified Signed-off-by: Luke Aguilar --- src/utils.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 4ebee6b97..7b3a739c0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -369,11 +369,6 @@ export function resolvePathVariables(pathStr: string): string { if (!pathStr) { return pathStr; } - const requiresWorkspace = pathStr.includes('${workspaceFolder}') || - pathStr.includes('${workspaceFolderBasename}'); - if (requiresWorkspace && !workspace.workspaceFolders?.length) { - return pathStr; - } return vscodeVariables(pathStr); }