@@ -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 );
0 commit comments