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

Unified Diff: pkg/analysis_server/bin/dartdeps.dart

Issue 175183008: Analysis server connect fixes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comments 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 | « no previous file | pkg/analysis_server/lib/http_server.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/bin/dartdeps.dart
diff --git a/pkg/analysis_server/bin/dartdeps.dart b/pkg/analysis_server/bin/dartdeps.dart
index e67cd1e029dae09954ba4358a48fcfc49b198a8e..73e59074376372e6b68eb898314bb7e0c61177c7 100644
--- a/pkg/analysis_server/bin/dartdeps.dart
+++ b/pkg/analysis_server/bin/dartdeps.dart
@@ -33,6 +33,11 @@ class _DartDependencyAnalyzer {
static const String HELP_OPTION = "help";
/**
+ * The name of the option used to specify an already running server.
+ */
+ static const String SERVER_OPTION = "server";
+
+ /**
* Parse the command line arguments to determine the application to be
* analyzed, then launch and manage an analysis server to do the work.
* If there is a problem with the given arguments, then return a non zero
@@ -40,12 +45,25 @@ class _DartDependencyAnalyzer {
*/
void start(List<String> args) {
var parser = new ArgParser();
- parser.addFlag(HELP_OPTION, help:
- "print this help message without starting analysis", defaultsTo: false,
+ parser.addFlag(HELP_OPTION,
+ help: "print this help message without starting analysis",
+ defaultsTo: false,
negatable: false);
+ parser.addOption(
+ SERVER_OPTION,
+ help: "[serverUrl] use an analysis server thats already running");
// Parse arguments
- ArgResults results = parser.parse(args);
+ ArgResults results;
+ try {
+ results = parser.parse(args);
+ } on FormatException catch(e) {
+ print(e.message);
+ print('');
+ printUsage(parser);
+ exitCode = 1;
+ return;
+ }
if (results[HELP_OPTION]) {
printUsage(parser);
return;
@@ -71,14 +89,22 @@ class _DartDependencyAnalyzer {
return;
}
- // Assume that the analysis server entry point is in the same directory
- StringBuffer path = new StringBuffer();
- path.write(FileSystemEntity.parentOf(Platform.script.toFilePath()));
- path.write(Platform.pathSeparator);
- path.write("server.dart");
+ Future<AnalysisManager> future;
+ String serverUrl = results[SERVER_OPTION];
+ if (serverUrl != null) {
+ // Connect to an already running analysis server
+ future = AnalysisManager.connect(serverUrl);
- // Launch analysis server
- AnalysisManager.start(path.toString()).then(analyze);
+ } else {
+ // Launch and connect to a new analysis server
+ // Assume that the analysis server entry point is in the same directory
+ StringBuffer path = new StringBuffer();
+ path.write(FileSystemEntity.parentOf(Platform.script.toFilePath()));
+ path.write(Platform.pathSeparator);
+ path.write("server.dart");
+ future = AnalysisManager.start(path.toString());
+ }
+ future.then(analyze);
}
void analyze(AnalysisManager mgr) {
« no previous file with comments | « no previous file | pkg/analysis_server/lib/http_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698