diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 5aea3859858..69a0b61f1f5 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -624,6 +624,15 @@ declare module 'vscode' { * @return A [disposable](#Disposable) that unregisters this provider when being disposed. */ export function registerDebugAdapterProvider(debugType: string, provider: DebugAdapterProvider): Disposable; + + /** + * Register a factory callback for the given debug type that is is called at the start of a debug session in order + * to return a "tracker" object that provides read-access to the communication between VS Code and a debug adapter. + * + * @param debugType A specific debug type or '*' for matching all debug types. + * @param callback A factory callback that is called at the start of a debug session to return a tracker object or `undefined`. + */ + export function registerDebugAdapterTracker(debugType: string, callback: (session: DebugSession) => DebugAdapterTracker | undefined): Disposable; } /** diff --git a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts index d817564f633..b0a198d55d1 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts @@ -62,7 +62,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb createDebugAdapter(session: IDebugSession): IDebugAdapter { const handle = this._debugAdaptersHandleCounter++; - const da = new ExtensionHostDebugAdapter(handle, this._proxy, this.getSessionDto(session)); + const da = new ExtensionHostDebugAdapter(this, handle, this._proxy, session); this._debugAdapters.set(handle, da); return da; } @@ -252,7 +252,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb // dto helpers - private getSessionDto(session: IDebugSession): IDebugSessionDto { + getSessionDto(session: IDebugSession): IDebugSessionDto { if (session) { const sessionID = session.getId(); if (this._sessions.has(sessionID)) { @@ -307,7 +307,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape, IDeb */ class ExtensionHostDebugAdapter extends AbstractDebugAdapter { - constructor(private _handle: number, private _proxy: ExtHostDebugServiceShape, private _sessionDto: IDebugSessionDto) { + constructor(private _ds: MainThreadDebugService, private _handle: number, private _proxy: ExtHostDebugServiceShape, private _session: IDebugSession) { super(); } @@ -320,7 +320,7 @@ class ExtensionHostDebugAdapter extends AbstractDebugAdapter { } public startSession(): Promise { - return Promise.resolve(this._proxy.$startDASession(this._handle, this._sessionDto)); + return Promise.resolve(this._proxy.$startDASession(this._handle, this._ds.getSessionDto(this._session))); } public sendMessage(message: DebugProtocol.ProtocolMessage): void { diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 320333f6ef5..6a076d0ac89 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -676,11 +676,14 @@ export function createApiFactory( return extHostDebugService.onDidChangeBreakpoints(listener, thisArgs, disposables); }, registerDebugConfigurationProvider(debugType: string, provider: vscode.DebugConfigurationProvider) { - return extHostDebugService.registerDebugConfigurationProvider(extension, debugType, provider); + return extHostDebugService.registerDebugConfigurationProvider(debugType, provider); }, registerDebugAdapterProvider(debugType: string, provider: vscode.DebugAdapterProvider) { return extHostDebugService.registerDebugAdapterProvider(extension, debugType, provider); }, + registerDebugAdapterTracker(debugType: string, callback: (session: vscode.DebugSession) => vscode.DebugAdapterTracker | undefined) { + return extHostDebugService.registerDebugAdapterTracker(debugType, callback); + }, startDebugging(folder: vscode.WorkspaceFolder | undefined, nameOrConfig: string | vscode.DebugConfiguration) { return extHostDebugService.startDebugging(folder, nameOrConfig); }, diff --git a/src/vs/workbench/api/node/extHostDebugService.ts b/src/vs/workbench/api/node/extHostDebugService.ts index fb4d48f6bfc..840dd9a060a 100644 --- a/src/vs/workbench/api/node/extHostDebugService.ts +++ b/src/vs/workbench/api/node/extHostDebugService.ts @@ -230,7 +230,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { return this._debugServiceProxy.$startDebugging(folder ? folder.uri : undefined, nameOrConfig); } - public registerDebugConfigurationProvider(extension: IExtensionDescription, type: string, provider: vscode.DebugConfigurationProvider): vscode.Disposable { + public registerDebugConfigurationProvider(type: string, provider: vscode.DebugConfigurationProvider): vscode.Disposable { if (!provider) { return new Disposable(() => { }); @@ -242,8 +242,9 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { this._debugServiceProxy.$registerDebugConfigurationProvider(type, !!provider.provideDebugConfigurations, !!provider.resolveDebugConfiguration, - !!provider.debugAdapterExecutable, // TODO@AW: legacy - !!provider.provideDebugAdapterTracker, handle); + !!provider.debugAdapterExecutable, // TODO@AW: deprecated + !!provider.provideDebugAdapterTracker, // TODO@AW: deprecated + handle); return new Disposable(() => { this._configProviders = this._configProviders.filter(p => p.provider !== provider); // remove @@ -278,6 +279,17 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { }); } + public registerDebugAdapterTracker(debugType: string, callback: (session: vscode.DebugSession) => vscode.DebugAdapterTracker | undefined) { + + const provider: vscode.DebugConfigurationProvider = { + provideDebugAdapterTracker(session: vscode.DebugSession) { + return callback(session); + } + }; + + return this.registerDebugConfigurationProvider(debugType, provider); + } + // RPC methods (ExtHostDebugServiceShape) public $runInTerminal(args: DebugProtocol.RunInTerminalRequestArguments, config: ITerminalSettings): Thenable {