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

Method spawn

src/extension/sdk/dev_tools/manager.ts:218–263  ·  view source on GitHub ↗
(session: (DartDebugSessionInformation & { vmServiceUri: string }) | undefined, options: DevToolsOptions, forceShow: boolean)

Source from the content-addressed store, hash-verified

216 /// Spawns DevTools and returns the full URL to open for that session
217 /// eg. http://127.0.0.1:8123/?port=8543
218 public async spawn(session: (DartDebugSessionInformation & { vmServiceUri: string }) | undefined, options: DevToolsOptions, forceShow: boolean): Promise<{ url: string; dispose: () => void } | undefined> {
219 this.analytics.logDevToolsOpened(options?.commandSource);
220
221 const url = await this.start();
222 if (!url)
223 return;
224
225 if (options.location === undefined)
226 options.location = this.getDevToolsLocation(options.pageId);
227 if (options.reuseWindows === undefined)
228 options.reuseWindows = config.devToolsReuseWindows;
229
230 // When we're running embedded and were asked to open without a page, we should prompt for a page (plus give an option
231 // to open non-embedded view).
232 if (options.location !== "external" && !options.pageId) {
233 const choice = await this.promptForDevToolsPage(!!session);
234 if (!choice) // User cancelled
235 return;
236 else if (choice === "EXTERNAL")
237 options.location = "external";
238 else
239 options.pageId = choice.page.id;
240 }
241
242 try {
243 await vs.window.withProgress({
244 location: vs.ProgressLocation.Notification,
245 title: "Opening DevTools...",
246 }, async () => {
247 const debugCommands = this.debugCommands;
248 const canLaunchDevToolsThroughService = isRunningLocally
249 && session
250 && debugCommands
251 && options.location === "external"
252 && !isDartCodeTestRun
253 && config.devToolsBrowser === "chrome"
254 && await waitFor(() => debugCommands.vmServices.serviceIsRegistered(VmService.LaunchDevTools), 500);
255
256 await this.launch(!!canLaunchDevToolsThroughService, session, options, forceShow);
257 });
258
259 return { url, dispose: () => this.dispose() };
260 } catch (e) {
261 this.showError(e);
262 }
263 }
264
265 private async promptForDevToolsPage(hasSession: boolean): Promise<{ page: DevToolsPage } | "EXTERNAL" | undefined> {
266 const choices: Array<vs.QuickPickItem & { page?: DevToolsPage; isExternal?: boolean }> = [

Callers 7

startMethod · 0.80
safeSpawnFunction · 0.80
constructorMethod · 0.80
startMethod · 0.80
createNcProcessMethod · 0.80
onShownMethod · 0.80

Calls 9

startMethod · 0.95
getDevToolsLocationMethod · 0.95
promptForDevToolsPageMethod · 0.95
launchMethod · 0.95
disposeMethod · 0.95
showErrorMethod · 0.95
waitForFunction · 0.90
logDevToolsOpenedMethod · 0.80
serviceIsRegisteredMethod · 0.80

Tested by

no test coverage detected