Skip to content
Merged
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
23 changes: 23 additions & 0 deletions src/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import { logger, Type } from "./logger";
import * as utility from "./utility";
import { VariableResolver } from "./variableResolver";

const platformNameMappings = {
win32: "windows",
linux: "linux",
darwin: "osx",
};
const platformName = platformNameMappings[process.platform];

export class JavaDebugConfigurationProvider implements vscode.DebugConfigurationProvider {
private isUserSettingsDirty: boolean = true;
private debugHistory: MostRecentlyUsedHistory = new MostRecentlyUsedHistory();
Expand Down Expand Up @@ -46,6 +53,9 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
vscode.ProviderResult<vscode.DebugConfiguration> {
const resolveDebugConfigurationHandler = instrumentOperation("resolveDebugConfiguration", (operationId: string) => {
try {
// See https://github.com/microsoft/vscode-java-debug/issues/778
// Merge the platform specific properties to the global config to simplify the subsequent resolving logic.
this.mergePlatformProperties(folder, config);
this.resolveVariables(folder, config);
return this.heuristicallyResolveDebugConfiguration(folder, config);
} catch (ex) {
Expand Down Expand Up @@ -93,6 +103,19 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
});
}

private mergePlatformProperties(folder: vscode.WorkspaceFolder, config: vscode.DebugConfiguration) {
if (config && platformName && config[platformName]) {
try {
for (const key of Object.keys(config[platformName])) {
config[key] = config[platformName][key];
}
config[platformName] = undefined;
} catch {
// do nothing
}
}
}

private resolveVariables(folder: vscode.WorkspaceFolder, config: vscode.DebugConfiguration): void {
// all the properties whose values are string or array of string
const keys = ["mainClass", "args", "vmArgs", "modulePaths", "classPaths", "projectName",
Expand Down