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

Method constructor

src/extension/flutter/flutter_daemon.ts:38–89  ·  view source on GitHub ↗
(logger: Logger, private readonly analytics: Analytics, private readonly workspaceContext: FlutterWorkspaceContext, flutterCapabilities: FlutterCapabilities, private readonly runIfNoDevices?: () => void, portFromLocalExtension?: number)

Source from the content-addressed store, hash-verified

36 private didSpawnWithAdditionalArgs = false;
37
38 constructor(logger: Logger, private readonly analytics: Analytics, private readonly workspaceContext: FlutterWorkspaceContext, flutterCapabilities: FlutterCapabilities, private readonly runIfNoDevices?: () => void, portFromLocalExtension?: number) {
39 super(new CategoryLogger(logger, LogCategory.FlutterDaemon), config.maxLogLineLength, true, true);
40
41 const folder = workspaceContext.sdks.flutter;
42
43 this.registerForDaemonConnected((e) => {
44 this.additionalPidsToTerminate.push(e.pid);
45 this.capabilities.version = e.version;
46 void vs.commands.executeCommand("setContext", FLUTTER_SUPPORTS_ATTACH, this.capabilities.canFlutterAttach);
47
48 // Delay marking as initialized for a few seconds to see whether it helps prevent
49 // the first emulator requests from hanging.
50 // https://github.com/Dart-Code/Dart-Code/issues/5793
51 const completer = this.daemonInitializedCompleter;
52 const markInitializedAfterDelay = () => setTimeout(() => completer.resolve(), 2000);
53 void this.deviceEnable().then(markInitializedAfterDelay, markInitializedAfterDelay);
54 });
55
56 const daemonArgs = [];
57
58 const showWebServer = config.flutterShowWebServerDevice === "always" || !isRunningLocally;
59 if (showWebServer)
60 daemonArgs.push("--show-web-server-device");
61
62 if (isDartCodeTestRun)
63 daemonArgs.push("--show-test-device");
64
65 if (portFromLocalExtension) {
66 this.createNcProcess(portFromLocalExtension);
67 this.startPing();
68 } else if (workspaceContext.config.forceFlutterWorkspace && config.daemonPort) {
69 this.createNcProcess(config.daemonPort);
70 this.startPing(workspaceContext.config.restartMacDaemonMessage);
71 } else {
72 const execution = usingCustomScript(
73 path.join(workspaceContext.sdks.flutter, flutterPath),
74 ["daemon"].concat(daemonArgs),
75 workspaceContext.config?.flutterDaemonScript,
76 );
77
78 const flutterAdditionalArgs = config.for(vs.Uri.file(folder)).flutterAdditionalArgs;
79 this.didSpawnWithAdditionalArgs = !!flutterAdditionalArgs.length;
80 const args = getGlobalFlutterArgs().concat(flutterAdditionalArgs).concat(execution.args);
81 this.createProcess(folder, execution.executable, args, { toolEnv: getToolEnv() });
82 }
83
84 if (isChromeOS && config.flutterAdbConnectOnChromeOs) {
85 logger.info("Running ADB Connect on Chrome OS");
86 const adbConnectProc = safeToolSpawn(undefined, "adb", ["connect", "100.115.92.2:5555"]);
87 logProcess(logger, LogCategory.General, adbConnectProc);
88 }
89 }
90
91 public startPing(customMessage?: string) {
92 const prompt = customMessage ?? "The daemon connection was lost. Reload the extension to restart the daemon.";

Callers

nothing calls this directly

Calls 13

deviceEnableMethod · 0.95
createNcProcessMethod · 0.95
startPingMethod · 0.95
usingCustomScriptFunction · 0.90
getGlobalFlutterArgsFunction · 0.90
getToolEnvFunction · 0.90
safeToolSpawnFunction · 0.90
logProcessFunction · 0.90
executeCommandMethod · 0.65
infoMethod · 0.65
forMethod · 0.45

Tested by

no test coverage detected