提交 95f55954 编写于 作者: I isidor

debug: context menu actions for threads

fixes #5643
上级 d9b918a8
......@@ -193,6 +193,44 @@ export class BaseDebugController extends treedefaults.DefaultController {
// call stack
export class CallStackActionProvider implements renderer.IActionProvider {
constructor(@IInstantiationService private instantiationService: IInstantiationService) {
// noop
}
public hasActions(tree: tree.ITree, element: any): boolean {
return false;
}
public getActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
return TPromise.as([]);
}
public hasSecondaryActions(tree: tree.ITree, element: any): boolean {
return element instanceof model.Thread;
}
public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
const actions: actions.Action[] = [];
const thread = <model.Thread>element;
if (thread.stopped) {
actions.push(this.instantiationService.createInstance(debugactions.ContinueAction, debugactions.ContinueAction.ID, debugactions.ContinueAction.LABEL));
actions.push(this.instantiationService.createInstance(debugactions.StepOverDebugAction, debugactions.StepOverDebugAction.ID, debugactions.StepOverDebugAction.LABEL));
actions.push(this.instantiationService.createInstance(debugactions.StepIntoDebugAction, debugactions.StepIntoDebugAction.ID, debugactions.StepIntoDebugAction.LABEL));
actions.push(this.instantiationService.createInstance(debugactions.StepOutDebugAction, debugactions.StepOutDebugAction.ID, debugactions.StepOutDebugAction.LABEL));
} else {
actions.push(this.instantiationService.createInstance(debugactions.PauseAction, debugactions.PauseAction.ID, debugactions.PauseAction.LABEL));
}
return TPromise.as(actions);
}
public getActionItem(tree: tree.ITree, element: any, action: actions.IAction): actionbar.IActionItem {
return null;
}
}
export class CallStackDataSource implements tree.IDataSource {
constructor(@debug.IDebugService private debugService: debug.IDebugService) {
......@@ -366,10 +404,8 @@ export class CallstackAccessibilityProvider implements tree.IAccessibilityProvid
export class VariablesActionProvider implements renderer.IActionProvider {
private instantiationService: IInstantiationService;
constructor(instantiationService: IInstantiationService) {
this.instantiationService = instantiationService;
constructor(private instantiationService: IInstantiationService) {
// noop
}
public hasActions(tree: tree.ITree, element: any): boolean {
......
......@@ -218,11 +218,13 @@ export class CallStackView extends viewlet.CollapsibleViewletView {
public renderBody(container: HTMLElement): void {
dom.addClass(container, 'debug-call-stack');
this.treeContainer = renderViewTree(container);
const actionProvider = this.instantiationService.createInstance(viewer.CallStackActionProvider);
this.tree = new treeimpl.Tree(this.treeContainer, {
dataSource: this.instantiationService.createInstance(viewer.CallStackDataSource),
renderer: this.instantiationService.createInstance(viewer.CallStackRenderer),
accessibilityProvider: this.instantiationService.createInstance(viewer.CallstackAccessibilityProvider)
accessibilityProvider: this.instantiationService.createInstance(viewer.CallstackAccessibilityProvider),
controller: new viewer.BaseDebugController(this.debugService, this.contextMenuService, actionProvider)
}, debugTreeOptions(nls.localize('callStackAriaLabel', "Debug Call Stack")));
this.toDispose.push(this.tree.addListener2('selection', (e: tree.ISelectionEvent) => {
......
......@@ -159,8 +159,11 @@ export class StepOverDebugAction extends AbstractDebugAction {
super(id, label, 'debug-action step-over', debugService, keybindingService);
}
public run(): TPromise<any> {
return this.debugService.next(this.debugService.getViewModel().getFocusedThreadId());
public run(thread: debug.IThread): TPromise<any> {
const threadId = thread && thread instanceof model.Thread ? thread.threadId
: this.debugService.getViewModel().getFocusedThreadId();
return this.debugService.next(threadId);
}
protected isEnabled(state: debug.State): boolean {
......@@ -176,8 +179,11 @@ export class StepIntoDebugAction extends AbstractDebugAction {
super(id, label, 'debug-action step-into', debugService, keybindingService);
}
public run(): TPromise<any> {
return this.debugService.stepIn(this.debugService.getViewModel().getFocusedThreadId());
public run(thread: debug.IThread): TPromise<any> {
const threadId = thread && thread instanceof model.Thread ? thread.threadId
: this.debugService.getViewModel().getFocusedThreadId();
return this.debugService.stepIn(threadId);
}
protected isEnabled(state: debug.State): boolean {
......@@ -193,8 +199,11 @@ export class StepOutDebugAction extends AbstractDebugAction {
super(id, label, 'debug-action step-out', debugService, keybindingService);
}
public run(): TPromise<any> {
return this.debugService.stepOut(this.debugService.getViewModel().getFocusedThreadId());
public run(thread: debug.IThread): TPromise<any> {
const threadId = thread && thread instanceof model.Thread ? thread.threadId
: this.debugService.getViewModel().getFocusedThreadId();
return this.debugService.stepOut(threadId);
}
protected isEnabled(state: debug.State): boolean {
......@@ -235,8 +244,11 @@ export class ContinueAction extends AbstractDebugAction {
super(id, label, 'debug-action continue', debugService, keybindingService);
}
public run(): TPromise<any> {
return this.debugService.continue(this.debugService.getViewModel().getFocusedThreadId());
public run(thread: debug.IThread): TPromise<any> {
const threadId = thread && thread instanceof model.Thread ? thread.threadId
: this.debugService.getViewModel().getFocusedThreadId();
return this.debugService.continue(threadId);
}
protected isEnabled(state: debug.State): boolean {
......@@ -252,8 +264,11 @@ export class PauseAction extends AbstractDebugAction {
super(id, label, 'debug-action pause', debugService, keybindingService);
}
public run(): TPromise<any> {
return this.debugService.pause(this.debugService.getViewModel().getFocusedThreadId());
public run(thread: debug.IThread): TPromise<any> {
const threadId = thread && thread instanceof model.Thread ? thread.threadId
: this.debugService.getViewModel().getFocusedThreadId();
return this.debugService.pause(threadId);
}
protected isEnabled(state: debug.State): boolean {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册