提交 f31a1f4b 编写于 作者: I isidor

debug api polish: comments and remove toggleEnablement

上级 74e689f5
......@@ -905,7 +905,7 @@ export class BreakpointsRenderer implements tree.IRenderer {
public renderElement(tree: tree.ITree, element: any, templateId: string, templateData: any): void {
templateData.toDisposeBeforeRender = lifecycle.dispose(templateData.toDisposeBeforeRender);
templateData.toDisposeBeforeRender.push(dom.addStandardDisposableListener(templateData.checkbox, 'change', (e) => {
this.debugService.toggleEnablement(element);
this.debugService.enableOrDisableBreakpoints(!element.enabled, element);
}));
if (templateId === BreakpointsRenderer.EXCEPTION_BREAKPOINT_TEMPLATE_ID) {
......@@ -989,7 +989,7 @@ export class BreakpointsController extends BaseDebugController {
protected onSpace(tree: tree.ITree, event: IKeyboardEvent): boolean {
super.onSpace(tree, event);
const element = <debug.IEnablement>tree.getFocus();
this.debugService.toggleEnablement(element).done(null, errors.onUnexpectedError);
this.debugService.enableOrDisableBreakpoints(!element.enabled, element).done(null, errors.onUnexpectedError);
return true;
}
......
......@@ -302,34 +302,78 @@ export interface IDebugService {
setFocusedStackFrameAndEvaluate(focusedStackFrame: IStackFrame): TPromise<void>;
/**
* General breakpoints manipulation.
* Adds new breakpoints to the model. Notifies debug adapter of breakpoint changes.
*/
addBreakpoints(rawBreakpoints: IRawBreakpoint[]): TPromise<void[]>;
enableOrDisableAllBreakpoints(enabled: boolean): TPromise<void>;
toggleEnablement(element: IEnablement): TPromise<void>;
/**
* Enables or disables all breakpoints. If breakpoint is passed only enables or disables the passed breakpoint.
* Notifies debug adapter of breakpoint changes.
*/
enableOrDisableBreakpoints(enable: boolean, breakpoint?: IEnablement): TPromise<void>;
/**
* Sets the global activated property for all breakpoints.
* Notifies debug adapter of breakpoint changes.
*/
setBreakpointsActivated(activated: boolean): TPromise<void>;
/**
* Removes all breakpoints. If id is passed only removes the breakpoint associated with that id.
* Notifies debug adapter of breakpoint changes.
*/
removeBreakpoints(id?: string): TPromise<any>;
/**
* Function breakpoints manipulation.
* Adds a new no name function breakpoint. The function breakpoint should be renamed once user enters the name.
*/
addFunctionBreakpoint(): void;
/**
* Renames an already existing function breakpoint.
* Notifies debug adapter of breakpoint changes.
*/
renameFunctionBreakpoint(id: string, newFunctionName: string): TPromise<void>;
/**
* Removes all function breakpoints. If id is passed only removes the function breakpoint with the passed id.
* Notifies debug adapter of breakpoint changes.
*/
removeFunctionBreakpoints(id?: string): TPromise<void>;
/**
* Repl expressions manipulation.
* Adds a new expression to the repl.
*/
addReplExpression(name: string): TPromise<void>;
/**
* Removes all repl expressions.
*/
removeReplExpressions(): void;
/**
* Adds a new log to the repl. Either a string value or a dictionary (used to inspect complex objects printed to the repl).
*/
logToRepl(value: string | { [key: string]: any }, severity?: severity): void;
/**
* Appends new output to the repl.
*/
appendReplOutput(value: string, severity?: severity): void;
/**
* Watch expressions manipulation.
* Adds a new watch expression and evaluates it against the debug adapter.
*/
addWatchExpression(name?: string): TPromise<void>;
/**
* Renames a watch expression and evaluates it against the debug adapter.
*/
renameWatchExpression(id: string, newName: string): TPromise<void>;
/**
* Removes all watch expressions. If id is passed only removes the watch expression with the passed id.
*/
removeWatchExpressions(id?: string): void;
/**
......
......@@ -517,8 +517,8 @@ export class Model implements debug.IModel {
this._onDidChangeBreakpoints.fire();
}
public toggleEnablement(element: debug.IEnablement): void {
element.enabled = !element.enabled;
public setEnablement(element: debug.IEnablement, enable: boolean): void {
element.enabled = enable;
if (element instanceof Breakpoint && !element.enabled) {
var breakpoint = <Breakpoint> element;
breakpoint.lineNumber = breakpoint.desiredLineNumber;
......@@ -528,16 +528,16 @@ export class Model implements debug.IModel {
this._onDidChangeBreakpoints.fire();
}
public enableOrDisableAllBreakpoints(enabled: boolean): void {
public enableOrDisableAllBreakpoints(enable: boolean): void {
this.breakpoints.forEach(bp => {
bp.enabled = enabled;
if (!enabled) {
bp.enabled = enable;
if (!enable) {
bp.lineNumber = bp.desiredLineNumber;
bp.verified = false;
}
});
this.exceptionBreakpoints.forEach(ebp => ebp.enabled = enabled);
this.functionBreakpoints.forEach(fbp => fbp.enabled = enabled);
this.exceptionBreakpoints.forEach(ebp => ebp.enabled = enable);
this.functionBreakpoints.forEach(fbp => fbp.enabled = enable);
this._onDidChangeBreakpoints.fire();
}
......
......@@ -303,7 +303,7 @@ export class ToggleEnablementAction extends AbstractDebugAction {
}
public run(element: debug.IEnablement): TPromise<any> {
return this.debugService.toggleEnablement(element);
return this.debugService.enableOrDisableBreakpoints(!element.enabled, element);
}
}
......@@ -317,7 +317,7 @@ export class EnableAllBreakpointsAction extends AbstractDebugAction {
}
public run(): TPromise<any> {
return this.debugService.enableOrDisableAllBreakpoints(true);
return this.debugService.enableOrDisableBreakpoints(true);
}
protected isEnabled(state: debug.State): boolean {
......@@ -336,7 +336,7 @@ export class DisableAllBreakpointsAction extends AbstractDebugAction {
}
public run(): TPromise<any> {
return this.debugService.enableOrDisableAllBreakpoints(false);
return this.debugService.enableOrDisableBreakpoints(false);
}
protected isEnabled(state: debug.State): boolean {
......
......@@ -426,21 +426,20 @@ export class DebugService implements debug.IDebugService {
}
}
public enableOrDisableAllBreakpoints(enabled: boolean): TPromise<void>{
this.model.enableOrDisableAllBreakpoints(enabled);
return this.sendAllBreakpoints();
}
public enableOrDisableBreakpoints(enable: boolean, breakpoint?: debug.IEnablement): TPromise<void>{
if (breakpoint) {
this.model.setEnablement(breakpoint, enable);
if (breakpoint instanceof model.Breakpoint) {
return this.sendBreakpoints((<model.Breakpoint> breakpoint).source.uri);
} else if (breakpoint instanceof model.FunctionBreakpoint) {
return this.sendFunctionBreakpoints();
}
public toggleEnablement(element: debug.IEnablement): TPromise<void> {
this.model.toggleEnablement(element);
if (element instanceof model.Breakpoint) {
const breakpoint = <model.Breakpoint> element;
return this.sendBreakpoints(breakpoint.source.uri);
} else if (element instanceof model.FunctionBreakpoint) {
return this.sendFunctionBreakpoints();
return this.sendExceptionBreakpoints();
}
return this.sendExceptionBreakpoints();
this.model.enableOrDisableAllBreakpoints(enable);
return this.sendAllBreakpoints();
}
public addBreakpoints(rawBreakpoints: debug.IRawBreakpoint[]): TPromise<void[]> {
......
......@@ -69,7 +69,7 @@ suite('Debug - Model', () => {
model.getBreakpoints().forEach(bp => {
assert.equal(bp.enabled, false);
});
model.toggleEnablement(bp);
model.setEnablement(bp, true);
assert.equal(bp.enabled, true);
model.removeBreakpoints(model.getBreakpoints().filter(bp => bp.source.uri.toString() === modelUri1.toString()));
......
......@@ -41,11 +41,7 @@ export class MockDebugService implements debug.IDebugService {
return TPromise.as(null);
}
public enableOrDisableAllBreakpoints(enabled: boolean): TPromise<void> {
return TPromise.as(null);
}
public toggleEnablement(element: debug.IEnablement): TPromise<void> {
public enableOrDisableBreakpoints(enabled: boolean): TPromise<void> {
return TPromise.as(null);
}
......@@ -73,9 +69,7 @@ export class MockDebugService implements debug.IDebugService {
public removeReplExpressions(): void {}
public logToRepl(value: string, severity?: severity): void;
public logToRepl(value: { [key: string]: any }, severity?: severity): void;
public logToRepl(value: any, severity?: severity): void {}
public logToRepl(value: string | { [key: string]: any }, severity?: severity): void {}
public appendReplOutput(value: string, severity?: severity): void {}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册