| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 10 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 static const String INCREMENTAL_RESOLUTION_LOG = "incremental-resolution-log"; | 234 static const String INCREMENTAL_RESOLUTION_LOG = "incremental-resolution-log"; |
| 235 | 235 |
| 236 /** | 236 /** |
| 237 * The name of the option used to enable validation of incremental resolution | 237 * The name of the option used to enable validation of incremental resolution |
| 238 * results. | 238 * results. |
| 239 */ | 239 */ |
| 240 static const String INCREMENTAL_RESOLUTION_VALIDATION = | 240 static const String INCREMENTAL_RESOLUTION_VALIDATION = |
| 241 "incremental-resolution-validation"; | 241 "incremental-resolution-validation"; |
| 242 | 242 |
| 243 /** | 243 /** |
| 244 * The name of the option used to disable using the new analysis driver. | |
| 245 */ | |
| 246 static const String DISABLE_NEW_ANALYSIS_DRIVER = | |
| 247 'disable-new-analysis-driver'; | |
| 248 | |
| 249 /** | |
| 250 * The name of the option used to cause instrumentation to also be written to | 244 * The name of the option used to cause instrumentation to also be written to |
| 251 * a local file. | 245 * a local file. |
| 252 */ | 246 */ |
| 253 static const String INSTRUMENTATION_LOG_FILE = "instrumentation-log-file"; | 247 static const String INSTRUMENTATION_LOG_FILE = "instrumentation-log-file"; |
| 254 | 248 |
| 255 /** | 249 /** |
| 256 * The name of the option used to specify if [print] should print to the | 250 * The name of the option used to specify if [print] should print to the |
| 257 * console instead of being intercepted. | 251 * console instead of being intercepted. |
| 258 */ | 252 */ |
| 259 static const String INTERNAL_DELAY_FREQUENCY = 'internal-delay-frequency'; | 253 static const String INTERNAL_DELAY_FREQUENCY = 'internal-delay-frequency'; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 exitCode = 1; | 369 exitCode = 1; |
| 376 return null; | 370 return null; |
| 377 } | 371 } |
| 378 } | 372 } |
| 379 | 373 |
| 380 AnalysisServerOptions analysisServerOptions = new AnalysisServerOptions(); | 374 AnalysisServerOptions analysisServerOptions = new AnalysisServerOptions(); |
| 381 analysisServerOptions.enableIncrementalResolutionApi = | 375 analysisServerOptions.enableIncrementalResolutionApi = |
| 382 results[ENABLE_INCREMENTAL_RESOLUTION_API]; | 376 results[ENABLE_INCREMENTAL_RESOLUTION_API]; |
| 383 analysisServerOptions.enableIncrementalResolutionValidation = | 377 analysisServerOptions.enableIncrementalResolutionValidation = |
| 384 results[INCREMENTAL_RESOLUTION_VALIDATION]; | 378 results[INCREMENTAL_RESOLUTION_VALIDATION]; |
| 385 analysisServerOptions.enableNewAnalysisDriver = | |
| 386 !results[DISABLE_NEW_ANALYSIS_DRIVER]; | |
| 387 analysisServerOptions.useAnalysisHighlight2 = | 379 analysisServerOptions.useAnalysisHighlight2 = |
| 388 results[USE_ANALYSIS_HIGHLIGHT2]; | 380 results[USE_ANALYSIS_HIGHLIGHT2]; |
| 389 analysisServerOptions.fileReadMode = results[FILE_READ_MODE]; | 381 analysisServerOptions.fileReadMode = results[FILE_READ_MODE]; |
| 390 analysisServerOptions.newAnalysisDriverLog = | 382 analysisServerOptions.newAnalysisDriverLog = |
| 391 results[NEW_ANALYSIS_DRIVER_LOG]; | 383 results[NEW_ANALYSIS_DRIVER_LOG]; |
| 392 | 384 |
| 393 analysisServerOptions.clientId = results[CLIENT_ID]; | 385 analysisServerOptions.clientId = results[CLIENT_ID]; |
| 394 analysisServerOptions.clientVersion = results[CLIENT_VERSION]; | 386 analysisServerOptions.clientVersion = results[CLIENT_VERSION]; |
| 395 | 387 |
| 396 analysisServerOptions.enableVerboseFlutterCompletions = | 388 analysisServerOptions.enableVerboseFlutterCompletions = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 414 String defaultSdkPath; | 406 String defaultSdkPath; |
| 415 if (results[SDK_OPTION] != null) { | 407 if (results[SDK_OPTION] != null) { |
| 416 defaultSdkPath = results[SDK_OPTION]; | 408 defaultSdkPath = results[SDK_OPTION]; |
| 417 } else { | 409 } else { |
| 418 // No path to the SDK was provided. | 410 // No path to the SDK was provided. |
| 419 // Use DirectoryBasedDartSdk.defaultSdkDirectory, which will make a guess. | 411 // Use DirectoryBasedDartSdk.defaultSdkDirectory, which will make a guess. |
| 420 defaultSdkPath = FolderBasedDartSdk | 412 defaultSdkPath = FolderBasedDartSdk |
| 421 .defaultSdkDirectory(PhysicalResourceProvider.INSTANCE) | 413 .defaultSdkDirectory(PhysicalResourceProvider.INSTANCE) |
| 422 .path; | 414 .path; |
| 423 } | 415 } |
| 424 bool useSummaries = analysisServerOptions.fileReadMode == 'as-is' || | |
| 425 analysisServerOptions.enableNewAnalysisDriver; | |
| 426 // TODO(brianwilkerson) It would be nice to avoid creating an SDK that | 416 // TODO(brianwilkerson) It would be nice to avoid creating an SDK that |
| 427 // cannot be re-used, but the SDK is needed to create a package map provider | 417 // cannot be re-used, but the SDK is needed to create a package map provider |
| 428 // in the case where we need to run `pub` in order to get the package map. | 418 // in the case where we need to run `pub` in order to get the package map. |
| 429 DartSdk defaultSdk = _createDefaultSdk(defaultSdkPath, useSummaries); | 419 DartSdk defaultSdk = _createDefaultSdk(defaultSdkPath, true); |
| 430 // | 420 // |
| 431 // Initialize the instrumentation service. | 421 // Initialize the instrumentation service. |
| 432 // | 422 // |
| 433 String logFilePath = results[INSTRUMENTATION_LOG_FILE]; | 423 String logFilePath = results[INSTRUMENTATION_LOG_FILE]; |
| 434 if (logFilePath != null) { | 424 if (logFilePath != null) { |
| 435 _rollLogFiles(logFilePath, 5); | 425 _rollLogFiles(logFilePath, 5); |
| 436 FileInstrumentationServer fileBasedServer = | 426 FileInstrumentationServer fileBasedServer = |
| 437 new FileInstrumentationServer(logFilePath); | 427 new FileInstrumentationServer(logFilePath); |
| 438 instrumentationServer = instrumentationServer != null | 428 instrumentationServer = instrumentationServer != null |
| 439 ? new MulticastInstrumentationServer( | 429 ? new MulticastInstrumentationServer( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 450 defaultSdk.sdkVersion); | 440 defaultSdk.sdkVersion); |
| 451 AnalysisEngine.instance.instrumentationService = instrumentationService; | 441 AnalysisEngine.instance.instrumentationService = instrumentationService; |
| 452 | 442 |
| 453 _DiagnosticServerImpl diagnosticServer = new _DiagnosticServerImpl(); | 443 _DiagnosticServerImpl diagnosticServer = new _DiagnosticServerImpl(); |
| 454 | 444 |
| 455 // | 445 // |
| 456 // Create the sockets and start listening for requests. | 446 // Create the sockets and start listening for requests. |
| 457 // | 447 // |
| 458 socketServer = new SocketServer( | 448 socketServer = new SocketServer( |
| 459 analysisServerOptions, | 449 analysisServerOptions, |
| 460 new DartSdkManager(defaultSdkPath, useSummaries), | 450 new DartSdkManager(defaultSdkPath, true), |
| 461 defaultSdk, | 451 defaultSdk, |
| 462 instrumentationService, | 452 instrumentationService, |
| 463 diagnosticServer, | 453 diagnosticServer, |
| 464 serverPlugin, | 454 serverPlugin, |
| 465 fileResolverProvider, | 455 fileResolverProvider, |
| 466 packageResolverProvider, | 456 packageResolverProvider, |
| 467 useSingleContextManager); | 457 useSingleContextManager); |
| 468 httpServer = new HttpAnalysisServer(socketServer); | 458 httpServer = new HttpAnalysisServer(socketServer); |
| 469 stdioServer = new StdioAnalysisServer(socketServer); | 459 stdioServer = new StdioAnalysisServer(socketServer); |
| 470 socketServer.userDefinedPlugins = _userDefinedPlugins; | 460 socketServer.userDefinedPlugins = _userDefinedPlugins; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 help: "print this help message without starting a server", | 528 help: "print this help message without starting a server", |
| 539 abbr: 'h', | 529 abbr: 'h', |
| 540 defaultsTo: false, | 530 defaultsTo: false, |
| 541 negatable: false); | 531 negatable: false); |
| 542 parser.addOption(INCREMENTAL_RESOLUTION_LOG, | 532 parser.addOption(INCREMENTAL_RESOLUTION_LOG, |
| 543 help: "set a destination for the incremental resolver's log"); | 533 help: "set a destination for the incremental resolver's log"); |
| 544 parser.addFlag(INCREMENTAL_RESOLUTION_VALIDATION, | 534 parser.addFlag(INCREMENTAL_RESOLUTION_VALIDATION, |
| 545 help: "enable validation of incremental resolution results (slow)", | 535 help: "enable validation of incremental resolution results (slow)", |
| 546 defaultsTo: false, | 536 defaultsTo: false, |
| 547 negatable: false); | 537 negatable: false); |
| 548 parser.addFlag(DISABLE_NEW_ANALYSIS_DRIVER, | |
| 549 help: "disable using new analysis driver", | |
| 550 defaultsTo: false, | |
| 551 negatable: false); | |
| 552 parser.addOption(INSTRUMENTATION_LOG_FILE, | 538 parser.addOption(INSTRUMENTATION_LOG_FILE, |
| 553 help: | 539 help: |
| 554 "the path of the file to which instrumentation data will be written"
); | 540 "the path of the file to which instrumentation data will be written"
); |
| 555 parser.addFlag(INTERNAL_PRINT_TO_CONSOLE, | 541 parser.addFlag(INTERNAL_PRINT_TO_CONSOLE, |
| 556 help: "enable sending `print` output to the console", | 542 help: "enable sending `print` output to the console", |
| 557 defaultsTo: false, | 543 defaultsTo: false, |
| 558 negatable: false); | 544 negatable: false); |
| 559 parser.addOption(NEW_ANALYSIS_DRIVER_LOG, | 545 parser.addOption(NEW_ANALYSIS_DRIVER_LOG, |
| 560 help: "set a destination for the new analysis driver's log"); | 546 help: "set a destination for the new analysis driver's log"); |
| 561 parser.addFlag(VERBOSE_FLUTTER_COMPLETIONS, | 547 parser.addFlag(VERBOSE_FLUTTER_COMPLETIONS, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 | 646 |
| 661 _DiagnosticServerImpl(); | 647 _DiagnosticServerImpl(); |
| 662 | 648 |
| 663 @override | 649 @override |
| 664 Future<int> getServerPort() => httpServer.serveHttp(); | 650 Future<int> getServerPort() => httpServer.serveHttp(); |
| 665 | 651 |
| 666 Future startOnPort(int port) { | 652 Future startOnPort(int port) { |
| 667 return httpServer.serveHttp(port); | 653 return httpServer.serveHttp(port); |
| 668 } | 654 } |
| 669 } | 655 } |
| OLD | NEW |