Skip to content

Commit

Permalink
debug polish: api renaming, removeBreakpoints takes id
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Apr 19, 2016
1 parent 8324ab0 commit 7a0b01b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/vs/workbench/parts/debug/browser/debugViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -730,7 +730,7 @@ export class WatchExpressionsController extends BaseDebugController {
const element = tree.getFocus();
if (element instanceof model.Expression) {
const we = <model.Expression> element;
this.debugService.clearWatchExpressions(we.getId());
this.debugService.removeWatchExpressions(we.getId());

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/parts/debug/browser/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
19 changes: 14 additions & 5 deletions src/vs/workbench/parts/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export interface IModel extends ITreeElement {
onDidChangeBreakpoints: Event<void>;
onDidChangeCallStack: Event<void>;
onDidChangeWatchExpressions: Event<IExpression>;
onDidChangeREPLElements: Event<void>;
onDidChangeReplElements: Event<void>;
};

// service enums
Expand Down Expand Up @@ -302,27 +302,36 @@ export interface IDebugService {
setFocusedStackFrameAndEvaluate(focusedStackFrame: IStackFrame): TPromise<void>;

/**
* Sets breakpoints for a model. Does not send them to the adapter.
* General breakpoints manipulation.
*/
setBreakpointsForModel(modelUri: uri, rawData: IRawBreakpoint[]): void;
toggleBreakpoint(IRawBreakpoint): TPromise<void>;
enableOrDisableAllBreakpoints(enabled: boolean): TPromise<void>;
toggleEnablement(element: IEnablement): TPromise<void>;
setBreakpointsActivated(activated: boolean): TPromise<void>;
removeAllBreakpoints(): TPromise<any>;
removeBreakpoints(id?: string): TPromise<any>;

/**
* Function breakpoints manipulation.
*/
addFunctionBreakpoint(): void;
renameFunctionBreakpoint(id: string, newFunctionName: string): TPromise<void>;
removeFunctionBreakpoints(id?: string): TPromise<void>;

/**
* Repl expressions manipulation.
*/
addReplExpression(name: string): TPromise<void>;
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<void>;
renameWatchExpression(id: string, newName: string): TPromise<void>;
clearWatchExpressions(id?: string): void;
removeWatchExpressions(id?: string): void;

/**
* Creates a new debug session. Depending on the configuration will either 'launch' or 'attach'.
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/parts/debug/common/debugModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export class Model implements debug.IModel {
return this._onDidChangeWatchExpressions.event;
}

public get onDidChangeREPLElements(): Event<void> {
public get onDidChangeReplElements(): Event<void> {
return this._onDidChangeREPLElements.event;
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
}
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/parts/debug/electron-browser/debugActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class RemoveAllBreakpointsAction extends AbstractDebugAction {
}

public run(): TPromise<any> {
return TPromise.join([this.debugService.removeAllBreakpoints(), this.debugService.removeFunctionBreakpoints()]);
return TPromise.join([this.debugService.removeBreakpoints(), this.debugService.removeFunctionBreakpoints()]);
}

protected isEnabled(state: debug.State): boolean {
Expand Down Expand Up @@ -691,7 +691,7 @@ export class RemoveWatchExpressionAction extends AbstractDebugAction {
}

public run(expression: model.Expression): TPromise<any> {
this.debugService.clearWatchExpressions(expression.getId());
this.debugService.removeWatchExpressions(expression.getId());
return TPromise.as(null);
}
}
Expand All @@ -706,7 +706,7 @@ export class RemoveAllWatchExpressionsAction extends AbstractDebugAction {
}

public run(): TPromise<any> {
this.debugService.clearWatchExpressions();
this.debugService.removeWatchExpressions();
return TPromise.as(null);
}

Expand All @@ -728,7 +728,7 @@ export class ClearReplAction extends AbstractDebugAction {
}

public run(): TPromise<any> {
this.debugService.clearReplExpressions();
this.debugService.removeReplExpressions();

// focus back to repl
return this.panelService.openPanel(debug.REPL_ID, true);
Expand Down Expand Up @@ -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';
}
Expand Down
17 changes: 9 additions & 8 deletions src/vs/workbench/parts/debug/electron-browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,10 @@ export class DebugService implements debug.IDebugService {
return this.sendExceptionBreakpoints();
}

public removeAllBreakpoints(): TPromise<any> {
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<any> {
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)));
}
Expand Down Expand Up @@ -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<void> {
Expand All @@ -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<any> {
this.clearReplExpressions();
this.removeReplExpressions();

return this.textFileService.saveAll()
.then(() => this.extensionService.onReady()
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/parts/debug/test/common/debugModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ suite('Debug - Model', () => {
model.clearWatchExpressionValues();
assertWatchExpressions(model.getWatchExpressions(), 'new_name');

model.clearWatchExpressions();
model.removeWatchExpressions();
assert.equal(model.getWatchExpressions().length, 0);
});

Expand All @@ -317,7 +317,7 @@ suite('Debug - Model', () => {
assert.equal((<debugmodel.Expression> re).reference, 0);
});

model.clearReplExpressions();
model.removeReplExpressions();
assert.equal(model.getReplElements().length, 0);
});

Expand Down Expand Up @@ -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);
});

Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/parts/debug/test/common/mockDebugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class MockDebugService implements debug.IDebugService {
return TPromise.as(null);
}

public removeAllBreakpoints(): TPromise<any> {
public removeBreakpoints(): TPromise<any> {
return TPromise.as(null);
}

Expand All @@ -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;
Expand All @@ -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<any> {
return TPromise.as(null);
Expand Down

0 comments on commit 7a0b01b

Please sign in to comment.