MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / startFakeDebugSession

Function startFakeDebugSession

src/test/debug_helpers.ts:90–125  ·  view source on GitHub ↗
(options?: {
	debuggerType?: DebuggerType;
	hasStarted?: boolean;
	id?: string;
	name?: string;
})

Source from the content-addressed store, hash-verified

88}
89
90export function startFakeDebugSession(options?: {
91 debuggerType?: DebuggerType;
92 hasStarted?: boolean;
93 id?: string;
94 name?: string;
95}): DebugSession & { hotReloadCount: number } {
96 const debuggerType = options?.debuggerType;
97 const configuration = {
98 debuggerType,
99 name: options?.name ?? "Fake Debug Session",
100 request: "launch",
101 type: "dart",
102 };
103
104 let hotReloadCount = 0;
105 const session = {
106 configuration,
107 id: options?.id ?? `fake-${debuggerType ?? "session"}`,
108 name: configuration.name,
109 type: configuration.type,
110 workspaceFolder: undefined,
111 async getDebugProtocolBreakpoint() { return undefined; },
112 async customRequest(command: string) {
113 if (command === "hotReload")
114 hotReloadCount++;
115 },
116 get hotReloadCount() { return hotReloadCount; },
117 } as DebugSession & { hotReloadCount: number };
118
119 const dartSession = privateApi.debugCommands.handleDebugSessionStart(session);
120 if (options?.hasStarted && dartSession)
121 dartSession.hasStarted = true;
122 defer("Remove fake debug session", () => privateApi.debugCommands.handleDebugSessionEnd(session));
123
124 return session;
125}
126
127/// Waits for all the provided promises, but throws if the debugger terminates before they complete.
128export function waitAllThrowIfTerminates(dc: DartDebugClient, ...promises: Array<Promise<any>>) {

Callers 4

debug.test.tsFile · 0.90
startSessionFunction · 0.90
devtools.test.tsFile · 0.90
flutter.test.tsFile · 0.90

Calls 3

deferFunction · 0.90
handleDebugSessionEndMethod · 0.65

Tested by 1

startSessionFunction · 0.72