| 88 | } |
| 89 | |
| 90 | export 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. |
| 128 | export function waitAllThrowIfTerminates(dc: DartDebugClient, ...promises: Array<Promise<any>>) { |