提交 c80a7601 编写于 作者: I isidor

strict null checks: electronDebugActions and variablesView

上级 fa93b07d
...@@ -252,7 +252,9 @@ ...@@ -252,7 +252,9 @@
"./vs/workbench/contrib/debug/browser/exceptionWidget.ts", "./vs/workbench/contrib/debug/browser/exceptionWidget.ts",
"./vs/workbench/contrib/debug/browser/linkDetector.ts", "./vs/workbench/contrib/debug/browser/linkDetector.ts",
"./vs/workbench/contrib/debug/browser/statusbarColorProvider.ts", "./vs/workbench/contrib/debug/browser/statusbarColorProvider.ts",
"./vs/workbench/contrib/debug/electron-browser/electronDebugActions.ts",
"./vs/workbench/contrib/debug/electron-browser/rawDebugSession.ts", "./vs/workbench/contrib/debug/electron-browser/rawDebugSession.ts",
"./vs/workbench/contrib/debug/electron-browser/variablesView.ts",
"./vs/workbench/contrib/debug/test/common/debugSource.test.ts", "./vs/workbench/contrib/debug/test/common/debugSource.test.ts",
"./vs/workbench/contrib/debug/test/common/debugUtils.test.ts", "./vs/workbench/contrib/debug/test/common/debugUtils.test.ts",
"./vs/workbench/contrib/debug/test/common/mockDebug.ts", "./vs/workbench/contrib/debug/test/common/mockDebug.ts",
......
...@@ -247,7 +247,7 @@ export class Expression extends ExpressionContainer implements IExpression { ...@@ -247,7 +247,7 @@ export class Expression extends ExpressionContainer implements IExpression {
export class Variable extends ExpressionContainer implements IExpression { export class Variable extends ExpressionContainer implements IExpression {
// Used to show the error message coming from the adapter when setting the value #7807 // Used to show the error message coming from the adapter when setting the value #7807
public errorMessage: string; public errorMessage: string | undefined;
constructor( constructor(
session: IDebugSession | undefined, session: IDebugSession | undefined,
......
...@@ -20,10 +20,11 @@ export class CopyValueAction extends Action { ...@@ -20,10 +20,11 @@ export class CopyValueAction extends Action {
} }
public run(): Promise<any> { public run(): Promise<any> {
if (this.value instanceof Variable) { const stackFrame = this.debugService.getViewModel().focusedStackFrame;
const frameId = this.debugService.getViewModel().focusedStackFrame.frameId; const session = this.debugService.getViewModel().focusedSession;
const session = this.debugService.getViewModel().focusedSession;
return session.evaluate(this.value.evaluateName, frameId, this.context).then(result => { if (this.value instanceof Variable && stackFrame && session && this.value.evaluateName) {
return session.evaluate(this.value.evaluateName, stackFrame.frameId, this.context).then(result => {
clipboard.writeText(result.body.result); clipboard.writeText(result.body.result);
}, err => clipboard.writeText(this.value.value)); }, err => clipboard.writeText(this.value.value));
} }
...@@ -43,7 +44,7 @@ export class CopyEvaluatePathAction extends Action { ...@@ -43,7 +44,7 @@ export class CopyEvaluatePathAction extends Action {
} }
public run(): Promise<any> { public run(): Promise<any> {
clipboard.writeText(this.value.evaluateName); clipboard.writeText(this.value.evaluateName!);
return Promise.resolve(undefined); return Promise.resolve(undefined);
} }
} }
......
...@@ -129,14 +129,15 @@ export class VariablesView extends ViewletPanel { ...@@ -129,14 +129,15 @@ export class VariablesView extends ViewletPanel {
private onMouseDblClick(e: ITreeMouseEvent<IExpression | IScope>): void { private onMouseDblClick(e: ITreeMouseEvent<IExpression | IScope>): void {
const session = this.debugService.getViewModel().focusedSession; const session = this.debugService.getViewModel().focusedSession;
if (e.element instanceof Variable && session.capabilities.supportsSetVariable) { if (session && e.element instanceof Variable && session.capabilities.supportsSetVariable) {
this.debugService.getViewModel().setSelectedExpression(e.element); this.debugService.getViewModel().setSelectedExpression(e.element);
} }
} }
private onContextMenu(e: ITreeContextMenuEvent<IExpression | IScope>): void { private onContextMenu(e: ITreeContextMenuEvent<IExpression | IScope>): void {
const element = e.element; const element = e.element;
if (element instanceof Variable && !!element.value) { const anchor = e.anchor;
if (element instanceof Variable && !!element.value && anchor) {
const actions: IAction[] = []; const actions: IAction[] = [];
const variable = element as Variable; const variable = element as Variable;
actions.push(new SetValueAction(SetValueAction.ID, SetValueAction.LABEL, variable, this.debugService, this.keybindingService)); actions.push(new SetValueAction(SetValueAction.ID, SetValueAction.LABEL, variable, this.debugService, this.keybindingService));
...@@ -146,7 +147,7 @@ export class VariablesView extends ViewletPanel { ...@@ -146,7 +147,7 @@ export class VariablesView extends ViewletPanel {
actions.push(new AddToWatchExpressionsAction(AddToWatchExpressionsAction.ID, AddToWatchExpressionsAction.LABEL, variable, this.debugService, this.keybindingService)); actions.push(new AddToWatchExpressionsAction(AddToWatchExpressionsAction.ID, AddToWatchExpressionsAction.LABEL, variable, this.debugService, this.keybindingService));
this.contextMenuService.showContextMenu({ this.contextMenuService.showContextMenu({
getAnchor: () => e.anchor, getAnchor: () => anchor,
getActions: () => actions, getActions: () => actions,
getActionsContext: () => element getActionsContext: () => element
}); });
...@@ -193,11 +194,8 @@ class VariablesDelegate implements IListVirtualDelegate<IExpression | IScope> { ...@@ -193,11 +194,8 @@ class VariablesDelegate implements IListVirtualDelegate<IExpression | IScope> {
if (element instanceof Scope) { if (element instanceof Scope) {
return ScopesRenderer.ID; return ScopesRenderer.ID;
} }
if (element instanceof Variable) {
return VariablesRenderer.ID;
}
return null; return VariablesRenderer.ID;
} }
} }
...@@ -246,7 +244,7 @@ export class VariablesRenderer extends AbstractExpressionsRenderer { ...@@ -246,7 +244,7 @@ export class VariablesRenderer extends AbstractExpressionsRenderer {
validation: () => variable.errorMessage ? ({ content: variable.errorMessage }) : null validation: () => variable.errorMessage ? ({ content: variable.errorMessage }) : null
}, },
onFinish: (value: string, success: boolean) => { onFinish: (value: string, success: boolean) => {
variable.errorMessage = null; variable.errorMessage = undefined;
if (success && variable.value !== value) { if (success && variable.value !== value) {
variable.setVariable(value) variable.setVariable(value)
// Need to force watch expressions and variables to update since a variable change can have an effect on both // Need to force watch expressions and variables to update since a variable change can have an effect on both
...@@ -258,7 +256,7 @@ export class VariablesRenderer extends AbstractExpressionsRenderer { ...@@ -258,7 +256,7 @@ export class VariablesRenderer extends AbstractExpressionsRenderer {
} }
class VariablesAccessibilityProvider implements IAccessibilityProvider<IExpression | IScope> { class VariablesAccessibilityProvider implements IAccessibilityProvider<IExpression | IScope> {
getAriaLabel(element: IExpression | IScope): string { getAriaLabel(element: IExpression | IScope): string | null {
if (element instanceof Scope) { if (element instanceof Scope) {
return nls.localize('variableScopeAriaLabel', "Scope {0}, variables, debug", element.name); return nls.localize('variableScopeAriaLabel', "Scope {0}, variables, debug", element.name);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册