提交 254c8c5b 编写于 作者: A Andre Weinand

debug API: add onDidStartDebugSession

上级 81813b2c
......@@ -5483,6 +5483,11 @@ declare module 'vscode' {
*/
export const onDidChangeActiveDebugSession: Event<DebugSession | undefined>;
/**
* An [event](#Event) which fires when a new debug session has been started.
*/
export const onDidStartDebugSession: Event<DebugSession>;
/**
* An [event](#Event) which fires when a custom DAP event is received from the debug session.
*/
......
......@@ -23,6 +23,7 @@ export class MainThreadDebugService extends MainThreadDebugServiceShape {
this._proxy = threadService.get(ExtHostContext.ExtHostDebugService);
this._toDispose = [];
this._toDispose.push(debugService.onDidNewProcess(proc => this._proxy.$acceptDebugSessionStarted(<DebugSessionUUID>proc.getId(), proc.configuration.type, proc.name)));
this._toDispose.push(debugService.onDidEndProcess(proc => this._proxy.$acceptDebugSessionTerminated(<DebugSessionUUID>proc.getId(), proc.configuration.type, proc.name)));
this._toDispose.push(debugService.getViewModel().onDidFocusProcess(proc => {
if (proc) {
......
......@@ -470,6 +470,9 @@ export function createApiFactory(
startDebugSession(config: vscode.DebugConfiguration) {
return extHostDebugService.startDebugSession(config);
},
onDidStartDebugSession(listener, thisArg?, disposables?) {
return extHostDebugService.onDidStartDebugSession(listener, thisArg, disposables);
},
onDidTerminateDebugSession(listener, thisArg?, disposables?) {
return extHostDebugService.onDidTerminateDebugSession(listener, thisArg, disposables);
},
......
......@@ -499,6 +499,7 @@ export abstract class ExtHostTaskShape {
}
export abstract class ExtHostDebugServiceShape {
$acceptDebugSessionStarted(id: DebugSessionUUID, type: string, name: string): void { throw ni(); }
$acceptDebugSessionTerminated(id: DebugSessionUUID, type: string, name: string): void { throw ni(); }
$acceptDebugSessionActiveChanged(id: DebugSessionUUID | undefined, type?: string, name?: string): void { throw ni(); }
$acceptDebugSessionCustomEvent(id: DebugSessionUUID, type: string, name: string, event: any): void { throw ni(); }
......
......@@ -18,6 +18,9 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape {
private _debugServiceProxy: MainThreadDebugServiceShape;
private _debugSessions: Map<DebugSessionUUID, ExtHostDebugSession> = new Map<DebugSessionUUID, ExtHostDebugSession>();
private _onDidStartDebugSession: Emitter<vscode.DebugSession>;
get onDidStartDebugSession(): Event<vscode.DebugSession> { return this._onDidStartDebugSession.event; }
private _onDidTerminateDebugSession: Emitter<vscode.DebugSession>;
get onDidTerminateDebugSession(): Event<vscode.DebugSession> { return this._onDidTerminateDebugSession.event; }
......@@ -34,6 +37,7 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape {
constructor(threadService: IThreadService) {
super();
this._onDidStartDebugSession = new Emitter<vscode.DebugSession>();
this._onDidTerminateDebugSession = new Emitter<vscode.DebugSession>();
this._onDidChangeActiveDebugSession = new Emitter<vscode.DebugSession>();
this._onDidReceiveDebugSessionCustomEvent = new Emitter<vscode.DebugSessionCustomEvent>();
......@@ -50,6 +54,16 @@ export class ExtHostDebugService extends ExtHostDebugServiceShape {
});
}
public $acceptDebugSessionStarted(id: DebugSessionUUID, type: string, name: string): void {
let debugSession = this._debugSessions.get(id);
if (!debugSession) {
debugSession = new ExtHostDebugSession(this._debugServiceProxy, id, type, name);
this._debugSessions.set(id, debugSession);
}
this._onDidStartDebugSession.fire(debugSession);
}
public $acceptDebugSessionTerminated(id: DebugSessionUUID, type: string, name: string): void {
let debugSession = this._debugSessions.get(id);
......
......@@ -440,6 +440,11 @@ export interface IDebugService {
*/
onDidChangeState: Event<State>;
/**
* Allows to register on new process events.
*/
onDidNewProcess: Event<IProcess>;
/**
* Allows to register on end process events.
*/
......
......@@ -68,6 +68,7 @@ export class DebugService implements debug.IDebugService {
private sessionStates: Map<string, debug.State>;
private _onDidChangeState: Emitter<debug.State>;
private _onDidNewProcess: Emitter<debug.IProcess>;
private _onDidEndProcess: Emitter<debug.IProcess>;
private _onDidCustomEvent: Emitter<DebugProtocol.Event>;
private model: Model;
......@@ -110,6 +111,7 @@ export class DebugService implements debug.IDebugService {
this.toDisposeOnSessionEnd = new Map<string, lifecycle.IDisposable[]>();
this.breakpointsToSendOnResourceSaved = new Set<string>();
this._onDidChangeState = new Emitter<debug.State>();
this._onDidNewProcess = new Emitter<debug.IProcess>();
this._onDidEndProcess = new Emitter<debug.IProcess>();
this._onDidCustomEvent = new Emitter<DebugProtocol.Event>();
this.sessionStates = new Map<string, debug.State>();
......@@ -291,7 +293,9 @@ export class DebugService implements debug.IDebugService {
}
private registerSessionListeners(process: Process, session: RawDebugSession): void {
this.toDisposeOnSessionEnd.get(session.getId()).push(session);
this.toDisposeOnSessionEnd.get(session.getId()).push(session.onDidInitialize(event => {
aria.status(nls.localize('debuggingStarted', "Debugging started."));
const sendConfigurationDone = () => {
......@@ -503,6 +507,10 @@ export class DebugService implements debug.IDebugService {
return this._onDidChangeState.event;
}
public get onDidNewProcess(): Event<debug.IProcess> {
return this._onDidNewProcess.event;
}
public get onDidEndProcess(): Event<debug.IProcess> {
return this._onDidEndProcess.event;
}
......@@ -842,6 +850,7 @@ export class DebugService implements debug.IDebugService {
this.viewModel.setMultiProcessView(true);
}
this.updateStateAndEmit(session.getId(), debug.State.Running);
this._onDidNewProcess.fire(process);
return this.telemetryService.publicLog('debugSessionStart', {
type: configuration.type,
......
......@@ -19,6 +19,10 @@ export class MockDebugService implements debug.IDebugService {
return null;
}
public get onDidNewProcess(): Event<debug.IProcess> {
return null;
}
public get onDidEndProcess(): Event<debug.IProcess> {
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册