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

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

Issue 175173002: first cut cmdline analysis server launcher (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
Index: pkg/analysis_server/bin/dartdeps.dart
diff --git a/pkg/analysis_server/bin/dartdeps.dart b/pkg/analysis_server/bin/dartdeps.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3b7ae752c3d7d423f3fe77dad8cb9d09290eb84f
--- /dev/null
+++ b/pkg/analysis_server/bin/dartdeps.dart
@@ -0,0 +1,104 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:args/args.dart';
+import 'package:analysis_server/src/analysis_manager.dart';
+
+/**
+ * Start analysis server as a separate process and use the websocket protocol
+ * to analyze the application specified on the command line.
+ */
+void main(List<String> args) {
+ _DartDependencyAnalyzer analyzer = new _DartDependencyAnalyzer();
+ analyzer.start(args);
+}
+
+/**
+ * Instances of [_DartDependencyAnalyzer] launch an analysis server and use
+ * that server to analyze the dependencies of an application.
+ */
+class _DartDependencyAnalyzer {
Brian Wilkerson 2014/02/21 15:09:54 Style question: In analysis server I put the priva
danrubel 2014/02/21 15:51:13 I made it private and kept it in this library beca
+ /**
+ * The name of the application that is used to start the analyzer.
+ */
+ static const BINARY_NAME = 'dartdeps';
Brian Wilkerson 2014/02/21 15:09:54 I thought I remembered that the application was go
danrubel 2014/02/21 15:51:13 I like "dartdeps" because this is more the just sh
+
+ /**
+ * The name of the option used to print usage information.
+ */
+ static const String HELP_OPTION = "help";
+
+ /**
+ * 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
+ * value, otherwise return zero.
+ */
+ void start(List<String> args) {
+ var parser = new ArgParser();
+ parser.addFlag(HELP_OPTION, help:
+ "print this help message without starting analysis", defaultsTo: false,
+ negatable: false);
+
+ // Parse arguments
+ ArgResults results = parser.parse(args);
+ if (results[HELP_OPTION]) {
+ _printUsage(parser);
+ return;
+ }
+ if (results.rest.length == 0) {
+ _printUsage(parser);
+ exitCode = 1;
+ return;
+ }
+ Directory appDir = new Directory(results.rest[0]);
+ if (!appDir.existsSync()) {
+ print('Specified application directory does not exist: $appDir');
+ print('');
+ _printUsage(parser);
+ exitCode = 1;
+ return;
+ }
+ if (results.rest.length > 1) {
+ print('Unexpected arguments after $appDir');
+ print('');
+ _printUsage(parser);
+ exitCode = 1;
+ 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");
+
+ // Launch analysis server
+ AnalysisManager.start(path.toString()).then(_analyze);
+ }
+
+ void _analyze(AnalysisManager mgr) {
Brian Wilkerson 2014/02/21 15:09:54 Style question: Is there any value in marking an i
danrubel 2014/02/21 15:51:13 Good point! Removed _
+ print("Analyzing...");
+ new Timer(new Duration(seconds: 5), () {
+ if (mgr.stop()) {
+ print("stopped");
+ } else {
+ print("already stopped");
+ }
+ });
+ }
+
+ /**
+ * Print information about how to use the server.
+ */
+ void _printUsage(ArgParser parser) {
+ print('Usage: $BINARY_NAME [flags] <application_directory>');
+ print('');
+ print('Supported flags are:');
+ print(parser.getUsage());
+ }
+}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/analysis_manager.dart » ('j') | pkg/analysis_server/lib/src/analysis_manager.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698