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 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 analysisServerOptions.enableIncrementalResolutionValidation = | 368 analysisServerOptions.enableIncrementalResolutionValidation = |
369 results[INCREMENTAL_RESOLUTION_VALIDATION]; | 369 results[INCREMENTAL_RESOLUTION_VALIDATION]; |
370 analysisServerOptions.noErrorNotification = results[NO_ERROR_NOTIFICATION]; | 370 analysisServerOptions.noErrorNotification = results[NO_ERROR_NOTIFICATION]; |
371 analysisServerOptions.noIndex = results[NO_INDEX]; | 371 analysisServerOptions.noIndex = results[NO_INDEX]; |
372 analysisServerOptions.useAnalysisHighlight2 = | 372 analysisServerOptions.useAnalysisHighlight2 = |
373 results[USE_ANALISYS_HIGHLIGHT2]; | 373 results[USE_ANALISYS_HIGHLIGHT2]; |
374 analysisServerOptions.fileReadMode = results[FILE_READ_MODE]; | 374 analysisServerOptions.fileReadMode = results[FILE_READ_MODE]; |
375 | 375 |
376 _initIncrementalLogger(results[INCREMENTAL_RESOLUTION_LOG]); | 376 _initIncrementalLogger(results[INCREMENTAL_RESOLUTION_LOG]); |
377 | 377 |
378 DartSdk defaultSdk; | 378 JavaFile defaultSdkDirectory; |
379 if (results[SDK_OPTION] != null) { | 379 if (results[SDK_OPTION] != null) { |
380 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION])); | 380 defaultSdkDirectory = new JavaFile(results[SDK_OPTION]); |
381 } else { | 381 } else { |
382 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, | 382 // No path to the SDK was provided. |
383 // which will make a guess. | 383 // Use DirectoryBasedDartSdk.defaultSdkDirectory, which will make a guess. |
384 defaultSdk = DirectoryBasedDartSdk.defaultSdk; | 384 defaultSdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory; |
385 } | 385 } |
| 386 SdkCreator defaultSdkCreator = |
| 387 () => new DirectoryBasedDartSdk(defaultSdkDirectory); |
| 388 // TODO(brianwilkerson) It would be nice to avoid creating an SDK that |
| 389 // cannot be re-used, but the SDK is needed to create a package map provider |
| 390 // in the case where we need to run `pub` in order to get the package map. |
| 391 DirectoryBasedDartSdk defaultSdk = defaultSdkCreator(); |
386 // | 392 // |
387 // Initialize the instrumentation service. | 393 // Initialize the instrumentation service. |
388 // | 394 // |
389 String logFilePath = results[INSTRUMENTATION_LOG_FILE]; | 395 String logFilePath = results[INSTRUMENTATION_LOG_FILE]; |
390 if (logFilePath != null) { | 396 if (logFilePath != null) { |
391 _rollLogFiles(logFilePath, 5); | 397 _rollLogFiles(logFilePath, 5); |
392 FileInstrumentationServer fileBasedServer = | 398 FileInstrumentationServer fileBasedServer = |
393 new FileInstrumentationServer(logFilePath); | 399 new FileInstrumentationServer(logFilePath); |
394 instrumentationServer = instrumentationServer != null | 400 instrumentationServer = instrumentationServer != null |
395 ? new MulticastInstrumentationServer( | 401 ? new MulticastInstrumentationServer( |
(...skipping 17 matching lines...) Expand all Loading... |
413 plugins.add(linterPlugin); | 419 plugins.add(linterPlugin); |
414 plugins.add(linterServerPlugin); | 420 plugins.add(linterServerPlugin); |
415 plugins.add(dartCompletionPlugin); | 421 plugins.add(dartCompletionPlugin); |
416 plugins.addAll(_userDefinedPlugins); | 422 plugins.addAll(_userDefinedPlugins); |
417 | 423 |
418 ExtensionManager manager = new ExtensionManager(); | 424 ExtensionManager manager = new ExtensionManager(); |
419 manager.processPlugins(plugins); | 425 manager.processPlugins(plugins); |
420 // | 426 // |
421 // Create the sockets and start listening for requests. | 427 // Create the sockets and start listening for requests. |
422 // | 428 // |
423 socketServer = new SocketServer(analysisServerOptions, defaultSdk, service, | 429 socketServer = new SocketServer( |
424 serverPlugin, packageResolverProvider, embeddedUriResolverProvider); | 430 analysisServerOptions, |
| 431 defaultSdkCreator, |
| 432 defaultSdk, |
| 433 service, |
| 434 serverPlugin, |
| 435 packageResolverProvider, |
| 436 embeddedUriResolverProvider); |
425 httpServer = new HttpAnalysisServer(socketServer); | 437 httpServer = new HttpAnalysisServer(socketServer); |
426 stdioServer = new StdioAnalysisServer(socketServer); | 438 stdioServer = new StdioAnalysisServer(socketServer); |
427 socketServer.userDefinedPlugins = _userDefinedPlugins; | 439 socketServer.userDefinedPlugins = _userDefinedPlugins; |
428 | 440 |
429 if (serve_http) { | 441 if (serve_http) { |
430 httpServer.serveHttp(port); | 442 httpServer.serveHttp(port); |
431 } | 443 } |
432 | 444 |
433 _captureExceptions(service, () { | 445 _captureExceptions(service, () { |
434 stdioServer.serveStdio().then((_) async { | 446 stdioServer.serveStdio().then((_) async { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 */ | 598 */ |
587 static void _rollLogFiles(String path, int numOld) { | 599 static void _rollLogFiles(String path, int numOld) { |
588 for (int i = numOld - 1; i >= 0; i--) { | 600 for (int i = numOld - 1; i >= 0; i--) { |
589 try { | 601 try { |
590 String oldPath = i == 0 ? path : '$path.$i'; | 602 String oldPath = i == 0 ? path : '$path.$i'; |
591 new File(oldPath).renameSync('$path.${i+1}'); | 603 new File(oldPath).renameSync('$path.${i+1}'); |
592 } catch (e) {} | 604 } catch (e) {} |
593 } | 605 } |
594 } | 606 } |
595 } | 607 } |
OLD | NEW |