提交 d452f8d2 编写于 作者: D Don Jayamanne

changes to replace settings variables in launch config #8042

上级 e170425f
......@@ -130,7 +130,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables {
public resolve(value: IStringDictionary<IStringDictionary<string>>): IStringDictionary<IStringDictionary<string>>;
public resolve(value: any): any {
if (Types.isString(value)) {
return this.__resolveString(value);
return this.resolveString(value);
} else if (Types.isArray(value)) {
return this.__resolveArray(value);
} else if (Types.isObject(value)) {
......@@ -143,7 +143,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables {
resolveAny<T>(value: T): T;
resolveAny<T>(value: any): any {
if (Types.isString(value)) {
return this.__resolveString(value);
return this.resolveString(value);
} else if (Types.isArray(value)) {
return this.__resolveAnyArray(value);
} else if (Types.isObject(value)) {
......@@ -153,7 +153,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables {
return value;
}
private __resolveString(value: string): string {
protected resolveString(value: string): string {
let regexp = /\$\{(.*?)\}/g;
return value.replace(regexp, (match: string, name: string) => {
let newValue = (<any>this)[name];
......@@ -185,7 +185,7 @@ export abstract class AbstractSystemVariables implements ISystemVariables {
}
private __resolveArray(value: string[]): string[] {
return value.map(s => this.__resolveString(s));
return value.map(s => this.resolveString(s));
}
private __resolveAnyArray<T>(value: T[]): T[];
......
......@@ -30,6 +30,7 @@ import { Adapter } from 'vs/workbench/parts/debug/node/debugAdapter';
import { IWorkspaceContextService } from 'vs/workbench/services/workspace/common/contextService';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IQuickOpenService } from 'vs/workbench/services/quickopen/common/quickOpenService';
import { SettingsVariables } from 'vs/workbench/parts/lib/node/settingsVariables';
// debuggers extension point
......@@ -155,6 +156,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
public configuration: debug.IConfig;
private systemVariables: SystemVariables;
private settingsVariables: SettingsVariables;
private adapters: Adapter[];
private allModeIdsForBreakpoints: { [key: string]: boolean };
private _onDidConfigurationChange: Emitter<string>;
......@@ -171,6 +173,7 @@ export class ConfigurationManager implements debug.IConfigurationManager {
) {
this._onDidConfigurationChange = new Emitter<string>();
this.systemVariables = this.contextService.getWorkspace() ? new SystemVariables(this.editorService, this.contextService) : null;
this.settingsVariables = new SettingsVariables(this.configurationService.getConfiguration<any>());
this.setConfiguration(configName);
this.adapters = [];
this.registerListeners();
......@@ -326,6 +329,12 @@ export class ConfigurationManager implements debug.IConfigurationManager {
this.configuration[key] = this.systemVariables.resolveAny(this.configuration[key]);
});
}
// massage configuration attributes - substitute settings (from settings.json) variables.
if (this.systemVariables) {
Object.keys(this.configuration).forEach(key => {
this.configuration[key] = this.settingsVariables.resolveAny(this.configuration[key]);
});
}
}
}).then(() => this._onDidConfigurationChange.fire(this.configurationName));
}
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { AbstractSystemVariables } from 'vs/base/common/parsers';
export class SettingsVariables extends AbstractSystemVariables {
constructor(private configuration:any) {
super();
}
protected resolveString(value: string): string {
let regexp = /\${settings.(.+)}/g;
return value.replace(regexp, (match: string, name: string) => {
return new Function('_', 'return _.' + name)(this.configuration);
});
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册