提交 003ff303 编写于 作者: I isidor

strict null check: debug actions

上级 e9f899f5
......@@ -241,6 +241,7 @@
"./vs/workbench/contrib/debug/browser/exceptionWidget.ts",
"./vs/workbench/contrib/debug/browser/linkDetector.ts",
"./vs/workbench/contrib/debug/browser/baseDebugView.ts",
"./vs/workbench/contrib/debug/browser/debugActions.ts",
"./vs/workbench/contrib/debug/browser/statusbarColorProvider.ts",
"./vs/workbench/contrib/debug/electron-browser/rawDebugSession.ts",
"./vs/workbench/contrib/debug/test/common/debugSource.test.ts",
......
......@@ -7,9 +7,7 @@ import * as nls from 'vs/nls';
import { Action } from 'vs/base/common/actions';
import * as lifecycle from 'vs/base/common/lifecycle';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IFileService } from 'vs/platform/files/common/files';
import { IDebugService, State, IDebugSession, IThread, IEnablement, IBreakpoint, IStackFrame, REPL_ID }
from 'vs/workbench/contrib/debug/common/debug';
import { Variable, Expression, Thread, Breakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
......@@ -113,7 +111,7 @@ export class ConfigureAction extends AbstractDebugAction {
configurationManager.selectConfiguration(configurationManager.getLaunches()[0]);
}
return configurationManager.selectedConfiguration.launch.openConfigFile(sideBySide, false);
return configurationManager.selectedConfiguration.launch!.openConfigFile(sideBySide, false);
}
}
......@@ -145,7 +143,7 @@ export class StartAction extends AbstractDebugAction {
launch = configurationManager.getLaunch(rootUri);
if (!launch || launch.getConfigurationNames().length === 0) {
const launches = configurationManager.getLaunches();
launch = first(launches, l => !!l.getConfigurationNames().length, launch);
launch = first(launches, l => !!(l && l.getConfigurationNames().length), launch);
}
configurationManager.selectConfiguration(launch);
......@@ -194,12 +192,9 @@ export class SelectAndStartAction extends AbstractDebugAction {
constructor(id: string, label: string,
@IDebugService debugService: IDebugService,
@IKeybindingService keybindingService: IKeybindingService,
@ICommandService commandService: ICommandService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IFileService fileService: IFileService,
@IQuickOpenService private readonly quickOpenService: IQuickOpenService
) {
super(id, label, undefined, debugService, keybindingService);
super(id, label, '', debugService, keybindingService);
}
public run(): Promise<any> {
......@@ -228,11 +223,13 @@ export class RestartAction extends AbstractDebugAction {
return new StartAction(StartAction.ID, StartAction.LABEL, this.debugService, this.keybindingService, this.contextService, this.historyService);
}
private setLabel(session: IDebugSession): void {
this.updateLabel(session && session.configuration.request === 'attach' ? RestartAction.RECONNECT_LABEL : RestartAction.LABEL);
private setLabel(session: IDebugSession | undefined): void {
if (session) {
this.updateLabel(session && session.configuration.request === 'attach' ? RestartAction.RECONNECT_LABEL : RestartAction.LABEL);
}
}
public run(session: IDebugSession): Promise<any> {
public run(session: IDebugSession | undefined): Promise<any> {
if (!session || !session.getId) {
session = this.debugService.getViewModel().focusedSession;
}
......@@ -262,7 +259,7 @@ export class StepOverAction extends AbstractDebugAction {
super(id, label, 'debug-action step-over', debugService, keybindingService, 20);
}
public run(thread: IThread): Promise<any> {
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
......@@ -283,7 +280,7 @@ export class StepIntoAction extends AbstractDebugAction {
super(id, label, 'debug-action step-into', debugService, keybindingService, 30);
}
public run(thread: IThread): Promise<any> {
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
......@@ -304,7 +301,7 @@ export class StepOutAction extends AbstractDebugAction {
super(id, label, 'debug-action step-out', debugService, keybindingService, 40);
}
public run(thread: IThread): Promise<any> {
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
......@@ -325,7 +322,7 @@ export class StopAction extends AbstractDebugAction {
super(id, label, 'debug-action stop', debugService, keybindingService, 80);
}
public run(session: IDebugSession): Promise<any> {
public run(session: IDebugSession | undefined): Promise<any> {
if (!session || !session.getId) {
session = this.debugService.getViewModel().focusedSession;
}
......@@ -364,7 +361,7 @@ export class ContinueAction extends AbstractDebugAction {
super(id, label, 'debug-action continue', debugService, keybindingService, 10);
}
public run(thread: IThread): Promise<any> {
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
......@@ -385,7 +382,7 @@ export class PauseAction extends AbstractDebugAction {
super(id, label, 'debug-action pause', debugService, keybindingService, 10);
}
public run(thread: IThread): Promise<any> {
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
if (!thread) {
......@@ -408,10 +405,10 @@ export class TerminateThreadAction extends AbstractDebugAction {
static LABEL = nls.localize('terminateThread', "Terminate Thread");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, undefined, debugService, keybindingService);
super(id, label, '', debugService, keybindingService);
}
public run(thread: IThread): Promise<any> {
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
......@@ -429,15 +426,15 @@ export class RestartFrameAction extends AbstractDebugAction {
static LABEL = nls.localize('restartFrame', "Restart Frame");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, undefined, debugService, keybindingService);
super(id, label, '', debugService, keybindingService);
}
public run(frame: IStackFrame): Promise<any> {
public run(frame: IStackFrame | undefined): Promise<any> {
if (!frame) {
frame = this.debugService.getViewModel().focusedStackFrame;
}
return frame.restart();
return frame!.restart();
}
}
......@@ -541,7 +538,7 @@ export class ReapplyBreakpointsAction extends AbstractDebugAction {
static LABEL = nls.localize('reapplyAllBreakpoints', "Reapply All Breakpoints");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, null, debugService, keybindingService);
super(id, label, '', debugService, keybindingService);
this.toDispose.push(this.debugService.getModel().onDidChangeBreakpoints(() => this.updateEnablement()));
}
......@@ -581,7 +578,7 @@ export class SetValueAction extends AbstractDebugAction {
static LABEL = nls.localize('setValue', "Set Value");
constructor(id: string, label: string, private variable: Variable, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, null, debugService, keybindingService);
super(id, label, '', debugService, keybindingService);
}
public run(): Promise<any> {
......@@ -623,7 +620,7 @@ export class EditWatchExpressionAction extends AbstractDebugAction {
static LABEL = nls.localize('editWatchExpression', "Edit Expression");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, undefined, debugService, keybindingService);
super(id, label, '', debugService, keybindingService);
}
public run(expression: Expression): Promise<any> {
......@@ -656,7 +653,7 @@ export class RemoveWatchExpressionAction extends AbstractDebugAction {
static LABEL = nls.localize('removeWatchExpression', "Remove Expression");
constructor(id: string, label: string, @IDebugService debugService: IDebugService, @IKeybindingService keybindingService: IKeybindingService) {
super(id, label, undefined, debugService, keybindingService);
super(id, label, '', debugService, keybindingService);
}
public run(expression: Expression): Promise<any> {
......@@ -740,7 +737,7 @@ export class FocusSessionAction extends AbstractDebugAction {
@IKeybindingService keybindingService: IKeybindingService,
@IEditorService private readonly editorService: IEditorService
) {
super(id, label, null, debugService, keybindingService, 100);
super(id, label, '', debugService, keybindingService, 100);
}
public run(sessionName: string): Promise<any> {
......@@ -764,7 +761,7 @@ export class StepBackAction extends AbstractDebugAction {
super(id, label, 'debug-action step-back', debugService, keybindingService, 50);
}
public run(thread: IThread): Promise<any> {
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
......@@ -787,7 +784,7 @@ export class ReverseContinueAction extends AbstractDebugAction {
super(id, label, 'debug-action reverse-continue', debugService, keybindingService, 60);
}
public run(thread: IThread): Promise<any> {
public run(thread: IThread | undefined): Promise<any> {
if (!(thread instanceof Thread)) {
thread = this.debugService.getViewModel().focusedThread;
}
......
......@@ -89,11 +89,11 @@ export class DebugStatus extends Themable implements IStatusbarItem {
private setLabel(): void {
if (this.label && this.statusBarItem) {
const manager = this.debugService.getConfigurationManager();
const name = manager.selectedConfiguration.name;
const name = manager.selectedConfiguration.name || '';
const nameAndLaunchPresent = name && manager.selectedConfiguration.launch;
dom.toggleClass(this.statusBarItem, 'hidden', this.showInStatusBar === 'never' || !nameAndLaunchPresent);
if (nameAndLaunchPresent) {
this.label.textContent = manager.getLaunches().length > 1 ? `${name} (${manager.selectedConfiguration.launch.name})` : name;
this.label.textContent = manager.getLaunches().length > 1 ? `${name} (${manager.selectedConfiguration.launch!.name})` : name;
}
}
}
......
......@@ -585,11 +585,11 @@ export interface IConfigurationManager {
* Returns an object containing the selected launch configuration and the selected configuration name. Both these fields can be null (no folder workspace).
*/
readonly selectedConfiguration: {
launch: ILaunch;
name: string;
launch: ILaunch | undefined;
name: string | undefined;
};
selectConfiguration(launch: ILaunch, name?: string, debugStarted?: boolean): void;
selectConfiguration(launch: ILaunch | undefined, name?: string, debugStarted?: boolean): void;
getLaunches(): ReadonlyArray<ILaunch>;
......@@ -710,7 +710,7 @@ export interface IDebugService {
/**
* Sets the focused stack frame and evaluates all expressions against the newly focused stack frame,
*/
focusStackFrame(focusedStackFrame: IStackFrame, thread?: IThread, session?: IDebugSession, explicit?: boolean): void;
focusStackFrame(focusedStackFrame: IStackFrame | undefined, thread?: IThread, session?: IDebugSession, explicit?: boolean): void;
/**
* Adds new breakpoints to the model for the file specified with the uri. Notifies debug adapter of breakpoint changes.
......@@ -801,7 +801,7 @@ export interface IDebugService {
/**
* Stops the session. If the session does not exist then stops all sessions.
*/
stopSession(session: IDebugSession): Promise<any>;
stopSession(session: IDebugSession | undefined): Promise<any>;
/**
* Makes unavailable all sources with the passed uri. Source will appear as grayed out in callstack view.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册