提交 618fcaad 编写于 作者: A Andre Weinand

incorporate debug API feedback

上级 7017d1bf
......@@ -190,6 +190,26 @@ declare module 'vscode' {
onData(callback: (data: string) => any): void;
}
/**
* A custom Debug Adapter Protocol event received from a [debug session](#DebugSession).
*/
export interface DebugSessionCustomEvent {
/**
* The [debug session](#DebugSession) for which the custom event was received.
*/
session: DebugSession;
/**
* Type of event.
*/
event: string;
/**
* Event specific information.
*/
body?: any;
}
export namespace debug {
/**
......@@ -197,7 +217,7 @@ declare module 'vscode' {
* represented by the debug action floating window or the one currently shown in the drop down menu of the debug action floating window.
* If no debug session is active, the value is `undefined`.
*/
export const activeDebugSession: DebugSession | undefined;
export let activeDebugSession: DebugSession | undefined;
/**
* An [event](#Event) which fires when the [active debug session](#debug.activeDebugSession)
......@@ -205,16 +225,19 @@ declare module 'vscode' {
* to `undefined`.
*/
export const onDidChangeActiveDebugSession: Event<DebugSession | undefined>;
/**
* An [event](#Event) which fires when a custom DAP event is received from the debug session.
*/
export const onDidReceiveDebugSessionCustomEvent: Event<DebugSessionCustomEvent>;
}
export interface DebugSession {
/**
* Experimental API that allows hooking custom events from the debug session's debug adapter.
*
* @param callback The callback that is triggered when a custom event is received from the debug adapter.
* The debug session's ID.
*/
onCustomEvent(callback: (event: any) => void): void;
readonly id: string;
}
}
......@@ -33,7 +33,8 @@ export class MainThreadDebugService extends MainThreadDebugServiceShape {
}));
this._toDispose.push(debugService.onDidCustomEvent(event => {
if (event.body && event.body.sessionId) {
this._proxy.$acceptDebugSessionCustomEvent(event.body.sessionId, event);
const process = this.debugService.findProcessByUUID(event.body.sessionId); // TODO
this._proxy.$acceptDebugSessionCustomEvent(event.body.sessionId, process.configuration.type, process.configuration.name, event);
}
}));
}
......
......@@ -475,6 +475,9 @@ export function createApiFactory(
},
onDidChangeActiveDebugSession: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
return extHostDebugService.onDidChangeActiveDebugSession(listener, thisArg, disposables);
}),
onDidReceiveDebugSessionCustomEvent: proposedApiFunction(extension, (listener, thisArg?, disposables?) => {
return extHostDebugService.onDidReceiveDebugSessionCustomEvent(listener, thisArg, disposables);
})
};
......
......@@ -503,7 +503,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(); }
$acceptDebugSessionCustomEvent(id: DebugSessionUUID, event: any): void { throw ni(); }
$acceptDebugSessionCustomEvent(id: DebugSessionUUID, type: string, name: string, event: any): void { throw ni(); }
}
// --- proxy identifiers
......
......@@ -27,11 +27,16 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape {
private _activeDebugSession: ExtHostDebugSession | undefined;
get activeDebugSession(): ExtHostDebugSession | undefined { return this._activeDebugSession; }
private _onDidReceiveDebugSessionCustomEvent: Emitter<vscode.DebugSessionCustomEvent>;
get onDidReceiveDebugSessionCustomEvent(): Event<vscode.DebugSessionCustomEvent> { return this._onDidReceiveDebugSessionCustomEvent.event; }
constructor(threadService: IThreadService) {
super();
this._onDidTerminateDebugSession = new Emitter<vscode.DebugSession>();
this._onDidChangeActiveDebugSession = new Emitter<vscode.DebugSession>();
this._onDidReceiveDebugSessionCustomEvent = new Emitter<vscode.DebugSessionCustomEvent>();
this._debugServiceProxy = threadService.get(MainContext.MainThreadDebugService);
}
......@@ -70,12 +75,19 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape {
this._onDidChangeActiveDebugSession.fire(this._activeDebugSession);
}
public $acceptDebugSessionCustomEvent(id: DebugSessionUUID, event: any): void {
public $acceptDebugSessionCustomEvent(id: DebugSessionUUID, type: string, name: string, event: any): void {
let debugSession = this._debugSessions.get(id);
if (debugSession) {
debugSession._onCustomEvent(event);
if (!debugSession) {
debugSession = new ExtHostDebugSession(this._debugServiceProxy, id, type, name);
this._debugSessions.set(id, debugSession);
}
const ee: vscode.DebugSessionCustomEvent = {
session: debugSession,
event: event.event,
body: event.body
};
this._onDidReceiveDebugSessionCustomEvent.fire(ee);
}
}
......@@ -88,8 +100,6 @@ export class ExtHostDebugSession implements vscode.DebugSession {
private _type: string;
private _name: string;
private _onCustomEventCallback: (event: any) => void;
constructor(proxy: MainThreadDebugServiceShape, id: DebugSessionUUID, type: string, name: string) {
this._debugServiceProxy = proxy;
this._id = id;
......@@ -112,12 +122,4 @@ export class ExtHostDebugSession implements vscode.DebugSession {
public customRequest(command: string, args: any): Thenable<any> {
return this._debugServiceProxy.$customDebugAdapterRequest(this._id, command, args);
}
public onCustomEvent(callback: (event: any) => void): void {
this._onCustomEventCallback = callback;
}
public _onCustomEvent(event: any): void {
this._onCustomEventCallback(event);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册