提交 58b7cc9f 编写于 作者: I isidor

strict null checks: callStackView

上级 471b98c1
......@@ -35,6 +35,7 @@
"./vs/workbench/contrib/debug/common/**/*.ts",
"./vs/workbench/contrib/debug/browser/**/*.ts",
"./vs/workbench/contrib/debug/node/**/*.ts",
"./vs/workbench/contrib/debug/electron-browser/**/*.ts",
"./vs/workbench/contrib/preferences/common/**/*.ts",
"./vs/workbench/contrib/preferences/**/settings*.ts",
"./vs/workbench/contrib/terminal/**/*"
......@@ -157,18 +158,6 @@
"./vs/workbench/contrib/comments/electron-browser/commentsTreeViewer.ts",
"./vs/workbench/contrib/comments/electron-browser/reactionsAction.ts",
"./vs/workbench/contrib/comments/electron-browser/simpleCommentEditor.ts",
"./vs/workbench/contrib/debug/electron-browser/breakpointWidget.ts",
"./vs/workbench/contrib/debug/electron-browser/debugEditorContribution.ts",
"./vs/workbench/contrib/debug/electron-browser/debugHover.ts",
"./vs/workbench/contrib/debug/electron-browser/terminalSupport.ts",
"./vs/workbench/contrib/debug/electron-browser/debugSession.ts",
"./vs/workbench/contrib/debug/electron-browser/electronDebugActions.ts",
"./vs/workbench/contrib/debug/electron-browser/rawDebugSession.ts",
"./vs/workbench/contrib/debug/electron-browser/repl.ts",
"./vs/workbench/contrib/debug/electron-browser/variablesView.ts",
"./vs/workbench/contrib/debug/electron-browser/watchExpressionsView.ts",
"./vs/workbench/contrib/debug/electron-browser/debugConfigurationManager.ts",
"./vs/workbench/contrib/debug/electron-browser/debugService.ts",
"./vs/workbench/contrib/debug/test/browser/baseDebugView.test.ts",
"./vs/workbench/contrib/debug/test/common/debugSource.test.ts",
"./vs/workbench/contrib/debug/test/common/debugUtils.test.ts",
......
......@@ -145,7 +145,7 @@ export interface ITreeMouseEvent<T> {
export interface ITreeContextMenuEvent<T> {
browserEvent: UIEvent;
element: T | null;
anchor: HTMLElement | { x: number; y: number; } | undefined;
anchor: HTMLElement | { x: number; y: number; };
}
export interface ITreeNavigator<T> {
......
......@@ -156,7 +156,7 @@ export class CallStackView extends ViewletPanel {
return;
}
const focusStackFrame = (stackFrame: IStackFrame, thread: IThread, session: IDebugSession) => {
const focusStackFrame = (stackFrame: IStackFrame | undefined, thread: IThread | undefined, session: IDebugSession) => {
this.ignoreFocusStackFrameEvent = true;
try {
this.debugService.focusStackFrame(stackFrame, thread, session, true);
......@@ -309,7 +309,7 @@ export class CallStackView extends ViewletPanel {
});
}
private getContextForContributedActions(element: CallStackItem): string | number {
private getContextForContributedActions(element: CallStackItem | null): string | number | undefined {
if (element instanceof StackFrame) {
if (element.source.inMemory) {
return element.source.raw.path || element.source.reference;
......@@ -563,11 +563,9 @@ class CallStackDelegate implements IListVirtualDelegate<CallStackItem> {
if (element instanceof ThreadAndSessionIds) {
return LoadMoreRenderer.ID;
}
if (element instanceof Array) {
return ShowMoreRenderer.ID;
}
return undefined;
// element instanceof Array
return ShowMoreRenderer.ID;
}
}
......@@ -606,18 +604,21 @@ class CallStackDataSource implements IAsyncDataSource<IDebugModel, CallStackItem
}
}
private getThreadChildren(thread: Thread): Promise<Array<IStackFrame | string | ThreadAndSessionIds>> {
private getThreadChildren(thread: Thread): Promise<CallStackItem[]> {
return this.getThreadCallstack(thread).then(children => {
// Check if some stack frames should be hidden under a parent element since they are deemphasized
const result = [];
const result: CallStackItem[] = [];
children.forEach((child, index) => {
if (child instanceof StackFrame && child.source && isDeemphasized(child)) {
// Check if the user clicked to show the deemphasized source
if (this.deemphasizedStackFramesToShow.indexOf(child) === -1) {
if (result.length && result[result.length - 1] instanceof Array) {
// Collect all the stackframes that will be "collapsed"
result[result.length - 1].push(child);
return;
if (result.length) {
const last = result[result.length - 1];
if (last instanceof Array) {
// Collect all the stackframes that will be "collapsed"
last.push(child);
return;
}
}
const nextChild = index < children.length - 1 ? children[index + 1] : undefined;
......@@ -644,7 +645,7 @@ class CallStackDataSource implements IAsyncDataSource<IDebugModel, CallStackItem
}
return callStackPromise.then(() => {
if (callStack.length === 1 && thread.session.capabilities.supportsDelayedStackTraceLoading && thread.stoppedDetails && thread.stoppedDetails.totalFrames > 1) {
if (callStack.length === 1 && thread.session.capabilities.supportsDelayedStackTraceLoading && thread.stoppedDetails && thread.stoppedDetails.totalFrames && thread.stoppedDetails.totalFrames > 1) {
// To reduce flashing of the call stack view simply append the stale call stack
// once we have the correct data the tree will refresh and we will no longer display it.
callStack = callStack.concat(thread.getStaleCallStack().slice(1));
......@@ -653,7 +654,7 @@ class CallStackDataSource implements IAsyncDataSource<IDebugModel, CallStackItem
if (thread.stoppedDetails && thread.stoppedDetails.framesErrorMessage) {
callStack = callStack.concat([thread.stoppedDetails.framesErrorMessage]);
}
if (thread.stoppedDetails && thread.stoppedDetails.totalFrames > callStack.length && callStack.length > 1) {
if (thread.stoppedDetails && thread.stoppedDetails.totalFrames && thread.stoppedDetails.totalFrames > callStack.length && callStack.length > 1) {
callStack = callStack.concat([new ThreadAndSessionIds(thread.session.getId(), thread.threadId)]);
}
......@@ -676,13 +677,11 @@ class CallStackAccessibilityProvider implements IAccessibilityProvider<CallStack
if (typeof element === 'string') {
return element;
}
if (element instanceof ThreadAndSessionIds) {
return nls.localize('loadMoreStackFrames', "Load More Stack Frames");
}
if (element instanceof Array) {
return nls.localize('showMoreStackFrames', "Show {0} More Stack Frames", element.length);
}
return null;
// element instanceof ThreadAndSessionIds
return nls.localize('loadMoreStackFrames', "Load More Stack Frames");
}
}
......@@ -465,7 +465,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
actions.push(this.clearReplAction);
this.contextMenuService.showContextMenu({
getAnchor: () => e.anchor!,
getAnchor: () => e.anchor,
getActions: () => actions,
getActionsContext: () => e.element
});
......
......@@ -136,8 +136,7 @@ export class VariablesView extends ViewletPanel {
private onContextMenu(e: ITreeContextMenuEvent<IExpression | IScope>): void {
const element = e.element;
const anchor = e.anchor;
if (element instanceof Variable && !!element.value && anchor) {
if (element instanceof Variable && !!element.value) {
const actions: IAction[] = [];
const variable = element as Variable;
actions.push(new SetValueAction(SetValueAction.ID, SetValueAction.LABEL, variable, this.debugService, this.keybindingService));
......@@ -147,7 +146,7 @@ export class VariablesView extends ViewletPanel {
actions.push(new AddToWatchExpressionsAction(AddToWatchExpressionsAction.ID, AddToWatchExpressionsAction.LABEL, variable, this.debugService, this.keybindingService));
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getAnchor: () => e.anchor,
getActions: () => actions,
getActionsContext: () => element
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册