Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: pkg/analysis_server/lib/src/analysis_manager.dart

Issue 1855643002: More strong mode changes to analysis_server (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Backout changes to options file Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/channel/channel.dart'; 10 import 'package:analysis_server/src/channel/channel.dart';
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return _listenForPort(process); 68 return _listenForPort(process);
69 } catch (error) { 69 } catch (error) {
70 exitCode = 1; 70 exitCode = 1;
71 throw 'Failed to launch analysis server: $error'; 71 throw 'Failed to launch analysis server: $error';
72 } 72 }
73 } 73 }
74 74
75 /** 75 /**
76 * Listen for a port from the given analysis server process. 76 * Listen for a port from the given analysis server process.
77 */ 77 */
78 Future<AnalysisManager> _listenForPort(Process process) { 78 Future<AnalysisManager> _listenForPort(Process process) async {
79 this.process = process; 79 this.process = process;
80 80
81 // Echo stdout and stderr 81 // Echo stdout and stderr
82 Stream out = process.stdout.transform(UTF8.decoder).asBroadcastStream(); 82 Stream out = process.stdout.transform(UTF8.decoder).asBroadcastStream();
83 out.listen((line) => print(line)); 83 out.listen((line) => print(line));
84 process.stderr.pipe(stderr); 84 process.stderr.pipe(stderr);
85 85
86 // Listen for port from server 86 // Listen for port from server
87 const String pattern = 'Listening on port '; 87 const String pattern = 'Listening on port ';
88 return out 88 try {
89 .firstWhere((String line) => line.startsWith(pattern)) 89 String line = await out
90 .timeout(new Duration(seconds: 10)) 90 .firstWhere((String line) => line.startsWith(pattern))
91 .catchError((error) { 91 .timeout(new Duration(seconds: 10));
92 String port = line.substring(pattern.length).trim();
93 String url = 'ws://${InternetAddress.LOOPBACK_IP_V4.address}:$port/';
94 return _openConnection(url);
95 } catch (error) {
92 exitCode = 1; 96 exitCode = 1;
93 process.kill(); 97 process.kill();
94 throw 'Expected port from analysis server'; 98 throw 'Expected port from analysis server';
95 }).then((String line) { 99 }
96 String port = line.substring(pattern.length).trim();
97 String url = 'ws://${InternetAddress.LOOPBACK_IP_V4.address}:$port/';
98 return _openConnection(url);
99 });
100 } 100 }
101 101
102 /** 102 /**
103 * Open a connection to the analysis server using the given URL. 103 * Open a connection to the analysis server using the given URL.
104 */ 104 */
105 Future<AnalysisManager> _openConnection(String serverUrl) { 105 Future<AnalysisManager> _openConnection(String serverUrl) {
106 Function onError = (error) { 106 Function onError = (error) {
107 exitCode = 1; 107 exitCode = 1;
108 if (process != null) { 108 if (process != null) {
109 process.kill(); 109 process.kill();
(...skipping 22 matching lines...) Expand all
132 } 132 }
133 133
134 /** 134 /**
135 * Launch analysis server in a separate process 135 * Launch analysis server in a separate process
136 * and return a future with a manager for that analysis server. 136 * and return a future with a manager for that analysis server.
137 */ 137 */
138 static Future<AnalysisManager> start(String serverPath) { 138 static Future<AnalysisManager> start(String serverPath) {
139 return new AnalysisManager()._launchServer(serverPath); 139 return new AnalysisManager()._launchServer(serverPath);
140 } 140 }
141 } 141 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/plugin/protocol/protocol.dart ('k') | pkg/analysis_server/lib/src/collections.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698