Chromium Code Reviews| 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 import 'dart:math'; | 9 import 'dart:math'; |
| 10 | 10 |
| 11 import 'package:analysis_server/plugin/plugin.dart'; | 11 import 'package:analysis_server/plugin/plugin.dart'; |
| 12 import 'package:analysis_server/src/analysis_server.dart'; | 12 import 'package:analysis_server/src/analysis_server.dart'; |
| 13 import 'package:analysis_server/src/plugin/plugin_impl.dart'; | 13 import 'package:analysis_server/src/plugin/plugin_impl.dart'; |
| 14 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 14 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 15 import 'package:analysis_server/src/server/http_server.dart'; | 15 import 'package:analysis_server/src/server/http_server.dart'; |
| 16 import 'package:analysis_server/src/server/stdio_server.dart'; | 16 import 'package:analysis_server/src/server/stdio_server.dart'; |
| 17 import 'package:analysis_server/src/socket_server.dart'; | 17 import 'package:analysis_server/src/socket_server.dart'; |
| 18 import 'package:analysis_server/starter.dart'; | 18 import 'package:analysis_server/starter.dart'; |
| 19 import 'package:analyzer/file_system/physical_file_system.dart'; | 19 import 'package:analyzer/file_system/physical_file_system.dart'; |
| 20 import 'package:analyzer/instrumentation/instrumentation.dart'; | 20 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 21 import 'package:analyzer/src/generated/engine.dart'; | 21 import 'package:analyzer/src/generated/engine.dart'; |
| 22 import 'package:analyzer/src/generated/incremental_logger.dart'; | 22 import 'package:analyzer/src/generated/incremental_logger.dart'; |
| 23 import 'package:analyzer/src/generated/java_io.dart'; | 23 import 'package:analyzer/src/generated/java_io.dart'; |
| 24 import 'package:analyzer/src/generated/sdk.dart'; | 24 import 'package:analyzer/src/generated/sdk.dart'; |
| 25 import 'package:analyzer/src/generated/sdk_io.dart'; | 25 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 26 import 'package:analyzer/options.dart'; | |
| 26 import 'package:args/args.dart'; | 27 import 'package:args/args.dart'; |
| 27 | 28 |
| 28 /** | 29 /** |
| 29 * Initializes incremental logger. | 30 * Initializes incremental logger. |
| 30 * | 31 * |
| 31 * Supports following formats of [spec]: | 32 * Supports following formats of [spec]: |
| 32 * | 33 * |
| 33 * "console" - log to the console; | 34 * "console" - log to the console; |
| 34 * "file:/some/file/name" - log to the file, overwritten on start. | 35 * "file:/some/file/name" - log to the file, overwritten on start. |
| 35 */ | 36 */ |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 * Set the [plugins] that are defined outside the analysis_server package. | 164 * Set the [plugins] that are defined outside the analysis_server package. |
| 164 */ | 165 */ |
| 165 void set userDefinedPlugins(List<Plugin> plugins) { | 166 void set userDefinedPlugins(List<Plugin> plugins) { |
| 166 _userDefinedPlugins = plugins == null ? <Plugin>[] : plugins; | 167 _userDefinedPlugins = plugins == null ? <Plugin>[] : plugins; |
| 167 } | 168 } |
| 168 | 169 |
| 169 /** | 170 /** |
| 170 * Use the given command-line [arguments] to start this server. | 171 * Use the given command-line [arguments] to start this server. |
| 171 */ | 172 */ |
| 172 void start(List<String> arguments) { | 173 void start(List<String> arguments) { |
| 173 ArgParser parser = _createArgParser(); | 174 CommandLineParser parser = _createArgParser(); |
| 174 ArgResults results = parser.parse(arguments); | 175 ArgResults results = parser.parse(arguments, <String, String>{}); |
| 175 if (results[HELP_OPTION]) { | 176 if (results[HELP_OPTION]) { |
| 176 _printUsage(parser); | 177 _printUsage(parser.parser); |
| 177 return; | 178 return; |
| 178 } | 179 } |
| 179 | 180 |
| 180 // TODO(brianwilkerson) Enable this after it is possible for an | 181 // TODO(brianwilkerson) Enable this after it is possible for an |
| 181 // instrumentation server to be provided. | 182 // instrumentation server to be provided. |
| 182 // if (results[ENABLE_INSTRUMENTATION_OPTION]) { | 183 // if (results[ENABLE_INSTRUMENTATION_OPTION]) { |
| 183 // if (instrumentationServer == null) { | 184 // if (instrumentationServer == null) { |
| 184 // print('Exiting server: enabled instrumentation without providing an in strumentation server'); | 185 // print('Exiting server: enabled instrumentation without providing an in strumentation server'); |
| 185 // print(''); | 186 // print(''); |
| 186 // _printUsage(parser); | 187 // _printUsage(parser); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 204 | 205 |
| 205 int port; | 206 int port; |
| 206 bool serve_http = false; | 207 bool serve_http = false; |
| 207 if (results[PORT_OPTION] != null) { | 208 if (results[PORT_OPTION] != null) { |
| 208 serve_http = true; | 209 serve_http = true; |
| 209 try { | 210 try { |
| 210 port = int.parse(results[PORT_OPTION]); | 211 port = int.parse(results[PORT_OPTION]); |
| 211 } on FormatException { | 212 } on FormatException { |
| 212 print('Invalid port number: ${results[PORT_OPTION]}'); | 213 print('Invalid port number: ${results[PORT_OPTION]}'); |
| 213 print(''); | 214 print(''); |
| 214 _printUsage(parser); | 215 _printUsage(parser.parser); |
| 215 exitCode = 1; | 216 exitCode = 1; |
| 216 return; | 217 return; |
| 217 } | 218 } |
| 218 } | 219 } |
| 219 | 220 |
| 220 AnalysisServerOptions analysisServerOptions = new AnalysisServerOptions(); | 221 AnalysisServerOptions analysisServerOptions = new AnalysisServerOptions(); |
| 221 analysisServerOptions.enableIncrementalResolutionApi = | 222 analysisServerOptions.enableIncrementalResolutionApi = |
| 222 results[ENABLE_INCREMENTAL_RESOLUTION_API]; | 223 results[ENABLE_INCREMENTAL_RESOLUTION_API]; |
| 223 analysisServerOptions.enableIncrementalResolutionValidation = | 224 analysisServerOptions.enableIncrementalResolutionValidation = |
| 224 results[INCREMENTAL_RESOLUTION_VALIDATION]; | 225 results[INCREMENTAL_RESOLUTION_VALIDATION]; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 }; | 303 }; |
| 303 ZoneSpecification zoneSpecification = new ZoneSpecification( | 304 ZoneSpecification zoneSpecification = new ZoneSpecification( |
| 304 handleUncaughtError: errorFunction, | 305 handleUncaughtError: errorFunction, |
| 305 print: printFunction); | 306 print: printFunction); |
| 306 return runZoned(callback, zoneSpecification: zoneSpecification); | 307 return runZoned(callback, zoneSpecification: zoneSpecification); |
| 307 } | 308 } |
| 308 | 309 |
| 309 /** | 310 /** |
| 310 * Create and return the parser used to parse the command-line arguments. | 311 * Create and return the parser used to parse the command-line arguments. |
| 311 */ | 312 */ |
| 312 ArgParser _createArgParser() { | 313 CommandLineParser _createArgParser() { |
| 313 ArgParser parser = new ArgParser(); | 314 CommandLineParser parser = new CommandLineParser(); |
| 314 parser.addOption( | 315 parser.addOption( |
| 315 CLIENT_ID, | 316 CLIENT_ID, |
| 316 help: "an identifier used to identify the client"); | 317 help: "an identifier used to identify the client"); |
| 317 parser.addOption(CLIENT_VERSION, help: "the version of the client"); | 318 parser.addOption(CLIENT_VERSION, help: "the version of the client"); |
| 318 parser.addFlag( | 319 parser.addFlag( |
| 320 'ignore-unrecognized-flags', | |
|
Brian Wilkerson
2015/02/19 20:44:09
I thought we were making this the default behavior
Paul Berry
2015/02/19 21:10:16
My recollection matches Brian's. IIRC, we argued
| |
| 321 help: 'Ignore unrecognized command line flags', | |
| 322 defaultsTo: false, | |
| 323 negatable: false); | |
| 324 parser.addFlag( | |
| 319 ENABLE_INCREMENTAL_RESOLUTION_API, | 325 ENABLE_INCREMENTAL_RESOLUTION_API, |
| 320 help: "enable using incremental resolution for API changes", | 326 help: "enable using incremental resolution for API changes", |
| 321 defaultsTo: false, | 327 defaultsTo: false, |
| 322 negatable: false); | 328 negatable: false); |
| 323 parser.addFlag( | 329 parser.addFlag( |
| 324 ENABLE_INSTRUMENTATION_OPTION, | 330 ENABLE_INSTRUMENTATION_OPTION, |
| 325 help: "enable sending instrumentation information to a server", | 331 help: "enable sending instrumentation information to a server", |
| 326 defaultsTo: false, | 332 defaultsTo: false, |
| 327 negatable: false); | 333 negatable: false); |
| 328 parser.addFlag( | 334 parser.addFlag( |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 407 uuidFile.parent.createSync(recursive: true); | 413 uuidFile.parent.createSync(recursive: true); |
| 408 uuidFile.writeAsStringSync(uuid); | 414 uuidFile.writeAsStringSync(uuid); |
| 409 } catch (exception, stackTrace) { | 415 } catch (exception, stackTrace) { |
| 410 service.logPriorityException(exception, stackTrace); | 416 service.logPriorityException(exception, stackTrace); |
| 411 // Slightly alter the uuid to indicate it was not persisted | 417 // Slightly alter the uuid to indicate it was not persisted |
| 412 uuid = 'temp-$uuid'; | 418 uuid = 'temp-$uuid'; |
| 413 } | 419 } |
| 414 return uuid; | 420 return uuid; |
| 415 } | 421 } |
| 416 } | 422 } |
| OLD | NEW |