提交 7a0b01b2 编写于 作者: I isidor

debug polish: api renaming, removeBreakpoints takes id

上级 8324ab0c
......@@ -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 = <model.Expression> element;
this.debugService.clearWatchExpressions(we.getId());
this.debugService.removeWatchExpressions(we.getId());
return true;
}
......
......@@ -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) => {
......
......@@ -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
......@@ -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'.
......
......@@ -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;
}
......@@ -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();
}
......
......@@ -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 {
......@@ -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);
}
}
......@@ -706,7 +706,7 @@ export class RemoveAllWatchExpressionsAction extends AbstractDebugAction {
}
public run(): TPromise<any> {
this.debugService.clearWatchExpressions();
this.debugService.removeWatchExpressions();
return TPromise.as(null);
}
......@@ -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);
......@@ -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';
}
......
......@@ -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)));
}
......@@ -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> {
......@@ -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()
......
......@@ -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((<debugmodel.Expression> 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);
});
......
......@@ -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);
}
......@@ -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<any> {
return TPromise.as(null);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册