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

Method spawnProcess

src/debug/web_debug_impl.ts:51–96  ·  view source on GitHub ↗
(args: DartLaunchArgs)

Source from the content-addressed store, hash-verified

49 }
50
51 protected async spawnProcess(args: DartLaunchArgs): Promise<SpawnedProcess> {
52 const logger = new DebugAdapterLogger(this, this.logCategory);
53 this.expectAdditionalPidToTerminate = true;
54 this.runDaemon = this.spawnRunDaemon(args, logger);
55 this.runDaemon.registerForUnhandledMessages((msg) => this.handleLogOutput(msg));
56
57 // Set up subscriptions.
58 this.runDaemon.registerForDaemonConnect((n) => this.recordAdditionalPid(n.pid));
59 this.runDaemon.registerForAppStart((n) => this.currentRunningAppId = n.appId);
60 this.runDaemon.registerForAppDebugPort(async (n) => {
61 this.vmServiceUri = n.wsUri;
62 await this.connectToVmServiceIfReady();
63 });
64 this.runDaemon.registerForAppStarted(async (n) => {
65 this.appHasStarted = true;
66 this.outputCategory = "stdout";
67 // In modes like Profile, we'll never connect the debugger, so
68 // we should end our progress reporting here.
69 if (!this.vmServiceUri)
70 this.endProgress(debugLaunchProgressId);
71 else
72 await this.connectToVmServiceIfReady();
73 this.sendEvent(new Event("flutter.appStarted"));
74 });
75 this.runDaemon.registerForAppStop((n) => {
76 this.currentRunningAppId = undefined;
77 if (this.runDaemon) {
78 this.runDaemon.dispose();
79 this.runDaemon = undefined;
80 }
81 });
82
83 this.runDaemon.registerForAppProgress((e) => {
84 if (!this.appHasStarted)
85 this.sendLaunchProgressEvent(e);
86 else
87 this.sendProgressEvent(e);
88 });
89 this.runDaemon.registerForAppWebLaunchUrl((e) => this.sendEvent(new Event("dart.webLaunchUrl", { url: e.url, launched: e.launched })));
90 // TODO: Should this use logToUser?
91 this.runDaemon.registerForError((err) => this.sendEvent(new OutputEvent(`${err}\n`, "stderr")));
92 this.runDaemon.registerForDaemonLog((msg) => this.handleLogOutput(msg.log, msg.error));
93 this.runDaemon.registerForAppLog((msg) => this.handleLogOutput(msg.log, msg.error));
94
95 return this.runDaemon.process!;
96 }
97
98 private sendLaunchProgressEvent(e: AppProgress) {
99 // We ignore finish progress events for launch progress because we use a

Callers 1

launchRequestFunction · 0.80

Calls 15

spawnRunDaemonMethod · 0.95
handleLogOutputMethod · 0.95
sendProgressEventMethod · 0.95
registerForAppStartMethod · 0.80
registerForAppStartedMethod · 0.80
endProgressMethod · 0.80
sendEventMethod · 0.80

Tested by

no test coverage detected