| OLD | NEW |
| 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 library driver; | 5 library driver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:analysis_server/http_server.dart'; | 10 import 'package:analysis_server/http_server.dart'; |
| 11 import 'package:analysis_server/src/socket_server.dart'; | 11 import 'package:analysis_server/src/socket_server.dart'; |
| 12 import 'package:analysis_server/stdio_server.dart'; | 12 import 'package:analysis_server/stdio_server.dart'; |
| 13 import 'package:analyzer/src/generated/java_io.dart'; | 13 import 'package:analyzer/src/generated/java_io.dart'; |
| 14 import 'package:analyzer/src/generated/sdk.dart'; | 14 import 'package:analyzer/src/generated/sdk.dart'; |
| 15 import 'package:analyzer/src/generated/sdk_io.dart'; | 15 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 16 import 'package:args/args.dart'; | 16 import 'package:args/args.dart'; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * The [Driver] class represents a single running instance of the analysis | 19 * The [Driver] class represents a single running instance of the analysis |
| 20 * server application. It is responsible for parsing command line options | 20 * server application. It is responsible for parsing command line options |
| 21 * and starting the HTTP and/or stdio servers. | 21 * and starting the HTTP and/or stdio servers. |
| 22 */ | 22 */ |
| 23 class Driver { | 23 class Driver { |
| 24 /** | 24 /** |
| 25 * The name of the application that is used to start a server. | 25 * The name of the application that is used to start a server. |
| 26 */ | 26 */ |
| 27 static const BINARY_NAME = 'server'; | 27 static const BINARY_NAME = "server"; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * The name of the option used to enable instrumentation. | 30 * The name of the option used to enable instrumentation. |
| 31 */ | 31 */ |
| 32 static const String ENABLE_INSTRUMENTATION_OPTION = "enable-instrumentation"; | 32 static const String ENABLE_INSTRUMENTATION_OPTION = "enable-instrumentation"; |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * The name of the option used to print usage information. | 35 * The name of the option used to print usage information. |
| 36 */ | 36 */ |
| 37 static const String HELP_OPTION = "help"; | 37 static const String HELP_OPTION = "help"; |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * The name of the option used to specify the log file to which | 40 * The name of the option used to specify the log file to which |
| 41 * instrumentation data is to be written. | 41 * instrumentation data is to be written. |
| 42 */ | 42 */ |
| 43 static const String INSTRUMENTATION_LOG_FILE_OPTION = | 43 static const String INSTRUMENTATION_LOG_FILE_OPTION = |
| 44 "instrumentation-log-file"; | 44 "instrumentation-log-file"; |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * The name of the option used to specify the port to which the server will | 47 * The name of the option used to specify the port to which the server will |
| 48 * connect. | 48 * connect. |
| 49 */ | 49 */ |
| 50 static const String PORT_OPTION = "port"; | 50 static const String PORT_OPTION = "port"; |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * The path to the SDK. | 53 * The path to the SDK. |
| 54 * TODO(paulberry): get rid of this once the 'analysis.updateSdks' request is | 54 * TODO(paulberry): get rid of this once the 'analysis.updateSdks' request is |
| 55 * operational. | 55 * operational. |
| 56 */ | 56 */ |
| 57 static const String SDK_OPTION = 'sdk'; | 57 static const String SDK_OPTION = "sdk"; |
| 58 |
| 59 /** |
| 60 * The name of the option used to disable error notifications. |
| 61 */ |
| 62 static const String NO_ERROR_NOTIFICATION = "no-error-notification"; |
| 58 | 63 |
| 59 SocketServer socketServer; | 64 SocketServer socketServer; |
| 60 | 65 |
| 61 HttpAnalysisServer httpServer; | 66 HttpAnalysisServer httpServer; |
| 62 | 67 |
| 63 StdioAnalysisServer stdioServer; | 68 StdioAnalysisServer stdioServer; |
| 64 | 69 |
| 65 Driver(); | 70 Driver(); |
| 66 /** | 71 /** |
| 67 * Use the given command-line arguments to start this server. | 72 * Use the given command-line arguments to start this server. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 78 help: "print this help message without starting a server", | 83 help: "print this help message without starting a server", |
| 79 defaultsTo: false, | 84 defaultsTo: false, |
| 80 negatable: false); | 85 negatable: false); |
| 81 parser.addOption( | 86 parser.addOption( |
| 82 INSTRUMENTATION_LOG_FILE_OPTION, | 87 INSTRUMENTATION_LOG_FILE_OPTION, |
| 83 help: "[path] the file to which instrumentation data will be logged"); | 88 help: "[path] the file to which instrumentation data will be logged"); |
| 84 parser.addOption( | 89 parser.addOption( |
| 85 PORT_OPTION, | 90 PORT_OPTION, |
| 86 help: "[port] the port on which the server will listen"); | 91 help: "[port] the port on which the server will listen"); |
| 87 parser.addOption(SDK_OPTION, help: "[path] the path to the sdk"); | 92 parser.addOption(SDK_OPTION, help: "[path] the path to the sdk"); |
| 93 parser.addFlag( |
| 94 NO_ERROR_NOTIFICATION, |
| 95 help: "disable sending all analysis error notifications to the server (n
ot yet implemented)", |
| 96 defaultsTo: false, |
| 97 negatable: false); |
| 88 | 98 |
| 89 ArgResults results = parser.parse(args); | 99 ArgResults results = parser.parse(args); |
| 90 if (results[HELP_OPTION]) { | 100 if (results[HELP_OPTION]) { |
| 91 _printUsage(parser); | 101 _printUsage(parser); |
| 92 return; | 102 return; |
| 93 } | 103 } |
| 94 if (results[ENABLE_INSTRUMENTATION_OPTION]) { | 104 if (results[ENABLE_INSTRUMENTATION_OPTION]) { |
| 95 if (results[INSTRUMENTATION_LOG_FILE_OPTION] != null) { | 105 if (results[INSTRUMENTATION_LOG_FILE_OPTION] != null) { |
| 96 // TODO(brianwilkerson) Initialize the instrumentation system with | 106 // TODO(brianwilkerson) Initialize the instrumentation system with |
| 97 // logging. | 107 // logging. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 /** | 167 /** |
| 158 * Print information about how to use the server. | 168 * Print information about how to use the server. |
| 159 */ | 169 */ |
| 160 void _printUsage(ArgParser parser) { | 170 void _printUsage(ArgParser parser) { |
| 161 print('Usage: $BINARY_NAME [flags]'); | 171 print('Usage: $BINARY_NAME [flags]'); |
| 162 print(''); | 172 print(''); |
| 163 print('Supported flags are:'); | 173 print('Supported flags are:'); |
| 164 print(parser.usage); | 174 print(parser.usage); |
| 165 } | 175 } |
| 166 } | 176 } |
| OLD | NEW |