Debug API for tracking current debug session; fixes #30157

This commit is contained in:
Andre Weinand
2017-07-06 00:26:17 +02:00
parent 78b912ee3f
commit 5eb21eaa8a
7 changed files with 66 additions and 2 deletions

View File

@@ -463,12 +463,19 @@ export function createApiFactory(
// namespace: debug
const debug: typeof vscode.debug = {
get activeDebugSession() {
assertProposedApi(extension);
return extHostDebugService.activeDebugSession;
},
createDebugSession(config: vscode.DebugConfiguration) {
return extHostDebugService.createDebugSession(config);
},
onDidTerminateDebugSession(listener, thisArg?, disposables?) {
return extHostDebugService.onDidTerminateDebugSession(listener, thisArg, disposables);
}
},
onDidChangeActiveDebugSession: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
return extHostDebugService.onDidChangeActiveDebugSession(listener, thisArg, disposables);
})
};

View File

@@ -501,6 +501,7 @@ export abstract class ExtHostTaskShape {
export abstract class ExtHostDebugServiceShape {
$acceptDebugSessionTerminated(id: DebugSessionUUID, type: string, name: string): void { throw ni(); }
$acceptDebugSessionActiveChanged(id: DebugSessionUUID | undefined, type?: string, name?: string): void { throw ni(); }
}
// --- proxy identifiers

View File

@@ -21,11 +21,18 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape {
private _onDidTerminateDebugSession: Emitter<vscode.DebugSession>;
get onDidTerminateDebugSession(): Event<vscode.DebugSession> { return this._onDidTerminateDebugSession.event; }
private _onDidChangeActiveDebugSession: Emitter<vscode.DebugSession | undefined>;
get onDidChangeActiveDebugSession(): Event<vscode.DebugSession | undefined> { return this._onDidChangeActiveDebugSession.event; }
private _activeDebugSession: vscode.DebugSession | undefined;
get activeDebugSession(): vscode.DebugSession | undefined { return this._activeDebugSession; }
constructor(threadService: IThreadService) {
super();
this._onDidTerminateDebugSession = new Emitter<vscode.DebugSession>();
this._onDidChangeActiveDebugSession = new Emitter<vscode.DebugSession>();
this._debugServiceProxy = threadService.get(MainContext.MainThreadDebugService);
}
@@ -47,6 +54,19 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape {
this._onDidTerminateDebugSession.fire(debugSession);
this._debugSessions.delete(id);
}
public $acceptDebugSessionActiveChanged(id: DebugSessionUUID | undefined, type?: string, name?: string): void {
if (id) {
this._activeDebugSession = this._debugSessions.get(id);
if (!this._activeDebugSession) {
this._activeDebugSession = new ExtHostDebugSession(this._debugServiceProxy, id, type, name);
}
} else {
this._activeDebugSession = undefined;
}
this._onDidChangeActiveDebugSession.fire(this._activeDebugSession);
}
}
export class ExtHostDebugSession implements vscode.DebugSession {