diff --git a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts index a1d7ac57cda..edab286ff8b 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts @@ -46,7 +46,7 @@ export class MainThreadDebugService extends MainThreadDebugServiceShape { } public $startDebugging(folderUri: URI | undefined, nameOrConfiguration: string | IConfig): TPromise { - return this.debugService.startDebugging(nameOrConfiguration).then(x => { + return this.debugService.startDebugging(folderUri, nameOrConfiguration).then(x => { return true; }, err => { return TPromise.wrapError(err && err.message ? err.message : 'cannot start debugging'); @@ -57,7 +57,7 @@ export class MainThreadDebugService extends MainThreadDebugServiceShape { if (configuration.request !== 'launch' && configuration.request !== 'attach') { return TPromise.wrapError(new Error(`only 'launch' or 'attach' allowed for 'request' attribute`)); } - return this.debugService.createProcess(configuration).then(process => { + return this.debugService.createProcess(folderUri, configuration).then(process => { if (process) { return process.getId(); } diff --git a/src/vs/workbench/parts/debug/browser/debugActions.ts b/src/vs/workbench/parts/debug/browser/debugActions.ts index 53ecce9c344..a5c7a86a91f 100644 --- a/src/vs/workbench/parts/debug/browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/browser/debugActions.ts @@ -124,7 +124,7 @@ export class StartAction extends AbstractDebugAction { } public run(): TPromise { - return this.debugService.startDebugging(undefined, this.isNoDebug()); + return this.debugService.startDebugging(undefined, undefined, this.isNoDebug()); } protected isNoDebug(): boolean { diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 093b30398ce..bb45ac9becc 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -87,6 +87,7 @@ export interface IExpression extends IReplElement, IExpressionContainer { } export interface ISession { + root: uri; stackTrace(args: DebugProtocol.StackTraceArguments): TPromise; exceptionInfo(args: DebugProtocol.ExceptionInfoArguments): TPromise; scopes(args: DebugProtocol.ScopesArguments): TPromise; @@ -385,7 +386,7 @@ export interface IConfigurationManager { selectedName: string; - selectConfiguration(launch: ILaunch, name: string): void; + selectConfiguration(launch: ILaunch, name?: string): void; getLaunches(): ILaunch[]; @@ -564,12 +565,12 @@ export interface IDebugService { * Also saves all files, manages if compounds are present in the configuration * and calls the startSessionCommand if an adapter registered it. */ - startDebugging(configOrName?: IConfig | string, noDebug?: boolean): TPromise; + startDebugging(root?: uri, configOrName?: IConfig | string, noDebug?: boolean): TPromise; /** * Creates a new debug process. Depending on the configuration will either 'launch' or 'attach'. */ - createProcess(config: IConfig): TPromise; + createProcess(root: uri, config: IConfig): TPromise; /** * Find process by ID. diff --git a/src/vs/workbench/parts/debug/electron-browser/debugCommands.ts b/src/vs/workbench/parts/debug/electron-browser/debugCommands.ts index 378881a76fd..49d609d43a4 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugCommands.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugCommands.ts @@ -32,9 +32,9 @@ export function registerCommands(): void { } if (typeof configurationOrName === 'string') { - debugService.startDebugging(configurationOrName); + debugService.startDebugging(undefined, configurationOrName); } else { - debugService.createProcess(configurationOrName); + debugService.createProcess(undefined, configurationOrName); } }, when: CONTEXT_NOT_IN_DEBUG_MODE, diff --git a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts index 6bd50613f98..b8ae42b7d62 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts @@ -311,9 +311,11 @@ export class ConfigurationManager implements IConfigurationManager { return this._onDidSelectConfigurationName.event; } - public selectConfiguration(launch: ILaunch, name: string): void { + public selectConfiguration(launch: ILaunch, name?: string): void { this._selectedLaunch = launch; - this._selectedName = name; + if (name) { + this._selectedName = name; + } this.storageService.store(DEBUG_SELECTED_CONFIG_NAME_KEY, this.selectedName, StorageScope.WORKSPACE); if (launch) { this.storageService.store(DEBUG_SELECTED_ROOT, this.contextService.getRoot(launch.uri).toString(), StorageScope.WORKSPACE); @@ -449,7 +451,7 @@ class Launch implements ILaunch { // massage configuration attributes - append workspace path to relatvie paths, substitute variables in paths. Object.keys(result).forEach(key => { - result[key] = this.configurationResolverService.resolveAny(result[key]); + result[key] = this.configurationResolverService.resolveAny(this.workspaceUri, result[key]); }); const adapter = this.configurationManager.getAdapter(result.type); diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index d005eeaac70..0329bee9573 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -175,7 +175,7 @@ export class DebugService implements debug.IDebugService { this.configurationManager.selectedLaunch.resolveConfiguration(config).done(resolvedConfig => { resolvedConfig.request = 'attach'; resolvedConfig.port = broadcast.payload.port; - this.doCreateProcess(resolvedConfig, broadcast.payload.debugId); + this.doCreateProcess(this.configurationManager.selectedLaunch.workspaceUri, resolvedConfig, broadcast.payload.debugId); }, errors.onUnexpectedError); return; @@ -636,14 +636,7 @@ export class DebugService implements debug.IDebugService { this.model.removeWatchExpressions(id); } - public startDebugging(configOrName?: debug.IConfig | string, noDebug = false): TPromise { - - // temporary workaround: the folderUri should be an argument to startDebugging - let folderUri: uri = undefined; - const workspace = this.contextService.getWorkspace(); - if (workspace && workspace.roots.length > 0) { - folderUri = workspace.roots[0]; - } + public startDebugging(root?: uri, configOrName?: debug.IConfig | string, noDebug = false): TPromise { // make sure to save all files and that the configuration is up to date return this.textFileService.saveAll().then(() => this.configurationService.reloadConfiguration().then(() => @@ -653,14 +646,15 @@ export class DebugService implements debug.IDebugService { } this.launchJsonChanged = false; const manager = this.getConfigurationManager(); - let config: debug.IConfig, compound: debug.ICompound; + const launch = !root ? manager.selectedLaunch : manager.getLaunches().filter(l => l.workspaceUri.toString() === root.toString()).pop(); + let config: debug.IConfig, compound: debug.ICompound; if (!configOrName) { configOrName = this.configurationManager.selectedName; } - if (typeof configOrName === 'string' && manager.selectedLaunch) { - config = manager.selectedLaunch.getConfiguration(configOrName); - compound = manager.selectedLaunch.getCompound(configOrName); + if (typeof configOrName === 'string' && launch) { + config = launch.getConfiguration(configOrName); + compound = launch.getCompound(configOrName); } else if (typeof configOrName !== 'string') { config = configOrName; } @@ -671,7 +665,7 @@ export class DebugService implements debug.IDebugService { "Compound must have \"configurations\" attribute set in order to start multiple configurations."))); } - return TPromise.join(compound.configurations.map(name => name !== compound.name ? this.startDebugging(name) : TPromise.as(null))); + return TPromise.join(compound.configurations.map(name => name !== compound.name ? this.startDebugging(root, name) : TPromise.as(null))); } if (configOrName && !config) { return TPromise.wrapError(new Error(nls.localize('configMissing', "Configuration '{0}' is missing in 'launch.json'.", configOrName))); @@ -681,17 +675,16 @@ export class DebugService implements debug.IDebugService { if (noDebug && config) { config.noDebug = true; } - const selectedLaunch = manager.selectedLaunch; if (commandAndType && commandAndType.command) { const defaultConfig = noDebug ? { noDebug: true } : {}; - return this.commandService.executeCommand(commandAndType.command, config || defaultConfig, selectedLaunch.workspaceUri).then((result: StartSessionResult) => { - if (selectedLaunch) { + return this.commandService.executeCommand(commandAndType.command, config || defaultConfig, launch ? launch.workspaceUri : undefined).then((result: StartSessionResult) => { + if (launch) { if (result && result.status === 'initialConfiguration') { - return selectedLaunch.openConfigFile(false, commandAndType.type); + return launch.openConfigFile(false, commandAndType.type); } if (result && result.status === 'saveConfiguration') { - return this.fileService.updateContent(selectedLaunch.uri, result.content).then(() => selectedLaunch.openConfigFile(false)); + return this.fileService.updateContent(launch.uri, result.content).then(() => launch.openConfigFile(false)); } } return undefined; @@ -699,10 +692,10 @@ export class DebugService implements debug.IDebugService { } if (config) { - return this.createProcess(config); + return this.createProcess(root, config); } - if (selectedLaunch && commandAndType) { - return selectedLaunch.openConfigFile(false, commandAndType.type); + if (launch && commandAndType) { + return launch.openConfigFile(false, commandAndType.type); } return undefined; @@ -720,7 +713,7 @@ export class DebugService implements debug.IDebugService { return null; } - public createProcess(config: debug.IConfig): TPromise { + public createProcess(root: uri, config: debug.IConfig): TPromise { return this.textFileService.saveAll().then(() => (this.configurationManager.selectedLaunch ? this.configurationManager.selectedLaunch.resolveConfiguration(config) : TPromise.as(config)).then(resolvedConfig => { if (!resolvedConfig) { @@ -739,7 +732,7 @@ export class DebugService implements debug.IDebugService { const successExitCode = taskSummary && taskSummary.exitCode === 0; const failureExitCode = taskSummary && taskSummary.exitCode !== undefined && taskSummary.exitCode !== 0; if (successExitCode || (errorCount === 0 && !failureExitCode)) { - return this.doCreateProcess(resolvedConfig); + return this.doCreateProcess(root, resolvedConfig); } this.messageService.show(severity.Error, { @@ -749,7 +742,7 @@ export class DebugService implements debug.IDebugService { actions: [ new Action('debug.continue', nls.localize('debugAnyway', "Debug Anyway"), null, true, () => { this.messageService.hideAll(); - return this.doCreateProcess(resolvedConfig); + return this.doCreateProcess(root, resolvedConfig); }), this.instantiationService.createInstance(ToggleMarkersPanelAction, ToggleMarkersPanelAction.ID, ToggleMarkersPanelAction.LABEL), CloseAction @@ -780,7 +773,7 @@ export class DebugService implements debug.IDebugService { ); } - private doCreateProcess(configuration: debug.IConfig, sessionId = generateUuid()): TPromise { + private doCreateProcess(root: uri, configuration: debug.IConfig, sessionId = generateUuid()): TPromise { configuration.__sessionId = sessionId; this.allSessionIds.add(sessionId); this.updateStateAndEmit(sessionId, debug.State.Initializing); @@ -818,7 +811,7 @@ export class DebugService implements debug.IDebugService { this.customTelemetryService = new TelemetryService({ appender }, this.configurationService); } - const session = this.instantiationService.createInstance(RawDebugSession, sessionId, configuration.debugServer, adapter, this.customTelemetryService); + const session = this.instantiationService.createInstance(RawDebugSession, sessionId, configuration.debugServer, adapter, this.customTelemetryService, root); const process = this.model.addProcess(configuration, session); this.toDisposeOnSessionEnd.set(session.getId(), []); @@ -961,7 +954,7 @@ export class DebugService implements debug.IDebugService { config.noDebug = process.configuration.noDebug; } config.__restart = restartData; - this.createProcess(config).then(() => c(null), err => e(err)); + this.createProcess(process.session.root, config).then(() => c(null), err => e(err)); }, 300); }) ).then(() => { diff --git a/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts b/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts index 62951198d1d..40e83b2ff22 100644 --- a/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts +++ b/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts @@ -6,6 +6,7 @@ import nls = require('vs/nls'); import cp = require('child_process'); import net = require('net'); +import uri from 'vs/base/common/uri'; import Event, { Emitter } from 'vs/base/common/event'; import platform = require('vs/base/common/platform'); import objects = require('vs/base/common/objects'); @@ -70,6 +71,7 @@ export class RawDebugSession extends v8.V8Protocol implements debug.ISession { private debugServerPort: number, private adapter: Adapter, private customTelemetryService: ITelemetryService, + public root: uri, @IMessageService private messageService: IMessageService, @ITelemetryService private telemetryService: ITelemetryService, @IOutputService private outputService: IOutputService, @@ -434,7 +436,7 @@ export class RawDebugSession extends v8.V8Protocol implements debug.ISession { } private startServer(): TPromise { - return this.adapter.getAdapterExecutable().then(ae => this.launchServer(ae).then(() => { + return this.adapter.getAdapterExecutable(this.root).then(ae => this.launchServer(ae).then(() => { this.serverProcess.on('error', (err: Error) => this.onServerError(err)); this.serverProcess.on('exit', (code: number, signal: string) => this.onServerExit()); diff --git a/src/vs/workbench/parts/debug/node/debugAdapter.ts b/src/vs/workbench/parts/debug/node/debugAdapter.ts index 944fd5b5227..9b656fbd65f 100644 --- a/src/vs/workbench/parts/debug/node/debugAdapter.ts +++ b/src/vs/workbench/parts/debug/node/debugAdapter.ts @@ -31,19 +31,19 @@ export class Adapter { } } - public getAdapterExecutable(verifyAgainstFS = true): TPromise { + public getAdapterExecutable(root: uri, verifyAgainstFS = true): TPromise { if (this.rawAdapter.adapterExecutableCommand) { - return this.commandService.executeCommand(this.rawAdapter.adapterExecutableCommand).then(ad => { + return this.commandService.executeCommand(this.rawAdapter.adapterExecutableCommand, root.toString()).then(ad => { return this.verifyAdapterDetails(ad, verifyAgainstFS); }); } const adapterExecutable = { - command: this.getProgram(), + command: this.getProgram(root), args: this.getAttributeBasedOnPlatform('args') }; - const runtime = this.getRuntime(); + const runtime = this.getRuntime(root); if (runtime) { const runtimeArgs = this.getAttributeBasedOnPlatform('runtimeArgs'); adapterExecutable.args = (runtimeArgs || []).concat([adapterExecutable.command]).concat(adapterExecutable.args || []); @@ -82,19 +82,19 @@ export class Adapter { "Cannot determine executable for debug adapter '{0}'.", details.command))); } - private getRuntime(): string { + private getRuntime(root: uri): string { let runtime = this.getAttributeBasedOnPlatform('runtime'); if (runtime && runtime.indexOf('./') === 0) { - runtime = this.configurationResolverService ? this.configurationResolverService.resolve(runtime) : runtime; + runtime = this.configurationResolverService ? this.configurationResolverService.resolve(root, runtime) : runtime; runtime = paths.join(this.extensionDescription.extensionFolderPath, runtime); } return runtime; } - private getProgram(): string { + private getProgram(root: uri): string { let program = this.getAttributeBasedOnPlatform('program'); if (program) { - program = this.configurationResolverService ? this.configurationResolverService.resolve(program) : program; + program = this.configurationResolverService ? this.configurationResolverService.resolve(root, program) : program; program = paths.join(this.extensionDescription.extensionFolderPath, program); } return program; diff --git a/src/vs/workbench/parts/debug/test/common/mockDebug.ts b/src/vs/workbench/parts/debug/test/common/mockDebug.ts index a7e529ff329..d2b761947a0 100644 --- a/src/vs/workbench/parts/debug/test/common/mockDebug.ts +++ b/src/vs/workbench/parts/debug/test/common/mockDebug.ts @@ -83,11 +83,11 @@ export class MockDebugService implements debug.IDebugService { public removeWatchExpressions(id?: string): void { } - public startDebugging(configOrName?: debug.IConfig | string, noDebug?: boolean): TPromise { + public startDebugging(root: uri, configOrName?: debug.IConfig | string, noDebug?: boolean): TPromise { return TPromise.as(null); } - public createProcess(config: debug.IConfig): TPromise { + public createProcess(root: uri, config: debug.IConfig): TPromise { return TPromise.as(null); } @@ -124,6 +124,8 @@ export class MockSession implements debug.ISession { return 'mockrawsession'; } + public root: uri; + public getLengthInSeconds(): number { return 100; } diff --git a/src/vs/workbench/parts/debug/test/node/debugAdapter.test.ts b/src/vs/workbench/parts/debug/test/node/debugAdapter.test.ts index 420f398feaa..0bf502a6008 100644 --- a/src/vs/workbench/parts/debug/test/node/debugAdapter.test.ts +++ b/src/vs/workbench/parts/debug/test/node/debugAdapter.test.ts @@ -55,7 +55,7 @@ suite('Debug - Adapter', () => { assert.equal(adapter.type, rawAdapter.type); assert.equal(adapter.label, rawAdapter.label); - return adapter.getAdapterExecutable(false).then(details => { + return adapter.getAdapterExecutable(undefined, false).then(details => { assert.equal(details.command, paths.join(extensionFolderPath, rawAdapter.program)); assert.deepEqual(details.args, rawAdapter.args); }); @@ -103,7 +103,7 @@ suite('Debug - Adapter', () => { engines: null }); - return adapter.getAdapterExecutable(false).then(details => { + return adapter.getAdapterExecutable(undefined, false).then(details => { assert.equal(details.command, platform.isLinux ? da.linux.runtime : platform.isMacintosh ? da.osx.runtime : da.win.runtime); assert.deepEqual(details.args, da.runtimeArgs.concat(['a/b/c/d/mockprogram'].concat(da.args))); }); diff --git a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts index bf8da6b58a5..4ea0efcddba 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -1257,13 +1257,13 @@ class TaskService extends EventEmitter implements ITaskService { this._taskSystem = new TerminalTaskSystem( this.terminalService, this.outputService, this.markerService, this.modelService, this.configurationResolverService, this.telemetryService, - this.workbenchEditorService, + this.workbenchEditorService, this.contextService, TaskService.OutputChannelId ); } else { let system = new ProcessTaskSystem( this.markerService, this.modelService, this.telemetryService, this.outputService, - this.configurationResolverService, TaskService.OutputChannelId, + this.configurationResolverService, this.contextService, TaskService.OutputChannelId, ); system.hasErrors(this._configHasErrors); this._taskSystem = system; diff --git a/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts b/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts index 3ad7ca39063..9b3aaa6c15b 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/terminalTaskSystem.ts @@ -23,6 +23,7 @@ import * as TPath from 'vs/base/common/paths'; // import URI from 'vs/base/common/uri'; import { IMarkerService } from 'vs/platform/markers/common/markers'; +import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IModelService } from 'vs/editor/common/services/modelService'; import { ProblemMatcher, ProblemMatcherRegistry /*, ProblemPattern, getResource */ } from 'vs/platform/markers/common/problemMatcher'; @@ -117,6 +118,7 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem { private configurationResolverService: IConfigurationResolverService, private telemetryService: ITelemetryService, private workbenchEditorService: IWorkbenchEditorService, + private contextService: IWorkspaceContextService, outputChannelId: string) { super(); @@ -631,7 +633,8 @@ export class TerminalTaskSystem extends EventEmitter implements ITaskSystem { } private resolveVariable(value: string): string { - return this.configurationResolverService.resolve(value); + // TODO@Dirk adopt new configuration resolver service https://github.com/Microsoft/vscode/issues/31365 + return this.configurationResolverService.resolve(this.contextService.getLegacyWorkspace().resource, value); } private resolveOptions(options: CommandOptions): CommandOptions { diff --git a/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts b/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts index dcf646daff4..ed09f3635ba 100644 --- a/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts +++ b/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts @@ -173,8 +173,9 @@ export class ProcessRunnerDetector { let args = (this.taskConfiguration.args || []).concat(config.arg); let options: CommandOptions = this.taskConfiguration.options ? this.resolveCommandOptions(this.taskConfiguration.options) : { cwd: this._cwd }; let isShellCommand = !!this.taskConfiguration.isShellCommand; + // TODO@Dirk adopt new configuration resolver service https://github.com/Microsoft/vscode/issues/31365 return this.runDetection( - new LineProcess(this.taskConfiguration.command, this.configurationResolverService.resolve(args), isShellCommand, options), + new LineProcess(this.taskConfiguration.command, this.configurationResolverService.resolve(this.contextService.getLegacyWorkspace().resource, args), isShellCommand, options), this.taskConfiguration.command, isShellCommand, config.matcher, ProcessRunnerDetector.DefaultProblemMatchers, list); } else { if (detectSpecific) { @@ -215,12 +216,13 @@ export class ProcessRunnerDetector { } private resolveCommandOptions(options: CommandOptions): CommandOptions { + // TODO@Dirk adopt new configuration resolver service https://github.com/Microsoft/vscode/issues/31365 let result = Objects.clone(options); if (result.cwd) { - result.cwd = this.configurationResolverService.resolve(result.cwd); + result.cwd = this.configurationResolverService.resolve(this.contextService.getLegacyWorkspace().resource, result.cwd); } if (result.env) { - result.env = this.configurationResolverService.resolve(result.env); + result.env = this.configurationResolverService.resolve(this.contextService.getLegacyWorkspace().resource, result.env); } return result; } diff --git a/src/vs/workbench/parts/tasks/node/processTaskSystem.ts b/src/vs/workbench/parts/tasks/node/processTaskSystem.ts index ed4a91d2d4e..55556c6f24c 100644 --- a/src/vs/workbench/parts/tasks/node/processTaskSystem.ts +++ b/src/vs/workbench/parts/tasks/node/processTaskSystem.ts @@ -24,6 +24,7 @@ import { IMarkerService } from 'vs/platform/markers/common/markers'; import { IModelService } from 'vs/editor/common/services/modelService'; import { ProblemMatcher, ProblemMatcherRegistry } from 'vs/platform/markers/common/problemMatcher'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { StartStopProblemCollector, WatchingProblemCollector, ProblemCollectorEvents } from 'vs/workbench/parts/tasks/common/problemCollectors'; import { @@ -43,6 +44,7 @@ export class ProcessTaskSystem extends EventEmitter implements ITaskSystem { private outputService: IOutputService; private telemetryService: ITelemetryService; private configurationResolverService: IConfigurationResolverService; + private contextService: IWorkspaceContextService; private outputChannel: IOutputChannel; @@ -52,11 +54,12 @@ export class ProcessTaskSystem extends EventEmitter implements ITaskSystem { private activeTaskPromise: TPromise; constructor(markerService: IMarkerService, modelService: IModelService, telemetryService: ITelemetryService, - outputService: IOutputService, configurationResolverService: IConfigurationResolverService, outputChannelId: string) { + outputService: IOutputService, configurationResolverService: IConfigurationResolverService, contextService: IWorkspaceContextService, outputChannelId: string) { super(); this.markerService = markerService; this.modelService = modelService; this.outputService = outputService; + this.contextService = contextService; this.telemetryService = telemetryService; this.configurationResolverService = configurationResolverService; @@ -374,7 +377,8 @@ export class ProcessTaskSystem extends EventEmitter implements ITaskSystem { } private resolveVariable(value: string): string { - return this.configurationResolverService.resolve(value); + // TODO@Dirk adopt new configuration resolver service https://github.com/Microsoft/vscode/issues/31365 + return this.configurationResolverService.resolve(this.contextService.getLegacyWorkspace().resource, value); } public log(value: string): void { diff --git a/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts b/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts index 90080c38cd9..a4d5f33a9ff 100644 --- a/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts +++ b/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import uri from 'vs/base/common/uri'; import { TPromise } from 'vs/base/common/winjs.base'; import { IStringDictionary } from 'vs/base/common/collections'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; @@ -13,9 +14,9 @@ export interface IConfigurationResolverService { _serviceBrand: any; // TODO@Isidor improve this API - resolve(value: string): string; - resolve(value: string[]): string[]; - resolve(value: IStringDictionary): IStringDictionary; - resolveAny(value: T): T; + resolve(root: uri, value: string): string; + resolve(root: uri, value: string[]): string[]; + resolve(root: uri, value: IStringDictionary): IStringDictionary; + resolveAny(root: uri, value: T): T; resolveInteractiveVariables(configuration: any, interactiveVariablesMap: { [key: string]: string }): TPromise; } diff --git a/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts b/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts index 6cc318a718e..e65a6cd14a4 100644 --- a/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts +++ b/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts @@ -3,6 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import uri from 'vs/base/common/uri'; import * as paths from 'vs/base/common/paths'; import * as types from 'vs/base/common/types'; import { TPromise } from 'vs/base/common/winjs.base'; @@ -15,12 +16,11 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; import { ICommonCodeEditor } from 'vs/editor/common/editorCommon'; import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { toResource } from 'vs/workbench/common/editor'; -import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; export class ConfigurationResolverService implements IConfigurationResolverService { _serviceBrand: any; - private _workspaceRoot: string; private _execPath: string; + private _workspaceRoot: string; constructor( envVariables: { [key: string]: string }, @@ -28,9 +28,7 @@ export class ConfigurationResolverService implements IConfigurationResolverServi @IEnvironmentService environmentService: IEnvironmentService, @IConfigurationService private configurationService: IConfigurationService, @ICommandService private commandService: ICommandService, - @IWorkspaceContextService private contextService: IWorkspaceContextService ) { - this._workspaceRoot = paths.normalize(contextService.hasWorkspace() ? contextService.getLegacyWorkspace().resource.fsPath : '', true); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29246) this._execPath = environmentService.execPath; Object.keys(envVariables).forEach(key => { this[`env:${key}`] = envVariables[key]; @@ -103,35 +101,37 @@ export class ConfigurationResolverService implements IConfigurationResolverServi return paths.normalize(fileResource.fsPath, true); } - public resolve(value: string): string; - public resolve(value: string[]): string[]; - public resolve(value: IStringDictionary): IStringDictionary; - public resolve(value: any): any { + public resolve(root: uri, value: string): string; + public resolve(root: uri, value: string[]): string[]; + public resolve(root: uri, value: IStringDictionary): IStringDictionary; + public resolve(root: uri, value: any): any { + this._workspaceRoot = root.fsPath.toString(); if (types.isString(value)) { - return this.resolveString(value); + return this.resolveString(root, value); } else if (types.isArray(value)) { - return this.resolveArray(value); + return this.resolveArray(root, value); } else if (types.isObject(value)) { - return this.resolveLiteral(value); + return this.resolveLiteral(root, value); } return value; } - public resolveAny(value: T): T; - public resolveAny(value: any): any { + public resolveAny(root: uri, value: T): T; + public resolveAny(root: uri, value: any): any { + this._workspaceRoot = root.fsPath.toString(); if (types.isString(value)) { - return this.resolveString(value); + return this.resolveString(root, value); } else if (types.isArray(value)) { - return this.resolveAnyArray(value); + return this.resolveAnyArray(root, value); } else if (types.isObject(value)) { - return this.resolveAnyLiteral(value); + return this.resolveAnyLiteral(root, value); } return value; } - private resolveString(value: string): string { + private resolveString(root: uri, value: string): string { let regexp = /\$\{(.*?)\}/g; const originalValue = value; const resolvedString = value.replace(regexp, (match: string, name: string) => { @@ -143,10 +143,10 @@ export class ConfigurationResolverService implements IConfigurationResolverServi } }); - return this.resolveConfigVariable(resolvedString, originalValue); + return this.resolveConfigVariable(root, resolvedString, originalValue); } - private resolveConfigVariable(value: string, originalValue: string): string { + private resolveConfigVariable(root: uri, value: string, originalValue: string): string { const replacer = (match: string, name: string) => { let config = this.configurationService.getConfiguration(); let newValue: any; @@ -168,41 +168,41 @@ export class ConfigurationResolverService implements IConfigurationResolverServi } if (types.isString(newValue)) { // Prevent infinite recursion and also support nested references (or tokens) - return newValue === originalValue ? '' : this.resolveString(newValue); + return newValue === originalValue ? '' : this.resolveString(root, newValue); } else { - return this.resolve(newValue) + ''; + return this.resolve(root, newValue) + ''; } }; return value.replace(/\$\{config:(.+?)\}/g, replacer); } - private resolveLiteral(values: IStringDictionary | string[]>): IStringDictionary | string[]> { + private resolveLiteral(root: uri, values: IStringDictionary | string[]>): IStringDictionary | string[]> { let result: IStringDictionary | string[]> = Object.create(null); Object.keys(values).forEach(key => { let value = values[key]; - result[key] = this.resolve(value); + result[key] = this.resolve(root, value); }); return result; } - private resolveAnyLiteral(values: T): T; - private resolveAnyLiteral(values: any): any { + private resolveAnyLiteral(root: uri, values: T): T; + private resolveAnyLiteral(root: uri, values: any): any { let result: IStringDictionary | string[]> = Object.create(null); Object.keys(values).forEach(key => { let value = values[key]; - result[key] = this.resolveAny(value); + result[key] = this.resolveAny(root, value); }); return result; } - private resolveArray(value: string[]): string[] { - return value.map(s => this.resolveString(s)); + private resolveArray(root: uri, value: string[]): string[] { + return value.map(s => this.resolveString(root, s)); } - private resolveAnyArray(value: T[]): T[]; - private resolveAnyArray(value: any[]): any[] { - return value.map(s => this.resolveAny(s)); + private resolveAnyArray(root: uri, value: T[]): T[]; + private resolveAnyArray(root: uri, value: any[]): any[] { + return value.map(s => this.resolveAny(root, s)); } /** diff --git a/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts index f0b67873917..12fc724a449 100644 --- a/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts @@ -11,21 +11,22 @@ import { IConfigurationService, getConfigurationValue, IConfigurationOverrides, import { ICommandService } from 'vs/platform/commands/common/commands'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { ConfigurationResolverService } from 'vs/workbench/services/configurationResolver/node/configurationResolverService'; -import { TestEnvironmentService, TestEditorService, TestContextService } from 'vs/workbench/test/workbenchTestServices'; +import { TestEnvironmentService, TestEditorService } from 'vs/workbench/test/workbenchTestServices'; import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; -import { testWorkspace } from 'vs/platform/workspace/test/common/testWorkspace'; suite('Configuration Resolver Service', () => { let configurationResolverService: IConfigurationResolverService; let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; let mockCommandService: MockCommandService; let editorService: TestEditorService; + let workspaceUri: uri; setup(() => { mockCommandService = new MockCommandService(); editorService = new TestEditorService(); - configurationResolverService = new ConfigurationResolverService(envVariables, editorService, TestEnvironmentService, new TestConfigurationService(), mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); + workspaceUri = uri.parse('file:///VSCode/workspaceLocation'); + configurationResolverService = new ConfigurationResolverService(envVariables, editorService, TestEnvironmentService, new TestConfigurationService(), mockCommandService); }); teardown(() => { @@ -35,41 +36,41 @@ suite('Configuration Resolver Service', () => { test('substitute one', () => { if (platform.isWindows) { - assert.strictEqual(configurationResolverService.resolve('abc ${workspaceRoot} xyz'), 'abc \\VSCode\\workspaceLocation xyz'); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, 'abc ${workspaceRoot} xyz'), 'abc \\VSCode\\workspaceLocation xyz'); } else { - assert.strictEqual(configurationResolverService.resolve('abc ${workspaceRoot} xyz'), 'abc /VSCode/workspaceLocation xyz'); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, 'abc ${workspaceRoot} xyz'), 'abc /VSCode/workspaceLocation xyz'); } }); test('workspace root folder name', () => { - assert.strictEqual(configurationResolverService.resolve('abc ${workspaceRootFolderName} xyz'), 'abc workspaceLocation xyz'); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, 'abc ${workspaceRootFolderName} xyz'), 'abc workspaceLocation xyz'); }); test('current selected line number', () => { - assert.strictEqual(configurationResolverService.resolve('abc ${lineNumber} xyz'), `abc ${editorService.mockLineNumber} xyz`); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, 'abc ${lineNumber} xyz'), `abc ${editorService.mockLineNumber} xyz`); }); test('substitute many', () => { if (platform.isWindows) { - assert.strictEqual(configurationResolverService.resolve('${workspaceRoot} - ${workspaceRoot}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation'); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, '${workspaceRoot} - ${workspaceRoot}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation'); } else { - assert.strictEqual(configurationResolverService.resolve('${workspaceRoot} - ${workspaceRoot}'), '/VSCode/workspaceLocation - /VSCode/workspaceLocation'); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, '${workspaceRoot} - ${workspaceRoot}'), '/VSCode/workspaceLocation - /VSCode/workspaceLocation'); } }); test('substitute one env variable', () => { if (platform.isWindows) { - assert.strictEqual(configurationResolverService.resolve('abc ${workspaceRoot} ${env:key1} xyz'), 'abc \\VSCode\\workspaceLocation Value for Key1 xyz'); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, 'abc ${workspaceRoot} ${env:key1} xyz'), 'abc \\VSCode\\workspaceLocation Value for Key1 xyz'); } else { - assert.strictEqual(configurationResolverService.resolve('abc ${workspaceRoot} ${env:key1} xyz'), 'abc /VSCode/workspaceLocation Value for Key1 xyz'); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, 'abc ${workspaceRoot} ${env:key1} xyz'), 'abc /VSCode/workspaceLocation Value for Key1 xyz'); } }); test('substitute many env variable', () => { if (platform.isWindows) { - assert.strictEqual(configurationResolverService.resolve('${workspaceRoot} - ${workspaceRoot} ${env:key1} - ${env:key2}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2'); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, '${workspaceRoot} - ${workspaceRoot} ${env:key1} - ${env:key2}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2'); } else { - assert.strictEqual(configurationResolverService.resolve('${workspaceRoot} - ${workspaceRoot} ${env:key1} - ${env:key2}'), '/VSCode/workspaceLocation - /VSCode/workspaceLocation Value for Key1 - Value for Key2'); + assert.strictEqual(configurationResolverService.resolve(workspaceUri, '${workspaceRoot} - ${workspaceRoot} ${env:key1} - ${env:key2}'), '/VSCode/workspaceLocation - /VSCode/workspaceLocation Value for Key1 - Value for Key2'); } }); @@ -86,8 +87,8 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); - assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} xyz'), 'abc foo xyz'); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.fontFamily} xyz'), 'abc foo xyz'); }); test('substitute many configuration variables', () => { @@ -103,8 +104,8 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); - assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo bar xyz'); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo bar xyz'); }); test('substitute nested configuration variables', () => { @@ -120,11 +121,11 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); if (platform.isWindows) { - assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo \\VSCode\\workspaceLocation bar bar xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo \\VSCode\\workspaceLocation bar bar xyz'); } else { - assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo /VSCode/workspaceLocation bar bar xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo /VSCode/workspaceLocation bar bar xyz'); } }); @@ -141,11 +142,11 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); if (platform.isWindows) { - assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo \\VSCode\\workspaceLocation bar bar xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo \\VSCode\\workspaceLocation bar bar xyz'); } else { - assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo /VSCode/workspaceLocation bar bar xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} xyz'), 'abc foo /VSCode/workspaceLocation bar bar xyz'); } }); @@ -162,11 +163,11 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); if (platform.isWindows) { - assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${workspaceRoot} ${env:key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for Key1 xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.fontFamily} ${workspaceRoot} ${env:key1} xyz'), 'abc foo \\VSCode\\workspaceLocation Value for Key1 xyz'); } else { - assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${workspaceRoot} ${env:key1} xyz'), 'abc foo /VSCode/workspaceLocation Value for Key1 xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.fontFamily} ${workspaceRoot} ${env:key1} xyz'), 'abc foo /VSCode/workspaceLocation Value for Key1 xyz'); } }); @@ -183,11 +184,11 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); if (platform.isWindows) { - assert.strictEqual(service.resolve('${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} ${workspaceRoot} - ${workspaceRoot} ${env:key1} - ${env:key2}'), 'foo bar \\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2'); + assert.strictEqual(service.resolve(workspaceUri, '${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} ${workspaceRoot} - ${workspaceRoot} ${env:key1} - ${env:key2}'), 'foo bar \\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for Key1 - Value for Key2'); } else { - assert.strictEqual(service.resolve('${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} ${workspaceRoot} - ${workspaceRoot} ${env:key1} - ${env:key2}'), 'foo bar /VSCode/workspaceLocation - /VSCode/workspaceLocation Value for Key1 - Value for Key2'); + assert.strictEqual(service.resolve(workspaceUri, '${config:editor.fontFamily} ${config:terminal.integrated.fontFamily} ${workspaceRoot} - ${workspaceRoot} ${env:key1} - ${env:key2}'), 'foo bar /VSCode/workspaceLocation - /VSCode/workspaceLocation Value for Key1 - Value for Key2'); } }); @@ -217,8 +218,8 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); - assert.strictEqual(service.resolve('abc ${config:editor.fontFamily} ${config:editor.lineNumbers} ${config:editor.insertSpaces} xyz'), 'abc foo 123 false xyz'); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.fontFamily} ${config:editor.lineNumbers} ${config:editor.insertSpaces} xyz'), 'abc foo 123 false xyz'); }); test('configuration should not evaluate Javascript', () => { @@ -229,8 +230,8 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); - assert.strictEqual(service.resolve('abc ${config:editor[\'abc\'.substr(0)]} xyz'), 'abc xyz'); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor[\'abc\'.substr(0)]} xyz'), 'abc xyz'); }); test('uses empty string as fallback', () => { @@ -239,11 +240,11 @@ suite('Configuration Resolver Service', () => { editor: {} }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); - assert.strictEqual(service.resolve('abc ${config:editor.abc} xyz'), 'abc xyz'); - assert.strictEqual(service.resolve('abc ${config:editor.abc.def} xyz'), 'abc xyz'); - assert.strictEqual(service.resolve('abc ${config:panel} xyz'), 'abc xyz'); - assert.strictEqual(service.resolve('abc ${config:panel.abc} xyz'), 'abc xyz'); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.abc} xyz'), 'abc xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.abc.def} xyz'), 'abc xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:panel} xyz'), 'abc xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:panel.abc} xyz'), 'abc xyz'); }); test('is restricted to own properties', () => { @@ -252,9 +253,9 @@ suite('Configuration Resolver Service', () => { editor: {} }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); - assert.strictEqual(service.resolve('abc ${config:editor.__proto__} xyz'), 'abc xyz'); - assert.strictEqual(service.resolve('abc ${config:editor.toString} xyz'), 'abc xyz'); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.__proto__} xyz'), 'abc xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.toString} xyz'), 'abc xyz'); }); test('configuration variables with invalid accessor', () => { @@ -265,10 +266,10 @@ suite('Configuration Resolver Service', () => { } }); - let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService, new TestContextService(testWorkspace(uri.parse('file:///VSCode/workspaceLocation')))); - assert.strictEqual(service.resolve('abc ${config:} xyz'), 'abc ${config:} xyz'); - assert.strictEqual(service.resolve('abc ${config:editor..fontFamily} xyz'), 'abc xyz'); - assert.strictEqual(service.resolve('abc ${config:editor.none.none2} xyz'), 'abc xyz'); + let service = new ConfigurationResolverService(envVariables, new TestEditorService(), TestEnvironmentService, configurationService, mockCommandService); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:} xyz'), 'abc ${config:} xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor..fontFamily} xyz'), 'abc xyz'); + assert.strictEqual(service.resolve(workspaceUri, 'abc ${config:editor.none.none2} xyz'), 'abc xyz'); }); test('interactive variable simple', () => {