From f1404198c393117f3573466bc0cac2c4b9c953e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81=20Weinand?= Date: Fri, 16 Mar 2018 17:08:31 +0100 Subject: [PATCH] proposed logMessage API; fixes #45643 --- src/vs/vscode.proposed.d.ts | 7 +++++++ .../electron-browser/mainThreadDebugService.ts | 9 ++++++--- src/vs/workbench/api/node/extHost.protocol.ts | 16 +++++++++------- src/vs/workbench/api/node/extHostDebugService.ts | 15 ++++++++------- src/vs/workbench/api/node/extHostTypes.ts | 14 +++++++++----- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 942579406ae..2078ed985d2 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -378,6 +378,13 @@ declare module 'vscode' { debugAdapterExecutable?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult; } + export interface Breakpoint { + /** + * An optional message that gets logged when this breakpoint is hit. + */ + readonly logMessage?: string; + } + //#endregion //#region Rob, Matt: logging diff --git a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts index c7a0ba78a06..044af5fd345 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts @@ -101,7 +101,8 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape { lineNumber: l.line + 1, column: l.character > 0 ? l.character + 1 : 0, condition: l.condition, - hitCondition: l.hitCondition + hitCondition: l.hitCondition, + logMessage: l.logMessage } ); this.debugService.addBreakpoints(uri.revive(dto.uri), rawbps); @@ -126,9 +127,10 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape { type: 'function', id: fbp.getId(), enabled: fbp.enabled, - functionName: fbp.name, + condition: fbp.condition, hitCondition: fbp.hitCondition, - /* condition: fbp.condition */ + logMessage: fbp.logMessage, + functionName: fbp.name }; } else { const sbp = bp; @@ -138,6 +140,7 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape { enabled: sbp.enabled, condition: sbp.condition, hitCondition: sbp.hitCondition, + logMessage: sbp.logMessage, uri: sbp.uri, line: sbp.lineNumber > 0 ? sbp.lineNumber - 1 : 0, character: (typeof sbp.column === 'number' && sbp.column > 0) ? sbp.column - 1 : 0, diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 09e84277e8b..878ea29bb67 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -725,21 +725,22 @@ export interface ExtHostTaskShape { $provideTasks(handle: number): TPromise; } -export interface IFunctionBreakpointDto { - type: 'function'; +export interface IBreakpointDto { + type: string; id?: string; enabled: boolean; condition?: string; hitCondition?: string; + logMessage?: string; +} + +export interface IFunctionBreakpointDto extends IBreakpointDto { + type: 'function'; functionName: string; } -export interface ISourceBreakpointDto { +export interface ISourceBreakpointDto extends IBreakpointDto { type: 'source'; - id?: string; - enabled: boolean; - condition?: string; - hitCondition?: string; uri: UriComponents; line: number; character: number; @@ -759,6 +760,7 @@ export interface ISourceMultiBreakpointDto { enabled: boolean; condition?: string; hitCondition?: string; + logMessage?: string; line: number; character: number; }[]; diff --git a/src/vs/workbench/api/node/extHostDebugService.ts b/src/vs/workbench/api/node/extHostDebugService.ts index e6b705d5238..39e58cacd5f 100644 --- a/src/vs/workbench/api/node/extHostDebugService.ts +++ b/src/vs/workbench/api/node/extHostDebugService.ts @@ -111,18 +111,15 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { if (!this._breakpoints.has(bpd.id)) { let bp: vscode.Breakpoint; if (bpd.type === 'function') { - bp = new FunctionBreakpoint(bpd.functionName, bpd.enabled, bpd.condition, bpd.hitCondition); + bp = new FunctionBreakpoint(bpd.functionName, bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage); } else { const uri = URI.revive(bpd.uri); - bp = new SourceBreakpoint(new Location(uri, new Position(bpd.line, bpd.character)), bpd.enabled, bpd.condition, bpd.hitCondition); + bp = new SourceBreakpoint(new Location(uri, new Position(bpd.line, bpd.character)), bpd.enabled, bpd.condition, bpd.hitCondition, bpd.logMessage); } bp['_id'] = bpd.id; this._breakpoints.set(bpd.id, bp); a.push(bp); - } - - } } @@ -145,12 +142,14 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { fbp.enabled = bpd.enabled; fbp.condition = bpd.condition; fbp.hitCondition = bpd.hitCondition; + fbp.logMessage = bpd.logMessage; fbp.functionName = bpd.functionName; } else if (bp instanceof SourceBreakpoint && bpd.type === 'source') { const sbp = bp; sbp.enabled = bpd.enabled; sbp.condition = bpd.condition; sbp.hitCondition = bpd.hitCondition; + sbp.logMessage = bpd.logMessage; sbp.location = new Location(URI.revive(bpd.uri), new Position(bpd.line, bpd.character)); } c.push(bp); @@ -206,6 +205,7 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { enabled: bp.enabled, condition: bp.condition, hitCondition: bp.hitCondition, + logMessage: bp.logMessage, line: bp.location.range.start.line, character: bp.location.range.start.character }); @@ -214,9 +214,10 @@ export class ExtHostDebugService implements ExtHostDebugServiceShape { type: 'function', id: bp['_id'], enabled: bp.enabled, - functionName: bp.functionName, hitCondition: bp.hitCondition, - condition: bp.condition + logMessage: bp.logMessage, + condition: bp.condition, + functionName: bp.functionName }); } } diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index 674a6aeb7f0..668c6aa9a4c 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -1673,8 +1673,9 @@ export class Breakpoint { readonly enabled: boolean; readonly condition?: string; readonly hitCondition?: string; + readonly logMessage?: string; - protected constructor(enabled?: boolean, condition?: string, hitCondition?: string) { + protected constructor(enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string) { this.enabled = typeof enabled === 'boolean' ? enabled : true; if (typeof condition === 'string') { this.condition = condition; @@ -1682,14 +1683,17 @@ export class Breakpoint { if (typeof hitCondition === 'string') { this.hitCondition = hitCondition; } + if (typeof logMessage === 'string') { + this.logMessage = logMessage; + } } } export class SourceBreakpoint extends Breakpoint { readonly location: Location; - constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string) { - super(enabled, condition, hitCondition); + constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string) { + super(enabled, condition, hitCondition, logMessage); if (location === null) { throw illegalArgument('location'); } @@ -1700,8 +1704,8 @@ export class SourceBreakpoint extends Breakpoint { export class FunctionBreakpoint extends Breakpoint { readonly functionName: string; - constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string) { - super(enabled, condition, hitCondition); + constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string) { + super(enabled, condition, hitCondition, logMessage); if (!functionName) { throw illegalArgument('functionName'); } -- GitLab