提交 37b76b08 编写于 作者: I isidor

debug: transform actions to commands and contribute them properly

上级 cfd4cb8c
......@@ -15,10 +15,8 @@ import { MenuId, IMenu, IMenuService } from 'vs/platform/actions/common/actions'
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { renderViewTree } from 'vs/workbench/contrib/debug/browser/baseDebugView';
import { IAction } from 'vs/base/common/actions';
import { RestartAction, StopAction, ContinueAction, StepOverAction, StepIntoAction, StepOutAction, PauseAction, RestartFrameAction, TerminateThreadAction, CopyStackTraceAction } from 'vs/workbench/contrib/debug/browser/debugActions';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IViewletPanelOptions, ViewletPanel } from 'vs/workbench/browser/parts/views/panelViewlet';
import { ILabelService } from 'vs/platform/label/common/label';
......@@ -264,32 +262,13 @@ export class CallStackView extends ViewletPanel {
}
private onContextMenu(e: ITreeContextMenuEvent<CallStackItem>): void {
const actions: IAction[] = [];
const element = e.element;
if (isDebugSession(element)) {
this.callStackItemType.set('session');
actions.push(this.instantiationService.createInstance(RestartAction, RestartAction.ID, RestartAction.LABEL));
actions.push(new StopAction(StopAction.ID, StopAction.LABEL, this.debugService, this.keybindingService));
} else if (element instanceof Thread) {
this.callStackItemType.set('thread');
const thread = <Thread>element;
if (thread.stopped) {
actions.push(new ContinueAction(ContinueAction.ID, ContinueAction.LABEL, this.debugService, this.keybindingService));
actions.push(new StepOverAction(StepOverAction.ID, StepOverAction.LABEL, this.debugService, this.keybindingService));
actions.push(new StepIntoAction(StepIntoAction.ID, StepIntoAction.LABEL, this.debugService, this.keybindingService));
actions.push(new StepOutAction(StepOutAction.ID, StepOutAction.LABEL, this.debugService, this.keybindingService));
} else {
actions.push(new PauseAction(PauseAction.ID, PauseAction.LABEL, this.debugService, this.keybindingService));
}
actions.push(new Separator());
actions.push(new TerminateThreadAction(TerminateThreadAction.ID, TerminateThreadAction.LABEL, this.debugService, this.keybindingService));
} else if (element instanceof StackFrame) {
this.callStackItemType.set('stackFrame');
if (element.thread.session.capabilities.supportsRestartFrame) {
actions.push(new RestartFrameAction(RestartFrameAction.ID, RestartFrameAction.LABEL, this.debugService, this.keybindingService));
}
actions.push(this.instantiationService.createInstance(CopyStackTraceAction, CopyStackTraceAction.ID, CopyStackTraceAction.LABEL));
} else {
this.callStackItemType.reset();
}
......@@ -297,7 +276,8 @@ export class CallStackView extends ViewletPanel {
this.contextMenuService.showContextMenu({
getAnchor: () => e.anchor,
getActions: () => {
fillInContextMenuActions(this.contributedContextMenu, { arg: this.getContextForContributedActions(element) }, actions, this.contextMenuService);
const actions: IAction[] = [];
fillInContextMenuActions(this.contributedContextMenu, { arg: this.getContextForContributedActions(element), shouldForwardArgs: true }, actions, this.contextMenuService);
return actions;
},
getActionsContext: () => element
......@@ -315,6 +295,9 @@ export class CallStackView extends ViewletPanel {
if (element instanceof Thread) {
return element.threadId;
}
if (isDebugSession(element)) {
return element.getId();
}
return undefined;
}
......
......@@ -8,9 +8,9 @@ import { Action } from 'vs/base/common/actions';
import * as lifecycle from 'vs/base/common/lifecycle';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IDebugService, State, IDebugSession, IThread, IEnablement, IBreakpoint, IStackFrame, REPL_ID }
import { IDebugService, State, IEnablement, IBreakpoint, REPL_ID }
from 'vs/workbench/contrib/debug/common/debug';
import { Variable, Expression, Thread, Breakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
import { Variable, Expression, Breakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
......@@ -18,12 +18,10 @@ import { TogglePanelAction } from 'vs/workbench/browser/panel';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { CollapseAction } from 'vs/workbench/browser/viewlet';
import { first } from 'vs/base/common/arrays';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { memoize } from 'vs/base/common/decorators';
import { AsyncDataTree } from 'vs/base/browser/ui/tree/asyncDataTree';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { startDebugging } from 'vs/workbench/contrib/debug/common/debugUtils';
export abstract class AbstractDebugAction extends Action {
......@@ -135,23 +133,8 @@ export class StartAction extends AbstractDebugAction {
this.toDispose.push(this.contextService.onDidChangeWorkbenchState(() => this.updateEnablement()));
}
// Note: When this action is executed from the process explorer, a config is passed. For all
// other cases it is run with no arguments.
public run(): Promise<any> {
const configurationManager = this.debugService.getConfigurationManager();
let launch = configurationManager.selectedConfiguration.launch;
if (!launch || launch.getConfigurationNames().length === 0) {
const rootUri = this.historyService.getLastActiveWorkspaceRoot();
launch = configurationManager.getLaunch(rootUri);
if (!launch || launch.getConfigurationNames().length === 0) {
const launches = configurationManager.getLaunches();
launch = first(launches, l => !!(l && l.getConfigurationNames().length), launch);
}
configurationManager.selectConfiguration(launch);
}
return this.debugService.startDebugging(launch, undefined, this.isNoDebug());
public run(): Promise<boolean> {
return startDebugging(this.debugService, this.historyService, this.isNoDebug());
}
protected isNoDebug(): boolean {
......@@ -204,242 +187,6 @@ export class SelectAndStartAction extends AbstractDebugAction {
}
}
export class RestartAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.restart';
static LABEL = nls.localize('restartDebug', "Restart");
static RECONNECT_LABEL = nls.localize('reconnectDebug', "Reconnect");
constructor(id: string, label: string,
@IDebugService debugService: IDebugService,
@IKeybindingService keybindingService: IKeybindingService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IHistoryService private readonly historyService: IHistoryService
) {
super(id, label, 'debug-action restart', debugService, keybindingService, 70);
this.setLabel(this.debugService.getViewModel().focusedSession);
this.toDispose.push(this.debugService.getViewModel().onDidFocusSession(() => this.setLabel(this.debugService.getViewModel().focusedSession)));
}
@memoize
private get startAction(): StartAction {
return new StartAction(StartAction.ID, StartAction.LABEL, this.debugService, this.keybindingService, this.contextService, this.historyService);
}
private setLabel(session: IDebugSession | undefined): void {
if (session) {
this.updateLabel(session && session.configuration.request === 'attach' ? RestartAction.RECONNECT_LABEL : RestartAction.LABEL);
}
}
public run(session: IDebugSession | undefined): Promise<any> {
if (!session || !session.getId) {
session = this.debugService.getViewModel().focusedSession;
}
if (!session) {
return this.startAction.run();
}
session.removeReplExpressions();
return this.debugService.restartSession(session);
}
protected isEnabled(state: State): boolean {
return super.isEnabled(state) && (
state === State.Running ||
state === State.Stopped ||
StartAction.isEnabled(this.debugService)
);
}
}
export class StepOverAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.stepOver';
static LABEL = nls.localize('stepOverDebug', "Step Over");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action step-over', debugService, keybindingService, 20);
}
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
return thread ? thread.next() : Promise.resolve();
}
protected isEnabled(state: State): boolean {
return super.isEnabled(state) && state === State.Stopped;
}
}
export class StepIntoAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.stepInto';
static LABEL = nls.localize('stepIntoDebug', "Step Into");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action step-into', debugService, keybindingService, 30);
}
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
return thread ? thread.stepIn() : Promise.resolve();
}
protected isEnabled(state: State): boolean {
return super.isEnabled(state) && state === State.Stopped;
}
}
export class StepOutAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.stepOut';
static LABEL = nls.localize('stepOutDebug', "Step Out");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action step-out', debugService, keybindingService, 40);
}
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
return thread ? thread.stepOut() : Promise.resolve();
}
protected isEnabled(state: State): boolean {
return super.isEnabled(state) && state === State.Stopped;
}
}
export class StopAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.stop';
static LABEL = nls.localize('stopDebug', "Stop");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action stop', debugService, keybindingService, 80);
}
public run(session: IDebugSession | undefined): Promise<any> {
if (!session || !session.getId) {
session = this.debugService.getViewModel().focusedSession;
}
return this.debugService.stopSession(session);
}
protected isEnabled(state: State): boolean {
return super.isEnabled(state) && (state !== State.Inactive);
}
}
export class DisconnectAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.disconnect';
static LABEL = nls.localize('disconnectDebug', "Disconnect");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action disconnect', debugService, keybindingService, 80);
}
public run(): Promise<any> {
const session = this.debugService.getViewModel().focusedSession;
return this.debugService.stopSession(session);
}
protected isEnabled(state: State): boolean {
return super.isEnabled(state) && (state === State.Running || state === State.Stopped);
}
}
export class ContinueAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.continue';
static LABEL = nls.localize('continueDebug', "Continue");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action continue', debugService, keybindingService, 10);
}
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
return thread ? thread.continue() : Promise.resolve();
}
protected isEnabled(state: State): boolean {
return super.isEnabled(state) && state === State.Stopped;
}
}
export class PauseAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.pause';
static LABEL = nls.localize('pauseDebug', "Pause");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action pause', debugService, keybindingService, 10);
}
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
if (!thread) {
const session = this.debugService.getViewModel().focusedSession;
const threads = session && session.getAllThreads();
thread = threads && threads.length ? threads[0] : undefined;
}
}
return thread ? thread.pause() : Promise.resolve();
}
protected isEnabled(state: State): boolean {
return super.isEnabled(state) && state === State.Running;
}
}
export class TerminateThreadAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.terminateThread';
static LABEL = nls.localize('terminateThread', "Terminate Thread");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, '', debugService, keybindingService);
}
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
return thread ? thread.terminate() : Promise.resolve();
}
protected isEnabled(state: State): boolean {
return super.isEnabled(state) && (state === State.Running || state === State.Stopped);
}
}
export class RestartFrameAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.restartFrame';
static LABEL = nls.localize('restartFrame', "Restart Frame");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, '', debugService, keybindingService);
}
public run(frame: IStackFrame | undefined): Promise<any> {
if (!frame) {
frame = this.debugService.getViewModel().focusedStackFrame;
}
return frame!.restart();
}
}
export class RemoveBreakpointAction extends AbstractDebugAction {
static readonly ID = 'workbench.debug.viewlet.action.removeBreakpoint';
static LABEL = nls.localize('removeBreakpoint', "Remove Breakpoint");
......@@ -754,53 +501,6 @@ export class FocusSessionAction extends AbstractDebugAction {
}
}
// Actions used by the chakra debugger
export class StepBackAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.stepBack';
static LABEL = nls.localize('stepBackDebug', "Step Back");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action step-back', debugService, keybindingService, 50);
}
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
return thread ? thread.stepBack() : Promise.resolve();
}
protected isEnabled(state: State): boolean {
const session = this.debugService.getViewModel().focusedSession;
return !!(super.isEnabled(state) && state === State.Stopped &&
session && session.capabilities.supportsStepBack);
}
}
export class ReverseContinueAction extends AbstractDebugAction {
static readonly ID = 'workbench.action.debug.reverseContinue';
static LABEL = nls.localize('reverseContinue', "Reverse");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, 'debug-action reverse-continue', debugService, keybindingService, 60);
}
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
return thread ? thread.reverseContinue() : Promise.resolve();
}
protected isEnabled(state: State): boolean {
const session = this.debugService.getViewModel().focusedSession;
return !!(super.isEnabled(state) && state === State.Stopped &&
session && session.capabilities.supportsStepBack);
}
}
export class ReplCollapseAllAction extends CollapseAction {
constructor(tree: AsyncDataTree<any, any, any>, private toFocus: { focus(): void; }) {
super(tree, true, undefined);
......@@ -875,22 +575,3 @@ export class CopyAction extends Action {
return Promise.resolve(undefined);
}
}
export class CopyStackTraceAction extends Action {
static readonly ID = 'workbench.action.debug.copyStackTrace';
static LABEL = nls.localize('copyStackTrace', "Copy Call Stack");
constructor(
id: string, label: string,
@IClipboardService private readonly clipboardService: IClipboardService,
@ITextResourcePropertiesService private readonly textResourcePropertiesService: ITextResourcePropertiesService
) {
super(id, label);
}
public run(frame: IStackFrame): Promise<any> {
const eol = this.textResourcePropertiesService.getEOL(frame.source.uri);
this.clipboardService.writeText(frame.thread.getCallStack().map(sf => sf.toString()).join(eol));
return Promise.resolve(undefined);
}
}
\ No newline at end of file
......@@ -9,8 +9,8 @@ import { List } from 'vs/base/browser/ui/list/listWidget';
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IListService } from 'vs/platform/list/browser/listService';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IDebugService, IEnablement, CONTEXT_BREAKPOINTS_FOCUSED, CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_VARIABLES_FOCUSED, EDITOR_CONTRIBUTION_ID, IDebugEditorContribution, CONTEXT_IN_DEBUG_MODE, CONTEXT_EXPRESSION_SELECTED, CONTEXT_BREAKPOINT_SELECTED, IConfig } from 'vs/workbench/contrib/debug/common/debug';
import { Expression, Variable, Breakpoint, FunctionBreakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
import { IDebugService, IEnablement, CONTEXT_BREAKPOINTS_FOCUSED, CONTEXT_WATCH_EXPRESSIONS_FOCUSED, CONTEXT_VARIABLES_FOCUSED, EDITOR_CONTRIBUTION_ID, IDebugEditorContribution, CONTEXT_IN_DEBUG_MODE, CONTEXT_EXPRESSION_SELECTED, CONTEXT_BREAKPOINT_SELECTED, IConfig, IStackFrame, IThread, IDebugSession, CONTEXT_DEBUG_STATE } from 'vs/workbench/contrib/debug/common/debug';
import { Expression, Variable, Breakpoint, FunctionBreakpoint, Thread } from 'vs/workbench/contrib/debug/common/debugModel';
import { IExtensionsViewlet, VIEWLET_ID as EXTENSIONS_VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { ICodeEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
......@@ -25,12 +25,179 @@ import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
import { PanelFocusContext } from 'vs/workbench/common/panel';
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { onUnexpectedError } from 'vs/base/common/errors';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { startDebugging } from 'vs/workbench/contrib/debug/common/debugUtils';
export const ADD_CONFIGURATION_ID = 'debug.addConfiguration';
export const TOGGLE_INLINE_BREAKPOINT_ID = 'editor.debug.action.toggleInlineBreakpoint';
export const COPY_STACK_TRACE_ID = 'debug.copyStackTrace';
export const REVERSE_CONTINUE_ID = 'workbench.action.debug.reverseContinue';
export const STEP_BACK_ID = 'workbench.action.debug.stepBack';
export const RESTART_SESSION_ID = 'workbench.action.debug.restart';
export const TERMINATE_THREAD_ID = 'workbench.action.debug.terminateThread';
export const STEP_OVER_ID = 'workbench.action.debug.stepOver';
export const STEP_INTO_ID = 'workbench.action.debug.stepInto';
export const STEP_OUT_ID = 'workbench.action.debug.stepOut';
export const PAUSE_ID = 'workbench.action.debug.pause';
export const DISCONNECT_ID = 'workbench.action.debug.disconnect';
export const STOP_ID = 'workbench.action.debug.stop';
export const RESTART_FRAME_ID = 'workbench.action.debug.restartFrame';
export const CONTINUE_ID = 'workbench.action.debug.continue';
function getThreadAndRun(accessor: ServicesAccessor, thread: IThread | undefined, run: (thread: IThread) => Promise<void>, ): void {
const debugService = accessor.get(IDebugService);
if (!(thread instanceof Thread)) {
thread = debugService.getViewModel().focusedThread;
}
if (thread) {
run(thread).then(undefined, onUnexpectedError);
}
}
export function registerCommands(): void {
CommandsRegistry.registerCommand({
id: COPY_STACK_TRACE_ID,
handler: (accessor: ServicesAccessor, _: string, frame: IStackFrame) => {
const textResourcePropertiesService = accessor.get(ITextResourcePropertiesService);
const clipboardService = accessor.get(IClipboardService);
const eol = textResourcePropertiesService.getEOL(frame.source.uri);
clipboardService.writeText(frame.thread.getCallStack().map(sf => sf.toString()).join(eol));
}
});
CommandsRegistry.registerCommand({
id: REVERSE_CONTINUE_ID,
handler: (accessor: ServicesAccessor, _: string, thread: IThread | undefined) => {
getThreadAndRun(accessor, thread, thread => thread.reverseContinue());
}
});
CommandsRegistry.registerCommand({
id: STEP_BACK_ID,
handler: (accessor: ServicesAccessor, _: string, thread: IThread | undefined) => {
getThreadAndRun(accessor, thread, thread => thread.stepBack());
}
});
CommandsRegistry.registerCommand({
id: TERMINATE_THREAD_ID,
handler: (accessor: ServicesAccessor, _: string, thread: IThread | undefined) => {
getThreadAndRun(accessor, thread, thread => thread.terminate());
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: RESTART_SESSION_ID,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.Shift | KeyMod.CtrlCmd | KeyCode.F5,
when: CONTEXT_IN_DEBUG_MODE,
handler: (accessor: ServicesAccessor, _: string, session: IDebugSession | undefined) => {
const debugService = accessor.get(IDebugService);
if (!session || !session.getId) {
session = debugService.getViewModel().focusedSession;
}
if (!session) {
const historyService = accessor.get(IHistoryService);
startDebugging(debugService, historyService, false);
} else {
session.removeReplExpressions();
debugService.restartSession(session).then(undefined, onUnexpectedError);
}
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: STEP_OVER_ID,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyCode.F10,
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
handler: (accessor: ServicesAccessor, _: string, thread: IThread | undefined) => {
getThreadAndRun(accessor, thread, thread => thread.next());
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: STEP_INTO_ID,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyCode.F11,
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
handler: (accessor: ServicesAccessor, _: string, thread: IThread | undefined) => {
getThreadAndRun(accessor, thread, thread => thread.stepIn());
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: STEP_OUT_ID,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.Shift | KeyCode.F11,
when: CONTEXT_DEBUG_STATE.isEqualTo('stopped'),
handler: (accessor: ServicesAccessor, _: string, thread: IThread | undefined) => {
getThreadAndRun(accessor, thread, thread => thread.stepOut());
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: PAUSE_ID,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyCode.F6,
when: CONTEXT_DEBUG_STATE.isEqualTo('running'),
handler: (accessor: ServicesAccessor, _: string, thread: IThread | undefined) => {
getThreadAndRun(accessor, thread, thread => thread.pause());
}
});
CommandsRegistry.registerCommand({
id: DISCONNECT_ID,
handler: (accessor: ServicesAccessor) => {
const debugService = accessor.get(IDebugService);
const session = debugService.getViewModel().focusedSession;
debugService.stopSession(session).then(undefined, onUnexpectedError);
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: STOP_ID,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyMod.Shift | KeyCode.F5,
when: CONTEXT_IN_DEBUG_MODE,
handler: (accessor: ServicesAccessor, _: string, session: IDebugSession | undefined) => {
const debugService = accessor.get(IDebugService);
if (!session || !session.getId) {
session = debugService.getViewModel().focusedSession;
}
debugService.stopSession(session).then(undefined, onUnexpectedError);
}
});
CommandsRegistry.registerCommand({
id: RESTART_FRAME_ID,
handler: (accessor: ServicesAccessor, _: string, frame: IStackFrame | undefined) => {
const debugService = accessor.get(IDebugService);
if (!frame) {
frame = debugService.getViewModel().focusedStackFrame;
}
return frame!.restart();
}
});
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: CONTINUE_ID,
weight: KeybindingWeight.WorkbenchContrib,
primary: KeyCode.F5,
when: CONTEXT_IN_DEBUG_MODE,
handler: (accessor: ServicesAccessor, _: string, thread: IThread | undefined) => {
getThreadAndRun(accessor, thread, thread => thread.continue());
}
});
CommandsRegistry.registerCommand({
id: 'debug.startFromConfig',
handler: (accessor, config: IConfig) => {
......
......@@ -53,6 +53,7 @@ export const CONTEXT_LOADED_SCRIPTS_SUPPORTED = new RawContextKey<boolean>('load
export const CONTEXT_LOADED_SCRIPTS_ITEM_TYPE = new RawContextKey<string>('loadedScriptsItemType', undefined);
export const CONTEXT_FOCUSED_SESSION_IS_ATTACH = new RawContextKey<boolean>('focusedSessionIsAttach', false);
export const CONTEXT_STEP_BACK_SUPPORTED = new RawContextKey<boolean>('stepBackSupported', false);
export const CONTEXT_RESTART_FRAME_SUPPORTED = new RawContextKey<boolean>('restartFrameSupported', false);
export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug';
export const DEBUG_SCHEME = 'debug';
......
......@@ -4,13 +4,32 @@
*--------------------------------------------------------------------------------------------*/
import { equalsIgnoreCase } from 'vs/base/common/strings';
import { IConfig, IDebuggerContribution } from 'vs/workbench/contrib/debug/common/debug';
import { IConfig, IDebuggerContribution, IDebugService } from 'vs/workbench/contrib/debug/common/debug';
import { URI as uri } from 'vs/base/common/uri';
import { isAbsolute } from 'vs/base/common/path';
import { deepClone } from 'vs/base/common/objects';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { first } from 'vs/base/common/arrays';
const _formatPIIRegexp = /{([^}]+)}/g;
export function startDebugging(debugService: IDebugService, historyService: IHistoryService, noDebug: boolean, ): Promise<boolean> {
const configurationManager = debugService.getConfigurationManager();
let launch = configurationManager.selectedConfiguration.launch;
if (!launch || launch.getConfigurationNames().length === 0) {
const rootUri = historyService.getLastActiveWorkspaceRoot();
launch = configurationManager.getLaunch(rootUri);
if (!launch || launch.getConfigurationNames().length === 0) {
const launches = configurationManager.getLaunches();
launch = first(launches, l => !!(l && l.getConfigurationNames().length), launch);
}
configurationManager.selectConfiguration(launch);
}
return debugService.startDebugging(launch, undefined, noDebug);
}
export function formatPII(value: string, excludePII: boolean, args: { [key: string]: string }): string {
return value.replace(_formatPIIRegexp, function (match, group) {
if (excludePII && group.length > 0 && group[0] !== '_') {
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Event, Emitter } from 'vs/base/common/event';
import { CONTEXT_EXPRESSION_SELECTED, IViewModel, IStackFrame, IDebugSession, IThread, IExpression, IFunctionBreakpoint, CONTEXT_BREAKPOINT_SELECTED, CONTEXT_LOADED_SCRIPTS_SUPPORTED, CONTEXT_STEP_BACK_SUPPORTED, CONTEXT_FOCUSED_SESSION_IS_ATTACH } from 'vs/workbench/contrib/debug/common/debug';
import { CONTEXT_EXPRESSION_SELECTED, IViewModel, IStackFrame, IDebugSession, IThread, IExpression, IFunctionBreakpoint, CONTEXT_BREAKPOINT_SELECTED, CONTEXT_LOADED_SCRIPTS_SUPPORTED, CONTEXT_STEP_BACK_SUPPORTED, CONTEXT_FOCUSED_SESSION_IS_ATTACH, CONTEXT_RESTART_FRAME_SUPPORTED } from 'vs/workbench/contrib/debug/common/debug';
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { isExtensionHostDebugging } from 'vs/workbench/contrib/debug/common/debugUtils';
......@@ -26,6 +26,7 @@ export class ViewModel implements IViewModel {
private loadedScriptsSupportedContextKey: IContextKey<boolean>;
private stepBackSupportedContextKey: IContextKey<boolean>;
private focusedSessionIsAttach: IContextKey<boolean>;
private restartFrameSupportedContextKey: IContextKey<boolean>;
constructor(contextKeyService: IContextKeyService) {
this._onDidFocusSession = new Emitter<IDebugSession | undefined>();
......@@ -37,6 +38,7 @@ export class ViewModel implements IViewModel {
this.loadedScriptsSupportedContextKey = CONTEXT_LOADED_SCRIPTS_SUPPORTED.bindTo(contextKeyService);
this.stepBackSupportedContextKey = CONTEXT_STEP_BACK_SUPPORTED.bindTo(contextKeyService);
this.focusedSessionIsAttach = CONTEXT_FOCUSED_SESSION_IS_ATTACH.bindTo(contextKeyService);
this.restartFrameSupportedContextKey = CONTEXT_RESTART_FRAME_SUPPORTED.bindTo(contextKeyService);
}
getId(): string {
......@@ -65,6 +67,7 @@ export class ViewModel implements IViewModel {
this.loadedScriptsSupportedContextKey.set(session ? !!session.capabilities.supportsLoadedSourcesRequest : false);
this.stepBackSupportedContextKey.set(session ? !!session.capabilities.supportsStepBack : false);
this.restartFrameSupportedContextKey.set(session ? !!session.capabilities.supportsRestartFrame : false);
const attach = !!session && session.configuration.request === 'attach' && !isExtensionHostDebugging(session.configuration);
this.focusedSessionIsAttach.set(attach);
......
......@@ -10,7 +10,7 @@ import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { SyncActionDescriptor, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
import { Registry } from 'vs/platform/registry/common/platform';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { KeybindingWeight, IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { IWorkbenchActionRegistry, Extensions as WorkbenchActionRegistryExtensions } from 'vs/workbench/common/actions';
import { ShowViewletAction, Extensions as ViewletExtensions, ViewletRegistry, ViewletDescriptor } from 'vs/workbench/browser/viewlet';
......@@ -22,19 +22,16 @@ import { CallStackView } from 'vs/workbench/contrib/debug/browser/callStackView'
import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
import {
IDebugService, VIEWLET_ID, REPL_ID, CONTEXT_IN_DEBUG_MODE, INTERNAL_CONSOLE_OPTIONS_SCHEMA,
CONTEXT_DEBUG_STATE, VARIABLES_VIEW_ID, CALLSTACK_VIEW_ID, WATCH_VIEW_ID, BREAKPOINTS_VIEW_ID, VIEW_CONTAINER, LOADED_SCRIPTS_VIEW_ID, CONTEXT_LOADED_SCRIPTS_SUPPORTED, CONTEXT_FOCUSED_SESSION_IS_ATTACH, CONTEXT_STEP_BACK_SUPPORTED,
CONTEXT_DEBUG_STATE, VARIABLES_VIEW_ID, CALLSTACK_VIEW_ID, WATCH_VIEW_ID, BREAKPOINTS_VIEW_ID, VIEW_CONTAINER, LOADED_SCRIPTS_VIEW_ID, CONTEXT_LOADED_SCRIPTS_SUPPORTED, CONTEXT_FOCUSED_SESSION_IS_ATTACH, CONTEXT_STEP_BACK_SUPPORTED, CONTEXT_CALLSTACK_ITEM_TYPE, CONTEXT_RESTART_FRAME_SUPPORTED,
} from 'vs/workbench/contrib/debug/common/debug';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { DebugEditorModelManager } from 'vs/workbench/contrib/debug/browser/debugEditorModelManager';
import {
StepOverAction, FocusReplAction, StepIntoAction, StepOutAction, StartAction, RestartAction, ContinueAction, StopAction, DisconnectAction, PauseAction, AddFunctionBreakpointAction,
ConfigureAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction, SelectAndStartAction, TerminateThreadAction, StepBackAction, ReverseContinueAction,
} from 'vs/workbench/contrib/debug/browser/debugActions';
import { FocusReplAction, StartAction, AddFunctionBreakpointAction, ConfigureAction, DisableAllBreakpointsAction, EnableAllBreakpointsAction, RemoveAllBreakpointsAction, RunAction, ReapplyBreakpointsAction, SelectAndStartAction } from 'vs/workbench/contrib/debug/browser/debugActions';
import { DebugToolbar } from 'vs/workbench/contrib/debug/browser/debugToolbar';
import * as service from 'vs/workbench/contrib/debug/electron-browser/debugService';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { registerCommands, ADD_CONFIGURATION_ID, TOGGLE_INLINE_BREAKPOINT_ID } from 'vs/workbench/contrib/debug/browser/debugCommands';
import { registerCommands, ADD_CONFIGURATION_ID, TOGGLE_INLINE_BREAKPOINT_ID, COPY_STACK_TRACE_ID, REVERSE_CONTINUE_ID, STEP_BACK_ID, RESTART_SESSION_ID, TERMINATE_THREAD_ID, STEP_OVER_ID, STEP_INTO_ID, STEP_OUT_ID, PAUSE_ID, DISCONNECT_ID, STOP_ID, RESTART_FRAME_ID, CONTINUE_ID } from 'vs/workbench/contrib/debug/browser/debugCommands';
import { IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
import { StatusBarColorProvider } from 'vs/workbench/contrib/debug/browser/statusbarColorProvider';
import { IViewsRegistry, Extensions as ViewExtensions } from 'vs/workbench/common/views';
......@@ -118,6 +115,8 @@ viewsRegistry.registerViews([{ id: CALLSTACK_VIEW_ID, name: nls.localize('callSt
viewsRegistry.registerViews([{ id: BREAKPOINTS_VIEW_ID, name: nls.localize('breakpoints', "Breakpoints"), ctorDescriptor: { ctor: BreakpointsView }, order: 40, weight: 20, canToggleVisibility: true, focusCommand: { id: 'workbench.debug.action.focusBreakpointsView' } }], VIEW_CONTAINER);
viewsRegistry.registerViews([{ id: LOADED_SCRIPTS_VIEW_ID, name: nls.localize('loadedScripts', "Loaded Scripts"), ctorDescriptor: { ctor: LoadedScriptsView }, order: 35, weight: 5, canToggleVisibility: true, collapsed: true, when: CONTEXT_LOADED_SCRIPTS_SUPPORTED }], VIEW_CONTAINER);
registerCommands();
// register action to open viewlet
const registry = Registry.as<IWorkbenchActionRegistry>(WorkbenchActionRegistryExtensions.WorkbenchActions);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenDebugPanelAction, OpenDebugPanelAction.ID, OpenDebugPanelAction.LABEL, openPanelKb), 'View: Debug Console', nls.localize('view', "View"));
......@@ -131,15 +130,6 @@ Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).regi
const debugCategory = nls.localize('debugCategory', "Debug");
registry.registerWorkbenchAction(new SyncActionDescriptor(StartAction, StartAction.ID, StartAction.LABEL, { primary: KeyCode.F5 }, CONTEXT_IN_DEBUG_MODE.toNegated()), 'Debug: Start Debugging', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(StepOverAction, StepOverAction.ID, StepOverAction.LABEL, { primary: KeyCode.F10 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Step Over', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(StepIntoAction, StepIntoAction.ID, StepIntoAction.LABEL, { primary: KeyCode.F11 }, CONTEXT_IN_DEBUG_MODE, KeybindingWeight.WorkbenchContrib + 1), 'Debug: Step Into', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(StepOutAction, StepOutAction.ID, StepOutAction.LABEL, { primary: KeyMod.Shift | KeyCode.F11 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Step Out', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(RestartAction, RestartAction.ID, RestartAction.LABEL, { primary: KeyMod.Shift | KeyMod.CtrlCmd | KeyCode.F5 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Restart', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(StopAction, StopAction.ID, StopAction.LABEL, { primary: KeyMod.Shift | KeyCode.F5 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Stop', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(DisconnectAction, DisconnectAction.ID, DisconnectAction.LABEL), 'Debug: Disconnect', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(ContinueAction, ContinueAction.ID, ContinueAction.LABEL, { primary: KeyCode.F5 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Continue', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(PauseAction, PauseAction.ID, PauseAction.LABEL, { primary: KeyCode.F6 }, CONTEXT_IN_DEBUG_MODE), 'Debug: Pause', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(TerminateThreadAction, TerminateThreadAction.ID, TerminateThreadAction.LABEL, undefined, CONTEXT_IN_DEBUG_MODE), 'Debug: Terminate Thread', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(ConfigureAction, ConfigureAction.ID, ConfigureAction.LABEL), 'Debug: Open launch.json', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(AddFunctionBreakpointAction, AddFunctionBreakpointAction.ID, AddFunctionBreakpointAction.LABEL), 'Debug: Add Function Breakpoint', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(ReapplyBreakpointsAction, ReapplyBreakpointsAction.ID, ReapplyBreakpointsAction.LABEL), 'Debug: Reapply All Breakpoints', debugCategory);
......@@ -151,6 +141,34 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(FocusReplAction, Focus
registry.registerWorkbenchAction(new SyncActionDescriptor(SelectAndStartAction, SelectAndStartAction.ID, SelectAndStartAction.LABEL), 'Debug: Select and Start Debugging', debugCategory);
registry.registerWorkbenchAction(new SyncActionDescriptor(ClearReplAction, ClearReplAction.ID, ClearReplAction.LABEL), 'Debug: Clear Console', debugCategory);
const registerDebugCommandPaletteItem = (id: string, title: string, when?: ContextKeyExpr, precondition?: ContextKeyExpr) => {
MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
when,
command: {
id,
title: `Debug: ${title}`,
precondition
}
});
};
const restartLabel = nls.localize('restartDebug', "Restart");
const stepOverLabel = nls.localize('stepOverDebug', "Step Over");
const stepIntoLabel = nls.localize('stepIntoDebug', "Step Into");
const stepOutLabel = nls.localize('stepOutDebug', "Step Out");
const pauseLabel = nls.localize('pauseDebug', "Pause");
const disconnectLabel = nls.localize('disconnect', "Disconnect");
const stopLabel = nls.localize('stop', "Stop");
const continueLabel = nls.localize('continueDebug', "Continue");
registerDebugCommandPaletteItem(RESTART_SESSION_ID, restartLabel);
registerDebugCommandPaletteItem(TERMINATE_THREAD_ID, nls.localize('terminateThread', "Terminate Thread"), CONTEXT_IN_DEBUG_MODE);
registerDebugCommandPaletteItem(STEP_OVER_ID, stepOverLabel, CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugCommandPaletteItem(STEP_INTO_ID, stepIntoLabel, CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugCommandPaletteItem(STEP_OUT_ID, stepOutLabel, CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugCommandPaletteItem(PAUSE_ID, pauseLabel, CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('running'));
registerDebugCommandPaletteItem(DISCONNECT_ID, disconnectLabel, CONTEXT_IN_DEBUG_MODE, CONTEXT_FOCUSED_SESSION_IS_ATTACH);
registerDebugCommandPaletteItem(STOP_ID, stopLabel, CONTEXT_IN_DEBUG_MODE, CONTEXT_FOCUSED_SESSION_IS_ATTACH.toNegated());
registerDebugCommandPaletteItem(CONTINUE_ID, continueLabel, CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
// Register Quick Open
(Registry.as<IQuickOpenRegistry>(QuickOpenExtensions.Quickopen)).registerQuickOpenHandler(
new QuickOpenHandlerDescriptor(
......@@ -234,8 +252,6 @@ configurationRegistry.registerConfiguration({
}
});
registerCommands();
// Register Debug Status
const statusBar = Registry.as<IStatusbarRegistry>(StatusExtensions.Statusbar);
statusBar.registerStatusbarItem(new StatusbarItemDescriptor(DebugStatus, StatusbarAlignment.LEFT, 30 /* Low Priority */));
......@@ -259,16 +275,40 @@ const registerDebugToolbarItem = (id: string, title: string, icon: string, order
});
};
registerDebugToolbarItem(ContinueAction.ID, ContinueAction.LABEL, 'continue', 10, CONTEXT_DEBUG_STATE.notEqualsTo('running'));
registerDebugToolbarItem(PauseAction.ID, PauseAction.LABEL, 'pause', 10, CONTEXT_DEBUG_STATE.isEqualTo('running'));
registerDebugToolbarItem(StopAction.ID, StopAction.LABEL, 'stop', 70, CONTEXT_FOCUSED_SESSION_IS_ATTACH.toNegated());
registerDebugToolbarItem(DisconnectAction.ID, DisconnectAction.LABEL, 'disconnect', 70, CONTEXT_FOCUSED_SESSION_IS_ATTACH);
registerDebugToolbarItem(StepOverAction.ID, StepOverAction.LABEL, 'step-over', 20, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugToolbarItem(StepIntoAction.ID, StepIntoAction.LABEL, 'step-into', 30, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugToolbarItem(StepOutAction.ID, StepOutAction.LABEL, 'step-out', 40, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugToolbarItem(RestartAction.ID, RestartAction.LABEL, 'restart', 60);
registerDebugToolbarItem(StepBackAction.ID, StepBackAction.LABEL, 'step-back', 50, CONTEXT_STEP_BACK_SUPPORTED, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugToolbarItem(ReverseContinueAction.ID, ReverseContinueAction.LABEL, 'reverse-continue', 60, CONTEXT_STEP_BACK_SUPPORTED, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugToolbarItem(CONTINUE_ID, continueLabel, 'continue', 10, CONTEXT_DEBUG_STATE.notEqualsTo('running'));
registerDebugToolbarItem(PAUSE_ID, pauseLabel, 'pause', 10, CONTEXT_DEBUG_STATE.isEqualTo('running'));
registerDebugToolbarItem(STOP_ID, stopLabel, 'stop', 70, CONTEXT_FOCUSED_SESSION_IS_ATTACH.toNegated());
registerDebugToolbarItem(DISCONNECT_ID, disconnectLabel, 'disconnect', 70, CONTEXT_FOCUSED_SESSION_IS_ATTACH);
registerDebugToolbarItem(STEP_OVER_ID, stepOverLabel, 'step-over', 20, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugToolbarItem(STEP_INTO_ID, stepIntoLabel, 'step-into', 30, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugToolbarItem(STEP_OUT_ID, stepOutLabel, 'step-out', 40, undefined, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugToolbarItem(RESTART_SESSION_ID, restartLabel, 'restart', 60);
registerDebugToolbarItem(STEP_BACK_ID, nls.localize('stepBackDebug', "Step Back"), 'step-back', 50, CONTEXT_STEP_BACK_SUPPORTED, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugToolbarItem(REVERSE_CONTINUE_ID, nls.localize('reverseContinue', "Reverse"), 'reverse-continue', 60, CONTEXT_STEP_BACK_SUPPORTED, CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
// Debug callstack context menu
const registerDebugCallstackItem = (id: string, title: string, order: number, when?: ContextKeyExpr, precondition?: ContextKeyExpr, group = 'navigation') => {
MenuRegistry.appendMenuItem(MenuId.DebugCallStackContext, {
group,
when,
order,
command: {
id,
title,
precondition
}
});
};
registerDebugCallstackItem(RESTART_SESSION_ID, restartLabel, 10, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('session'));
registerDebugCallstackItem(STOP_ID, stopLabel, 20, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('session'));
registerDebugCallstackItem(PAUSE_ID, pauseLabel, 10, ContextKeyExpr.and(CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('thread'), CONTEXT_DEBUG_STATE.isEqualTo('running')));
registerDebugCallstackItem(CONTINUE_ID, continueLabel, 10, ContextKeyExpr.and(CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('thread'), CONTEXT_DEBUG_STATE.isEqualTo('stopped')));
registerDebugCallstackItem(STEP_OVER_ID, stepOverLabel, 20, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('thread'), CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugCallstackItem(STEP_INTO_ID, stepIntoLabel, 30, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('thread'), CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugCallstackItem(STEP_OUT_ID, stepOutLabel, 40, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('thread'), CONTEXT_DEBUG_STATE.isEqualTo('stopped'));
registerDebugCallstackItem(TERMINATE_THREAD_ID, nls.localize('terminateThread', "Terminate Thread"), 10, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('thread'), undefined, 'termination');
registerDebugCallstackItem(RESTART_FRAME_ID, nls.localize('restartFrame', "Restart Frame"), 10, ContextKeyExpr.and(CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('stackFrame'), CONTEXT_RESTART_FRAME_SUPPORTED));
registerDebugCallstackItem(COPY_STACK_TRACE_ID, nls.localize('copyStackTrace', "Copy Call Stack"), 20, CONTEXT_CALLSTACK_ITEM_TYPE.isEqualTo('stackFrame'));
// View menu
......@@ -313,7 +353,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
group: '1_debug',
command: {
id: StopAction.ID,
id: STOP_ID,
title: nls.localize({ key: 'miStopDebugging', comment: ['&& denotes a mnemonic'] }, "&&Stop Debugging"),
precondition: CONTEXT_IN_DEBUG_MODE
},
......@@ -323,7 +363,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
group: '1_debug',
command: {
id: RestartAction.ID,
id: RESTART_SESSION_ID,
title: nls.localize({ key: 'miRestart Debugging', comment: ['&& denotes a mnemonic'] }, "&&Restart Debugging"),
precondition: CONTEXT_IN_DEBUG_MODE
},
......@@ -353,7 +393,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
group: '3_step',
command: {
id: StepOverAction.ID,
id: STEP_OVER_ID,
title: nls.localize({ key: 'miStepOver', comment: ['&& denotes a mnemonic'] }, "Step &&Over"),
precondition: CONTEXT_DEBUG_STATE.isEqualTo('stopped')
},
......@@ -363,7 +403,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
group: '3_step',
command: {
id: StepIntoAction.ID,
id: STEP_INTO_ID,
title: nls.localize({ key: 'miStepInto', comment: ['&& denotes a mnemonic'] }, "Step &&Into"),
precondition: CONTEXT_DEBUG_STATE.isEqualTo('stopped')
},
......@@ -373,7 +413,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
group: '3_step',
command: {
id: StepOutAction.ID,
id: STEP_OUT_ID,
title: nls.localize({ key: 'miStepOut', comment: ['&& denotes a mnemonic'] }, "Step O&&ut"),
precondition: CONTEXT_DEBUG_STATE.isEqualTo('stopped')
},
......@@ -383,7 +423,7 @@ MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
MenuRegistry.appendMenuItem(MenuId.MenubarDebugMenu, {
group: '3_step',
command: {
id: ContinueAction.ID,
id: CONTINUE_ID,
title: nls.localize({ key: 'miContinue', comment: ['&& denotes a mnemonic'] }, "&&Continue"),
precondition: CONTEXT_DEBUG_STATE.isEqualTo('stopped')
},
......@@ -497,11 +537,11 @@ if (isMacintosh) {
registerTouchBarEntry(StartAction.ID, StartAction.LABEL, 0, CONTEXT_IN_DEBUG_MODE.toNegated(), 'continue-tb.png');
registerTouchBarEntry(RunAction.ID, RunAction.LABEL, 1, CONTEXT_IN_DEBUG_MODE.toNegated(), 'continue-without-debugging-tb.png');
registerTouchBarEntry(ContinueAction.ID, ContinueAction.LABEL, 0, CONTEXT_DEBUG_STATE.isEqualTo('stopped'), 'continue-tb.png');
registerTouchBarEntry(PauseAction.ID, PauseAction.LABEL, 1, ContextKeyExpr.and(CONTEXT_IN_DEBUG_MODE, ContextKeyExpr.notEquals('debugState', 'stopped')), 'pause-tb.png');
registerTouchBarEntry(StepOverAction.ID, StepOverAction.LABEL, 2, CONTEXT_DEBUG_STATE.isEqualTo('stopped'), 'stepover-tb.png');
registerTouchBarEntry(StepIntoAction.ID, StepIntoAction.LABEL, 3, CONTEXT_DEBUG_STATE.isEqualTo('stopped'), 'stepinto-tb.png');
registerTouchBarEntry(StepOutAction.ID, StepOutAction.LABEL, 4, CONTEXT_DEBUG_STATE.isEqualTo('stopped'), 'stepout-tb.png');
registerTouchBarEntry(RestartAction.ID, RestartAction.LABEL, 5, CONTEXT_IN_DEBUG_MODE, 'restart-tb.png');
registerTouchBarEntry(StopAction.ID, StopAction.LABEL, 6, CONTEXT_IN_DEBUG_MODE, 'stop-tb.png');
registerTouchBarEntry(CONTINUE_ID, continueLabel, 0, CONTEXT_DEBUG_STATE.isEqualTo('stopped'), 'continue-tb.png');
registerTouchBarEntry(PAUSE_ID, pauseLabel, 1, ContextKeyExpr.and(CONTEXT_IN_DEBUG_MODE, ContextKeyExpr.notEquals('debugState', 'stopped')), 'pause-tb.png');
registerTouchBarEntry(STEP_OVER_ID, stepOverLabel, 2, CONTEXT_DEBUG_STATE.isEqualTo('stopped'), 'stepover-tb.png');
registerTouchBarEntry(STEP_INTO_ID, stepIntoLabel, 3, CONTEXT_DEBUG_STATE.isEqualTo('stopped'), 'stepinto-tb.png');
registerTouchBarEntry(STEP_OUT_ID, stepOutLabel, 4, CONTEXT_DEBUG_STATE.isEqualTo('stopped'), 'stepout-tb.png');
registerTouchBarEntry(RESTART_SESSION_ID, restartLabel, 5, CONTEXT_IN_DEBUG_MODE, 'restart-tb.png');
registerTouchBarEntry(STOP_ID, stopLabel, 6, CONTEXT_IN_DEBUG_MODE, 'stop-tb.png');
}
......@@ -13,14 +13,14 @@ import { IElement } from '../../vscode/driver';
const VIEWLET = 'div[id="workbench.view.debug"]';
const DEBUG_VIEW = `${VIEWLET} .debug-view-content`;
const CONFIGURE = `div[id="workbench.parts.sidebar"] .actions-container .configure`;
const STOP = `.debug-toolbar .debug-action.stop`;
const STEP_OVER = `.debug-toolbar .debug-action.step-over`;
const STEP_IN = `.debug-toolbar .debug-action.step-into`;
const STEP_OUT = `.debug-toolbar .debug-action.step-out`;
const CONTINUE = `.debug-toolbar .debug-action.continue`;
const STOP = `.debug-toolbar .action-label[title*="Stop"]`;
const STEP_OVER = `.debug-toolbar .action-label[title*="Step Over"]`;
const STEP_IN = `.debug-toolbar .action-label[title*="Step Into"]`;
const STEP_OUT = `.debug-toolbar .action-label[title*="Step Out"]`;
const CONTINUE = `.debug-toolbar .action-label[title*="Continue"]`;
const GLYPH_AREA = '.margin-view-overlays>:nth-child';
const BREAKPOINT_GLYPH = '.debug-breakpoint';
const PAUSE = `.debug-toolbar .debug-action.pause`;
const PAUSE = `.debug-toolbar .action-label[title*="Pause"]`;
const DEBUG_STATUS_BAR = `.statusbar.debugging`;
const NOT_DEBUG_STATUS_BAR = `.statusbar:not(debugging)`;
const TOOLBAR_HIDDEN = `.debug-toolbar[aria-hidden="true"]`;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册