Skip to content

Commit 6a424fd

Browse files
committed
Add support for vscode expansions
Signed-off-by: Luke Aguilar <dev@rdxip.com>
1 parent 4f862f5 commit 6a424fd

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'path';
55
import { commands, ConfigurationTarget, env, ExtensionContext, Position, Range, Selection, SnippetString, TextDocument, Uri, window, workspace, WorkspaceConfiguration, WorkspaceFolder } from 'vscode';
66
import { Commands } from './commands';
77
import { cleanupLombokCache } from './lombokSupport';
8-
import { ensureExists, getJavaConfiguration } from './utils';
8+
import { ensureExists, getJavaConfiguration, resolvePathVariables } from './utils';
99
import { apiManager } from './apiManager';
1010
import { isActive, setActive, smartSemicolonDetection } from './smartSemicolonDetection';
1111
import { BuildFileSelector, IMPORT_METHOD, PICKED_BUILD_FILES } from './buildFilesSelector';
@@ -242,7 +242,7 @@ export async function checkJavaPreferences(context: ExtensionContext): Promise<{
242242
}
243243

244244
return {
245-
javaHome,
245+
javaHome: resolvePathVariables(javaHome),
246246
preference
247247
};
248248
}

src/utils.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ export async function getJavaConfig(javaHome: string) {
284284
javaConfig.implementationCodeLens = deprecatedImplementations ? "types" : "none";
285285
}
286286

287+
javaConfig.import.gradle.java.home = resolvePathVariables(javaConfig.import.gradle.java.home);
288+
287289
return javaConfig;
288290
}
289291

@@ -363,6 +365,18 @@ export function getVSCodeVariablesMap(): any {
363365
return res;
364366
}
365367

368+
export function resolvePathVariables(pathStr: string): string {
369+
if (!pathStr) {
370+
return pathStr;
371+
}
372+
const requiresWorkspace = pathStr.includes('${workspaceFolder}') ||
373+
pathStr.includes('${workspaceFolderBasename}');
374+
if (requiresWorkspace && !workspace.workspaceFolders?.length) {
375+
return pathStr;
376+
}
377+
return vscodeVariables(pathStr);
378+
}
379+
366380
/**
367381
* Check if the extension version is a pre-release version or running an insider editor.
368382
* @param context The extension context or extension path

0 commit comments

Comments
 (0)