Skip to content

Commit 3aec07b

Browse files
authored
fix: debug focus, remove 'kind' discriminators 63943 (microsoft#181244)
* fix: review comments, remove 'kind' discrims, use instanceof * fix: tweak the isXXXX checks, add some prop typeof checks * fix: review, remove isX duck type fncs, and construct object
1 parent 53c319d commit 3aec07b

File tree

4 files changed

+50
-22
lines changed

4 files changed

+50
-22
lines changed

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
15161516
EditSessionIdentityMatch: EditSessionIdentityMatch,
15171517
InteractiveSessionVoteDirection: extHostTypes.InteractiveSessionVoteDirection,
15181518
InteractiveSessionCopyKind: extHostTypes.InteractiveSessionCopyKind,
1519-
InteractiveEditorResponseFeedbackKind: extHostTypes.InteractiveEditorResponseFeedbackKind
1519+
InteractiveEditorResponseFeedbackKind: extHostTypes.InteractiveEditorResponseFeedbackKind,
1520+
StackFrameFocus: extHostTypes.StackFrameFocus,
1521+
ThreadFocus: extHostTypes.ThreadFocus
15201522
};
15211523
};
15221524
}

src/vs/workbench/api/common/extHostDebugService.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { DebugSessionUUID, ExtHostDebugServiceShape, IBreakpointsDeltaDto, IThre
1616
import { IExtHostEditorTabs } from 'vs/workbench/api/common/extHostEditorTabs';
1717
import { IExtHostExtensionService } from 'vs/workbench/api/common/extHostExtensionService';
1818
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
19-
import { Breakpoint, DataBreakpoint, DebugAdapterExecutable, DebugAdapterInlineImplementation, DebugAdapterNamedPipeServer, DebugAdapterServer, DebugConsoleMode, Disposable, FunctionBreakpoint, Location, Position, setBreakpointId, SourceBreakpoint } from 'vs/workbench/api/common/extHostTypes';
19+
import { Breakpoint, DataBreakpoint, DebugAdapterExecutable, DebugAdapterInlineImplementation, DebugAdapterNamedPipeServer, DebugAdapterServer, DebugConsoleMode, Disposable, FunctionBreakpoint, Location, Position, setBreakpointId, SourceBreakpoint, ThreadFocus, StackFrameFocus } from 'vs/workbench/api/common/extHostTypes';
2020
import { IExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
2121
import { AbstractDebugAdapter } from 'vs/workbench/contrib/debug/common/abstractDebugAdapter';
2222
import { IAdapterDescriptor, IConfig, IDebugAdapter, IDebugAdapterExecutable, IDebugAdapterNamedPipeServer, IDebugAdapterServer, IDebuggerContribution } from 'vs/workbench/contrib/debug/common/debug';
@@ -601,29 +601,20 @@ export abstract class ExtHostDebugServiceBase implements IExtHostDebugService, E
601601
}
602602

603603
public async $acceptStackFrameFocus(focusDto: IThreadFocusDto | IStackFrameFocusDto): Promise<void> {
604-
let focus: vscode.ThreadFocus | vscode.StackFrameFocus;
604+
let focus: ThreadFocus | StackFrameFocus;
605605
const session = focusDto.sessionId ? await this.getSession(focusDto.sessionId) : undefined;
606606
if (!session) {
607607
throw new Error('no DebugSession found for debug focus context');
608608
}
609609

610610
if (focusDto.kind === 'thread') {
611-
focus = {
612-
kind: focusDto.kind,
613-
threadId: focusDto.threadId,
614-
session,
615-
};
611+
focus = new ThreadFocus(session, focusDto.threadId);
616612
} else {
617-
focus = {
618-
kind: focusDto.kind,
619-
threadId: focusDto.threadId,
620-
frameId: focusDto.frameId,
621-
session,
622-
};
613+
focus = new StackFrameFocus(session, focusDto.threadId, focusDto.frameId);
623614
}
624615

625-
this._stackFrameFocus = focus;
626-
this._onDidChangeStackFrameFocus.fire(focus);
616+
this._stackFrameFocus = <vscode.ThreadFocus | vscode.StackFrameFocus>focus;
617+
this._onDidChangeStackFrameFocus.fire(this._stackFrameFocus);
627618
}
628619

629620
public $provideDebugConfigurations(configProviderHandle: number, folderUri: UriComponents | undefined, token: CancellationToken): Promise<vscode.DebugConfiguration[]> {

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,6 +2957,24 @@ export class DebugAdapterInlineImplementation implements vscode.DebugAdapterInli
29572957
}
29582958
}
29592959

2960+
2961+
@es5ClassCompat
2962+
export class StackFrameFocus {
2963+
constructor(
2964+
public readonly session: vscode.DebugSession,
2965+
readonly threadId?: number,
2966+
readonly frameId?: number) { }
2967+
}
2968+
2969+
@es5ClassCompat
2970+
export class ThreadFocus {
2971+
constructor(
2972+
public readonly session: vscode.DebugSession,
2973+
readonly threadId?: number) { }
2974+
}
2975+
2976+
2977+
29602978
@es5ClassCompat
29612979
export class EvaluatableExpression implements vscode.EvaluatableExpression {
29622980
readonly range: vscode.Range;

src/vscode-dts/vscode.proposed.debugFocus.d.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@ declare module 'vscode' {
77

88
// See https://github.com/microsoft/vscode/issues/63943
99

10-
export interface ThreadFocus {
11-
// eslint-disable-next-line local/vscode-dts-string-type-literals
12-
kind: 'thread';
10+
export class ThreadFocus {
11+
/**
12+
* Create a ThreadFocus
13+
* @param session
14+
* @param threadId
15+
* @param frameId
16+
*/
17+
constructor(
18+
session: DebugSession,
19+
threadId?: number);
20+
1321

1422
/**
1523
* Debug session for thread.
@@ -22,9 +30,18 @@ declare module 'vscode' {
2230
readonly threadId: number | undefined;
2331
}
2432

25-
export interface StackFrameFocus {
26-
// eslint-disable-next-line local/vscode-dts-string-type-literals
27-
kind: 'stackFrame';
33+
export class StackFrameFocus {
34+
/**
35+
* Create a StackFrameFocus
36+
* @param session
37+
* @param threadId
38+
* @param frameId
39+
*/
40+
constructor(
41+
session: DebugSession,
42+
threadId?: number,
43+
frameId?: number);
44+
2845

2946
/**
3047
* Debug session for thread.

0 commit comments

Comments
 (0)