提交 f168d882 编写于 作者: A Andre Weinand

final tracker API; for #62843

上级 72812c41
...@@ -508,15 +508,30 @@ declare module 'vscode' { ...@@ -508,15 +508,30 @@ declare module 'vscode' {
* A Debug Adapter Tracker is a means to track the communication between VS Code and a Debug Adapter. * A Debug Adapter Tracker is a means to track the communication between VS Code and a Debug Adapter.
*/ */
export interface DebugAdapterTracker { export interface DebugAdapterTracker {
// VS Code -> Debug Adapter /**
startDebugAdapter?(): void; * A session with the debug adapter is about to be started.
toDebugAdapter?(message: any): void; */
stopDebugAdapter?(): void; onWillStartSession?(): void;
/**
// Debug Adapter -> VS Code * The debug adapter is about to receive a Debug Adapter Protocol message from VS Code.
fromDebugAdapter?(message: any): void; */
debugAdapterError?(error: Error): void; onWillReceiveMessage?(message: any): void;
debugAdapterExit?(code?: number, signal?: string): void; /**
* The debug adapter has sent a Debug Adapter Protocol message to VS Code.
*/
onDidSendMessage?(message: any): void;
/**
* The debug adapter session is about to be stopped.
*/
onWillStopSession?(): void;
/**
* An error with the debug adapter has occured.
*/
onError?(error: Error): void;
/**
* The debug adapter has exited with the given exit code or signal.
*/
onExit?(code: number | undefined, signal: string | undefined): void;
} }
export interface DebugAdapterTrackerFactory { export interface DebugAdapterTrackerFactory {
...@@ -543,6 +558,18 @@ declare module 'vscode' { ...@@ -543,6 +558,18 @@ declare module 'vscode' {
// deprecated // deprecated
export interface DebugAdapterTracker {
// VS Code -> Debug Adapter
startDebugAdapter?(): void;
toDebugAdapter?(message: any): void;
stopDebugAdapter?(): void;
// Debug Adapter -> VS Code
fromDebugAdapter?(message: any): void;
debugAdapterError?(error: Error): void;
debugAdapterExit?(code?: number, signal?: string): void;
}
export interface DebugConfigurationProvider { export interface DebugConfigurationProvider {
/** /**
* Deprecated, use DebugAdapterDescriptorFactory.provideDebugAdapter instead. * Deprecated, use DebugAdapterDescriptorFactory.provideDebugAdapter instead.
......
...@@ -420,7 +420,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -420,7 +420,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
da.onMessage(message => { da.onMessage(message => {
if (tracker) { if (tracker) {
tracker.fromDebugAdapter(message); tracker.onDidSendMessage(message);
} }
// DA -> VS Code // DA -> VS Code
...@@ -430,19 +430,19 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -430,19 +430,19 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
}); });
da.onError(err => { da.onError(err => {
if (tracker) { if (tracker) {
tracker.debugAdapterError(err); tracker.onError(err);
} }
this._debugServiceProxy.$acceptDAError(debugAdapterHandle, err.name, err.message, err.stack); this._debugServiceProxy.$acceptDAError(debugAdapterHandle, err.name, err.message, err.stack);
}); });
da.onExit(code => { da.onExit(code => {
if (tracker) { if (tracker) {
tracker.debugAdapterExit(code, null); tracker.onExit(code, undefined);
} }
this._debugServiceProxy.$acceptDAExit(debugAdapterHandle, code, null); this._debugServiceProxy.$acceptDAExit(debugAdapterHandle, code, null);
}); });
if (tracker) { if (tracker) {
tracker.startDebugAdapter(); tracker.onWillStartSession();
} }
return da.startSession(); return da.startSession();
...@@ -460,7 +460,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -460,7 +460,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
const tracker = this._debugAdaptersTrackers.get(debugAdapterHandle); // TODO@AW: same handle? const tracker = this._debugAdaptersTrackers.get(debugAdapterHandle); // TODO@AW: same handle?
if (tracker) { if (tracker) {
tracker.toDebugAdapter(message); tracker.onWillReceiveMessage(message);
} }
const da = this._debugAdapters.get(debugAdapterHandle); const da = this._debugAdapters.get(debugAdapterHandle);
...@@ -475,7 +475,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { ...@@ -475,7 +475,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape {
const tracker = this._debugAdaptersTrackers.get(debugAdapterHandle); const tracker = this._debugAdaptersTrackers.get(debugAdapterHandle);
this._debugAdaptersTrackers.delete(debugAdapterHandle); this._debugAdaptersTrackers.delete(debugAdapterHandle);
if (tracker) { if (tracker) {
tracker.stopDebugAdapter(); tracker.onWillStopSession();
} }
const da = this._debugAdapters.get(debugAdapterHandle); const da = this._debugAdapters.get(debugAdapterHandle);
...@@ -929,28 +929,28 @@ class MultiTracker implements vscode.DebugAdapterTracker { ...@@ -929,28 +929,28 @@ class MultiTracker implements vscode.DebugAdapterTracker {
constructor(private trackers: vscode.DebugAdapterTracker[]) { constructor(private trackers: vscode.DebugAdapterTracker[]) {
} }
startDebugAdapter(): void { onWillStartSession(): void {
this.trackers.forEach(t => t.startDebugAdapter ? t.startDebugAdapter() : void 0); this.trackers.forEach(t => t.onWillStartSession ? t.onWillStartSession() : (t.startDebugAdapter ? t.startDebugAdapter() : void 0));
} }
toDebugAdapter(message: any): void { onWillReceiveMessage(message: any): void {
this.trackers.forEach(t => t.toDebugAdapter ? t.toDebugAdapter(message) : void 0); this.trackers.forEach(t => t.onWillReceiveMessage ? t.onWillReceiveMessage(message) : (t.toDebugAdapter ? t.toDebugAdapter(message) : void 0));
} }
fromDebugAdapter(message: any): void { onDidSendMessage(message: any): void {
this.trackers.forEach(t => t.fromDebugAdapter ? t.fromDebugAdapter(message) : void 0); this.trackers.forEach(t => t.onDidSendMessage ? t.onDidSendMessage(message) : (t.fromDebugAdapter ? t.fromDebugAdapter(message) : void 0));
} }
debugAdapterError(error: Error): void { onWillStopSession(): void {
this.trackers.forEach(t => t.debugAdapterError ? t.debugAdapterError(error) : void 0); this.trackers.forEach(t => t.onWillStopSession ? t.onWillStopSession() : (t.stopDebugAdapter ? t.stopDebugAdapter() : void 0));
} }
debugAdapterExit(code: number, signal: string): void { onError(error: Error): void {
this.trackers.forEach(t => t.debugAdapterExit ? t.debugAdapterExit(code, signal) : void 0); this.trackers.forEach(t => t.onError ? t.onError(error) : (t.debugAdapterError ? t.debugAdapterError(error) : void 0));
} }
stopDebugAdapter(): void { onExit(code: number, signal: string): void {
this.trackers.forEach(t => t.stopDebugAdapter ? t.stopDebugAdapter() : void 0); this.trackers.forEach(t => t.onExit ? t.onExit(code, signal) : (t.debugAdapterExit ? t.debugAdapterExit(code, signal) : void 0));
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册