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

Unified Diff: pkg/analysis_server/lib/src/analysis_manager.dart

Issue 175183008: Analysis server connect fixes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: add comment Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/http_server.dart ('k') | pkg/analysis_server/lib/src/analysis_server.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_manager.dart
diff --git a/pkg/analysis_server/lib/src/analysis_manager.dart b/pkg/analysis_server/lib/src/analysis_manager.dart
index 44bd0a1e7211e8240aacb5122653d956bc696a5e..7dd69301d86f0b296d430b42d2c966bab12ba22f 100644
--- a/pkg/analysis_server/lib/src/analysis_manager.dart
+++ b/pkg/analysis_server/lib/src/analysis_manager.dart
@@ -15,7 +15,8 @@ class AnalysisManager {
static const int PORT = 3333;
/**
- * The analysis server process being managed.
+ * The analysis server process being managed
+ * or [:null:] if managing an analysis server that was already running.
Brian Wilkerson 2014/02/22 16:57:06 nit: We have been using backquotes (`) in the rest
danrubel 2014/02/24 17:39:24 Done.
*/
final Process process;
@@ -31,13 +32,22 @@ class AnalysisManager {
static Future<AnalysisManager> start(String pathToServer) {
// TODO dynamically allocate port and/or allow client to specify port
return Process.start(Platform.executable, [pathToServer, "--port",
- PORT.toString()]).then(_connect);
+ PORT.toString()]).then(_attach);
Brian Wilkerson 2014/02/22 16:57:06 We should have a 'catchError' to report when the s
danrubel 2014/02/24 17:39:24 Done.
}
/**
- * Open a connection to the analysis server.
+ * Open a connection to a running analysis server
*/
- static Future<AnalysisManager> _connect(Process process) {
+ static Future<AnalysisManager> connect(String url) {
+ return WebSocket.connect(url)
+ .then((WebSocket socket) => new AnalysisManager(null, socket));
+ }
+
+ /**
+ * Attach this process to the newly launched analysis server process,
+ * and open a connection to the analysis server.
+ */
+ static Future<AnalysisManager> _attach(Process process) {
Brian Wilkerson 2014/02/22 16:57:06 I think we also want to use the 'exitCode' getter
danrubel 2014/02/24 17:39:24 Done.
var url = 'ws://${InternetAddress.LOOPBACK_IP_V4.address}:$PORT/';
process.stderr.pipe(stderr);
Stream out = process.stdout.transform(UTF8.decoder).asBroadcastStream();
@@ -68,8 +78,8 @@ class AnalysisManager {
* Stop the analysis server.
*
* Returns [:true:] if the signal is successfully sent and process is killed.
Brian Wilkerson 2014/02/22 16:57:06 nit: As above
danrubel 2014/02/24 17:39:24 Done.
- * Otherwise the signal could not be sent, usually meaning that the process
- * is already dead.
+ * Otherwise there was no attached process or the signal could not be sent,
+ * usually meaning that the process is already dead.
*/
- bool stop() => process.kill();
+ bool stop() => process != null ? process.kill() : false;
Brian Wilkerson 2014/02/22 16:57:06 I still think you should ask the server nicely to
danrubel 2014/02/24 17:39:24 Agreed. Not quite ready to wire that up. Added a c
}
« no previous file with comments | « pkg/analysis_server/lib/http_server.dart ('k') | pkg/analysis_server/lib/src/analysis_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698