From 7a0b01b23485c746dc82ca71f426aa2cee66643a Mon Sep 17 00:00:00 2001 From: isidor Date: Tue, 19 Apr 2016 14:48:39 +0200 Subject: [PATCH] debug polish: api renaming, removeBreakpoints takes id --- .../parts/debug/browser/debugViewer.ts | 4 ++-- src/vs/workbench/parts/debug/browser/repl.ts | 2 +- src/vs/workbench/parts/debug/common/debug.ts | 19 ++++++++++++++----- .../parts/debug/common/debugModel.ts | 6 +++--- .../debug/electron-browser/debugActions.ts | 10 +++++----- .../debug/electron-browser/debugService.ts | 17 +++++++++-------- .../debug/test/common/debugModel.test.ts | 6 +++--- .../debug/test/common/mockDebugService.ts | 6 +++--- 8 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/vs/workbench/parts/debug/browser/debugViewer.ts b/src/vs/workbench/parts/debug/browser/debugViewer.ts index a13b37fb78b..cd4297cda68 100644 --- a/src/vs/workbench/parts/debug/browser/debugViewer.ts +++ b/src/vs/workbench/parts/debug/browser/debugViewer.ts @@ -100,7 +100,7 @@ function renderRenameBox(debugService: debug.IDebugService, contextViewService: if (element instanceof model.Expression && renamed && inputBox.value) { debugService.renameWatchExpression(element.getId(), inputBox.value).done(null, errors.onUnexpectedError); } else if (element instanceof model.Expression && !element.name) { - debugService.clearWatchExpressions(element.getId()); + debugService.removeWatchExpressions(element.getId()); } else if (element instanceof model.FunctionBreakpoint && renamed && inputBox.value) { debugService.renameFunctionBreakpoint(element.getId(), inputBox.value).done(null, errors.onUnexpectedError); } else if (element instanceof model.FunctionBreakpoint && !element.name) { @@ -730,7 +730,7 @@ export class WatchExpressionsController extends BaseDebugController { const element = tree.getFocus(); if (element instanceof model.Expression) { const we = element; - this.debugService.clearWatchExpressions(we.getId()); + this.debugService.removeWatchExpressions(we.getId()); return true; } diff --git a/src/vs/workbench/parts/debug/browser/repl.ts b/src/vs/workbench/parts/debug/browser/repl.ts index 258faae6f3b..ece4cc1f6d9 100644 --- a/src/vs/workbench/parts/debug/browser/repl.ts +++ b/src/vs/workbench/parts/debug/browser/repl.ts @@ -73,7 +73,7 @@ export class Repl extends Panel { } private registerListeners(): void { - this.toDispose.push(this.debugService.getModel().onDidChangeREPLElements(() => { + this.toDispose.push(this.debugService.getModel().onDidChangeReplElements(() => { this.onReplElementsUpdated(); })); this.toDispose.push(this.eventService.addListener2(EventType.COMPOSITE_OPENED, (e: CompositeEvent) => { diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index eac1fbb28a7..9253fa784de 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -182,7 +182,7 @@ export interface IModel extends ITreeElement { onDidChangeBreakpoints: Event; onDidChangeCallStack: Event; onDidChangeWatchExpressions: Event; - onDidChangeREPLElements: Event; + onDidChangeReplElements: Event; }; // service enums @@ -302,27 +302,36 @@ export interface IDebugService { setFocusedStackFrameAndEvaluate(focusedStackFrame: IStackFrame): TPromise; /** - * Sets breakpoints for a model. Does not send them to the adapter. + * General breakpoints manipulation. */ setBreakpointsForModel(modelUri: uri, rawData: IRawBreakpoint[]): void; toggleBreakpoint(IRawBreakpoint): TPromise; enableOrDisableAllBreakpoints(enabled: boolean): TPromise; toggleEnablement(element: IEnablement): TPromise; setBreakpointsActivated(activated: boolean): TPromise; - removeAllBreakpoints(): TPromise; + removeBreakpoints(id?: string): TPromise; + /** + * Function breakpoints manipulation. + */ addFunctionBreakpoint(): void; renameFunctionBreakpoint(id: string, newFunctionName: string): TPromise; removeFunctionBreakpoints(id?: string): TPromise; + /** + * Repl expressions manipulation. + */ addReplExpression(name: string): TPromise; - clearReplExpressions(): void; + removeReplExpressions(): void; logToRepl(value: string | { [key: string]: any }, severity?: severity): void; appendReplOutput(value: string, severity?: severity): void; + /** + * Watch expressions manipulation. + */ addWatchExpression(name?: string): TPromise; renameWatchExpression(id: string, newName: string): TPromise; - clearWatchExpressions(id?: string): void; + removeWatchExpressions(id?: string): void; /** * Creates a new debug session. Depending on the configuration will either 'launch' or 'attach'. diff --git a/src/vs/workbench/parts/debug/common/debugModel.ts b/src/vs/workbench/parts/debug/common/debugModel.ts index 6c44c162059..1a78fe39804 100644 --- a/src/vs/workbench/parts/debug/common/debugModel.ts +++ b/src/vs/workbench/parts/debug/common/debugModel.ts @@ -419,7 +419,7 @@ export class Model implements debug.IModel { return this._onDidChangeWatchExpressions.event; } - public get onDidChangeREPLElements(): Event { + public get onDidChangeReplElements(): Event { return this._onDidChangeREPLElements.event; } @@ -633,7 +633,7 @@ export class Model implements debug.IModel { } } - public clearReplExpressions(): void { + public removeReplExpressions(): void { if (this.replElements.length > 0) { this.replElements = []; this._onDidChangeREPLElements.fire(); @@ -694,7 +694,7 @@ export class Model implements debug.IModel { this._onDidChangeWatchExpressions.fire(); } - public clearWatchExpressions(id: string = null): void { + public removeWatchExpressions(id: string = null): void { this.watchExpressions = id ? this.watchExpressions.filter(we => we.getId() !== id) : []; this._onDidChangeWatchExpressions.fire(); } diff --git a/src/vs/workbench/parts/debug/electron-browser/debugActions.ts b/src/vs/workbench/parts/debug/electron-browser/debugActions.ts index d7db208252c..ac6742b76e3 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugActions.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugActions.ts @@ -285,7 +285,7 @@ export class RemoveAllBreakpointsAction extends AbstractDebugAction { } public run(): TPromise { - return TPromise.join([this.debugService.removeAllBreakpoints(), this.debugService.removeFunctionBreakpoints()]); + return TPromise.join([this.debugService.removeBreakpoints(), this.debugService.removeFunctionBreakpoints()]); } protected isEnabled(state: debug.State): boolean { @@ -691,7 +691,7 @@ export class RemoveWatchExpressionAction extends AbstractDebugAction { } public run(expression: model.Expression): TPromise { - this.debugService.clearWatchExpressions(expression.getId()); + this.debugService.removeWatchExpressions(expression.getId()); return TPromise.as(null); } } @@ -706,7 +706,7 @@ export class RemoveAllWatchExpressionsAction extends AbstractDebugAction { } public run(): TPromise { - this.debugService.clearWatchExpressions(); + this.debugService.removeWatchExpressions(); return TPromise.as(null); } @@ -728,7 +728,7 @@ export class ClearReplAction extends AbstractDebugAction { } public run(): TPromise { - this.debugService.clearReplExpressions(); + this.debugService.removeReplExpressions(); // focus back to repl return this.panelService.openPanel(debug.REPL_ID, true); @@ -771,7 +771,7 @@ export class ToggleReplAction extends AbstractDebugAction { } private registerListeners(): void { - this.toDispose.push(this.debugService.getModel().onDidChangeREPLElements(() => { + this.toDispose.push(this.debugService.getModel().onDidChangeReplElements(() => { if (!this.isReplVisible()) { this.class = 'debug-action toggle-repl notification'; } diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 6a95cdc5d91..5b56bc05ef8 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -460,9 +460,10 @@ export class DebugService implements debug.IDebugService { return this.sendExceptionBreakpoints(); } - public removeAllBreakpoints(): TPromise { - const urisToClear = arrays.distinct(this.model.getBreakpoints(), bp => bp.source.uri.toString()).map(bp => bp.source.uri); - this.model.removeBreakpoints(this.model.getBreakpoints()); + public removeBreakpoints(id?: string): TPromise { + const toRemove = this.model.getBreakpoints().filter(bp => !id || bp.getId() === id); + const urisToClear = arrays.distinct(toRemove, bp => bp.source.uri.toString()).map(bp => bp.source.uri); + this.model.removeBreakpoints(toRemove); return TPromise.join(urisToClear.map(uri => this.sendBreakpoints(uri))); } @@ -499,8 +500,8 @@ export class DebugService implements debug.IDebugService { this.model.appendReplOutput(value, severity); } - public clearReplExpressions(): void { - this.model.clearReplExpressions(); + public removeReplExpressions(): void { + this.model.removeReplExpressions(); } public addWatchExpression(name: string): TPromise { @@ -511,12 +512,12 @@ export class DebugService implements debug.IDebugService { return this.model.renameWatchExpression(this.session, this.viewModel.getFocusedStackFrame(), id, newName); } - public clearWatchExpressions(id?: string): void { - this.model.clearWatchExpressions(id); + public removeWatchExpressions(id?: string): void { + this.model.removeWatchExpressions(id); } public createSession(noDebug: boolean, changeViewState = !this.partService.isSideBarHidden()): TPromise { - this.clearReplExpressions(); + this.removeReplExpressions(); return this.textFileService.saveAll() .then(() => this.extensionService.onReady() diff --git a/src/vs/workbench/parts/debug/test/common/debugModel.test.ts b/src/vs/workbench/parts/debug/test/common/debugModel.test.ts index d1aa9af7586..c49644e2a2d 100644 --- a/src/vs/workbench/parts/debug/test/common/debugModel.test.ts +++ b/src/vs/workbench/parts/debug/test/common/debugModel.test.ts @@ -299,7 +299,7 @@ suite('Debug - Model', () => { model.clearWatchExpressionValues(); assertWatchExpressions(model.getWatchExpressions(), 'new_name'); - model.clearWatchExpressions(); + model.removeWatchExpressions(); assert.equal(model.getWatchExpressions().length, 0); }); @@ -317,7 +317,7 @@ suite('Debug - Model', () => { assert.equal(( re).reference, 0); }); - model.clearReplExpressions(); + model.removeReplExpressions(); assert.equal(model.getReplElements().length, 0); }); @@ -352,7 +352,7 @@ suite('Debug - Model', () => { assert.equal(element.value, 'Object'); assert.deepEqual(element.valueObj, keyValueObject); - model.clearReplExpressions(); + model.removeReplExpressions(); assert.equal(model.getReplElements().length, 0); }); diff --git a/src/vs/workbench/parts/debug/test/common/mockDebugService.ts b/src/vs/workbench/parts/debug/test/common/mockDebugService.ts index 8c312d623ca..0e16c3aac06 100644 --- a/src/vs/workbench/parts/debug/test/common/mockDebugService.ts +++ b/src/vs/workbench/parts/debug/test/common/mockDebugService.ts @@ -55,7 +55,7 @@ export class MockDebugService implements debug.IDebugService { return TPromise.as(null); } - public removeAllBreakpoints(): TPromise { + public removeBreakpoints(): TPromise { return TPromise.as(null); } @@ -73,7 +73,7 @@ export class MockDebugService implements debug.IDebugService { return TPromise.as(null); } - public clearReplExpressions(): void {} + public removeReplExpressions(): void {} public logToRepl(value: string, severity?: severity): void; public logToRepl(value: { [key: string]: any }, severity?: severity): void; @@ -89,7 +89,7 @@ export class MockDebugService implements debug.IDebugService { return TPromise.as(null); } - public clearWatchExpressions(id?: string): void {} + public removeWatchExpressions(id?: string): void {} public createSession(noDebug: boolean): TPromise { return TPromise.as(null); -- GitLab