Skip to content

Commit 7036e1c

Browse files
authored
Remove code for managing daemon startup of DevTools (#8290)
This was for versions of Dart SDK < v2.15 which is very outdated
1 parent 95d3c8a commit 7036e1c

File tree

3 files changed

+0
-127
lines changed

3 files changed

+0
-127
lines changed

flutter-idea/src/io/flutter/run/daemon/DaemonApi.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ CompletableFuture<Boolean> stopApp(@NotNull String appId) {
8181
return send("app.stop", new AppStop(appId));
8282
}
8383

84-
CompletableFuture<DevToolsAddress> devToolsServe() {
85-
return send("devtools.serve", new DevToolsServe());
86-
}
87-
8884
CompletableFuture<Boolean> detachApp(@NotNull String appId) {
8985
return send("app.detach", new AppDetach(appId));
9086
}
@@ -491,32 +487,4 @@ List<String> parseResult(JsonElement result) {
491487
return platforms;
492488
}
493489
}
494-
495-
public static class DevToolsAddress {
496-
public String host;
497-
public int port;
498-
499-
public DevToolsAddress(String host, int port) {
500-
this.host = host;
501-
this.port = port;
502-
}
503-
}
504-
505-
506-
private static class DevToolsServe extends Params<DevToolsAddress> {
507-
@Override
508-
DevToolsAddress parseResult(JsonElement result) {
509-
if (!(result instanceof JsonObject)) {
510-
return null;
511-
}
512-
513-
final String host = ((JsonObject)result).get("host").getAsString();
514-
final int port = ((JsonObject)result).get("port").getAsInt();
515-
if (host.isEmpty() || port == 0) {
516-
return null;
517-
}
518-
519-
return new DevToolsAddress(host, port);
520-
}
521-
}
522490
}

flutter-idea/src/io/flutter/run/daemon/DevToolsServerTask.java

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,6 @@ public void run(@NotNull ProgressIndicator progressIndicator) {
8080
progressIndicator.setFraction(30);
8181
progressIndicator.setText2("Init");
8282

83-
// If the `dart devtools` command is not supported, start the daemon instead.
84-
final boolean dartDevToolsSupported = dartSdkSupportsDartDevTools();
85-
if (!dartDevToolsSupported) {
86-
LOG.info("Starting the DevTools daemon.");
87-
progressIndicator.setFraction(60);
88-
progressIndicator.setText2("Daemon set-up");
89-
setUpWithDaemon();
90-
return;
91-
}
92-
9383
// If we are in a Bazel workspace, start the server.
9484
// Note: This is only for internal usages.
9585
final WorkspaceCache workspaceCache = WorkspaceCache.getInstance(project);
@@ -128,16 +118,6 @@ public void run(@NotNull ProgressIndicator progressIndicator) {
128118
}
129119
}
130120

131-
private Boolean dartSdkSupportsDartDevTools() {
132-
final DartSdk dartSdk = DartSdk.getDartSdk(project);
133-
if (dartSdk != null) {
134-
final Version version = Version.parseVersion(dartSdk.getVersion());
135-
assert version != null;
136-
return version.compareTo(2, 15, 0) >= 0;
137-
}
138-
return false;
139-
}
140-
141121
@Override
142122
public void onThrowable(@NotNull Throwable error) {
143123
cancelWithError(new Exception(error));
@@ -204,51 +184,6 @@ public void projectClosing(@NotNull Project project) {
204184
}
205185
}
206186

207-
private void setUpWithDaemon() {
208-
try {
209-
final GeneralCommandLine command = chooseCommand(project);
210-
if (command == null) {
211-
cancelWithError("Unable to find daemon command for project");
212-
return;
213-
}
214-
this.process = new MostlySilentColoredProcessHandler(command);
215-
daemonApi = new DaemonApi(process);
216-
daemonApi.listen(process, new DevToolsService.DevToolsServiceListener());
217-
daemonApi.devToolsServe().thenAccept((DaemonApi.DevToolsAddress address) -> {
218-
if (!project.isOpen()) {
219-
// We should skip starting DevTools (and doing any UI work) if the project has been closed.
220-
return;
221-
}
222-
if (address == null) {
223-
cancelWithError("DevTools address was null");
224-
}
225-
else {
226-
devToolsFutureRef.get().complete(new DevToolsInstance(address.host, address.port));
227-
}
228-
});
229-
}
230-
catch (ExecutionException e) {
231-
cancelWithError(e);
232-
}
233-
234-
ProjectManager.getInstance().addProjectManagerListener(project, new ProjectManagerListener() {
235-
@Override
236-
public void projectClosing(@NotNull Project project) {
237-
devToolsFutureRef.set(null);
238-
239-
try {
240-
daemonApi.daemonShutdown().get(5, TimeUnit.SECONDS);
241-
}
242-
catch (InterruptedException | java.util.concurrent.ExecutionException | TimeoutException e) {
243-
LOG.error("DevTools daemon did not shut down normally: " + e);
244-
if (!process.isProcessTerminated()) {
245-
process.destroyProcess();
246-
}
247-
}
248-
}
249-
});
250-
}
251-
252187
private CompletableFuture<DevToolsInstance> checkForDartPluginInitiatedDevToolsWithRetries(@NotNull ProgressIndicator progressIndicator)
253188
throws InterruptedException {
254189
progressIndicator.setText2("Waiting for server with DTD");
@@ -319,32 +254,6 @@ private void tryParseStartupText(@NotNull String text) {
319254
}
320255
}
321256

322-
private static GeneralCommandLine chooseCommand(@NotNull final Project project) {
323-
// Use daemon script if this is a bazel project.
324-
final Workspace workspace = WorkspaceCache.getInstance(project).get();
325-
if (workspace != null) {
326-
final String script = workspace.getDaemonScript();
327-
if (script != null) {
328-
return createCommand(workspace.getRoot().getPath(), script, ImmutableList.of());
329-
}
330-
}
331-
332-
// Otherwise, use the Flutter SDK.
333-
final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
334-
if (sdk == null) {
335-
return null;
336-
}
337-
338-
try {
339-
final String path = FlutterSdkUtil.pathToFlutterTool(sdk.getHomePath());
340-
return createCommand(sdk.getHomePath(), path, ImmutableList.of("daemon"));
341-
}
342-
catch (ExecutionException e) {
343-
FlutterUtils.warn(LOG, "Unable to calculate command to start Flutter daemon", e);
344-
return null;
345-
}
346-
}
347-
348257
private static @NotNull GeneralCommandLine createCommand(String workDir, String command, List<String> arguments) {
349258
final GeneralCommandLine result = new GeneralCommandLine().withWorkDirectory(workDir);
350259
result.setCharset(StandardCharsets.UTF_8);

flutter-idea/src/io/flutter/run/daemon/FlutterApp.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,6 @@ public CompletableFuture<DaemonApi.RestartResult> performHotReload(boolean pause
405405
return future;
406406
}
407407

408-
public CompletableFuture<DaemonApi.DevToolsAddress> serveDevTools() {
409-
return myDaemonApi.devToolsServe();
410-
}
411-
412408
public CompletableFuture<JsonObject> callServiceExtension(String methodName) {
413409
return callServiceExtension(methodName, new HashMap<>());
414410
}

0 commit comments

Comments
 (0)