mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
eliminate code duplication; use resolveWorkspaceFolder()
This commit is contained in:
@@ -68,7 +68,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
|
||||
constructor(mainContext: IMainContext,
|
||||
private _workspace: ExtHostWorkspace,
|
||||
private _workspaceService: ExtHostWorkspace,
|
||||
private _extensionService: ExtHostExtensionService,
|
||||
private _editorsService: ExtHostDocumentsAndEditors,
|
||||
private _configurationService: ExtHostConfiguration
|
||||
@@ -135,10 +135,18 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
|
||||
public $substituteVariables(folderUri: UriComponents | undefined, config: IConfig): TPromise<IConfig> {
|
||||
if (!this._variableResolver) {
|
||||
this._variableResolver = new ExtHostVariableResolverService(this._workspace, this._editorsService, this._configurationService);
|
||||
this._variableResolver = new ExtHostVariableResolverService(this._workspaceService, this._editorsService, this._configurationService);
|
||||
}
|
||||
const folder = <IWorkspaceFolder>this.getFolder(folderUri);
|
||||
return asWinJsPromise(token => DebugAdapter.substituteVariables(folder, config, this._variableResolver));
|
||||
const folder = this.getFolder(folderUri);
|
||||
let ws: IWorkspaceFolder = {
|
||||
uri: folder.uri,
|
||||
name: folder.name,
|
||||
index: folder.index,
|
||||
toResource: () => {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
};
|
||||
return asWinJsPromise(token => DebugAdapter.substituteVariables(ws, config, this._variableResolver));
|
||||
}
|
||||
|
||||
public $startDASession(handle: number, debugType: string, adpaterExecutable: IAdapterExecutable | null, debugPort: number): TPromise<void> {
|
||||
@@ -487,14 +495,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
|
||||
this._onDidReceiveDebugSessionCustomEvent.fire(ee);
|
||||
}
|
||||
|
||||
private getFolder(_folderUri: UriComponents | undefined) {
|
||||
private getFolder(_folderUri: UriComponents | undefined): vscode.WorkspaceFolder {
|
||||
if (_folderUri) {
|
||||
const folderUriString = URI.revive(_folderUri).toString();
|
||||
const folders = this._workspace.getWorkspaceFolders();
|
||||
const found = folders.filter(f => f.uri.toString() === folderUriString);
|
||||
if (found && found.length > 0) {
|
||||
return found[0];
|
||||
}
|
||||
const folderURI = URI.revive(_folderUri);
|
||||
return this._workspaceService.resolveWorkspaceFolder(folderURI);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user