| 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 analysis.server; | 5 library analysis.server; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:core' hide Resource; | 9 import 'dart:core' hide Resource; |
| 10 import 'dart:math' show max; | 10 import 'dart:math' show max; |
| 11 | 11 |
| 12 import 'package:analysis_server/plugin/analysis/analyzed_files.dart'; | 12 import 'package:analysis_server/plugin/analysis/analyzed_files.dart'; |
| 13 import 'package:analysis_server/plugin/analysis/resolver_provider.dart'; | 13 import 'package:analysis_server/plugin/analysis/resolver_provider.dart'; |
| 14 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; | 14 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; |
| 15 import 'package:analysis_server/src/analysis_logger.dart'; | 15 import 'package:analysis_server/src/analysis_logger.dart'; |
| 16 import 'package:analysis_server/src/channel/channel.dart'; | 16 import 'package:analysis_server/src/channel/channel.dart'; |
| 17 import 'package:analysis_server/src/context_manager.dart'; | 17 import 'package:analysis_server/src/context_manager.dart'; |
| 18 import 'package:analysis_server/src/operation/operation.dart'; | 18 import 'package:analysis_server/src/operation/operation.dart'; |
| 19 import 'package:analysis_server/src/operation/operation_analysis.dart'; | 19 import 'package:analysis_server/src/operation/operation_analysis.dart'; |
| 20 import 'package:analysis_server/src/operation/operation_queue.dart'; | 20 import 'package:analysis_server/src/operation/operation_queue.dart'; |
| 21 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 21 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 22 import 'package:analysis_server/src/services/correction/namespace.dart'; | 22 import 'package:analysis_server/src/services/correction/namespace.dart'; |
| 23 import 'package:analysis_server/src/services/index/index.dart'; | 23 import 'package:analysis_server/src/services/index/index.dart'; |
| 24 import 'package:analysis_server/src/services/search/search_engine.dart'; | 24 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 25 import 'package:analyzer/file_system/file_system.dart'; | 25 import 'package:analyzer/file_system/file_system.dart'; |
| 26 import 'package:analyzer/instrumentation/instrumentation.dart'; | 26 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 27 import 'package:analyzer/source/embedder.dart'; |
| 27 import 'package:analyzer/source/pub_package_map_provider.dart'; | 28 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 28 import 'package:analyzer/src/generated/ast.dart'; | 29 import 'package:analyzer/src/generated/ast.dart'; |
| 29 import 'package:analyzer/src/generated/element.dart'; | 30 import 'package:analyzer/src/generated/element.dart'; |
| 30 import 'package:analyzer/src/generated/engine.dart'; | 31 import 'package:analyzer/src/generated/engine.dart'; |
| 31 import 'package:analyzer/src/generated/java_engine.dart'; | 32 import 'package:analyzer/src/generated/java_engine.dart'; |
| 32 import 'package:analyzer/src/generated/java_io.dart'; | 33 import 'package:analyzer/src/generated/java_io.dart'; |
| 33 import 'package:analyzer/src/generated/sdk.dart'; | 34 import 'package:analyzer/src/generated/sdk.dart'; |
| 34 import 'package:analyzer/src/generated/source.dart'; | 35 import 'package:analyzer/src/generated/source.dart'; |
| 35 import 'package:analyzer/src/generated/source_io.dart'; | 36 import 'package:analyzer/src/generated/source_io.dart'; |
| 36 import 'package:analyzer/src/generated/utilities_general.dart'; | 37 import 'package:analyzer/src/generated/utilities_general.dart'; |
| (...skipping 1480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 } | 1518 } |
| 1518 | 1519 |
| 1519 void _computingPackageMap(bool computing) { | 1520 void _computingPackageMap(bool computing) { |
| 1520 if (analysisServer.serverServices.contains(ServerService.STATUS)) { | 1521 if (analysisServer.serverServices.contains(ServerService.STATUS)) { |
| 1521 PubStatus pubStatus = new PubStatus(computing); | 1522 PubStatus pubStatus = new PubStatus(computing); |
| 1522 ServerStatusParams params = new ServerStatusParams(pub: pubStatus); | 1523 ServerStatusParams params = new ServerStatusParams(pub: pubStatus); |
| 1523 analysisServer.sendNotification(params.toNotification()); | 1524 analysisServer.sendNotification(params.toNotification()); |
| 1524 } | 1525 } |
| 1525 } | 1526 } |
| 1526 | 1527 |
| 1528 /// Returns true if the list of [resolvers] contains a [EmbedderUriResolver] |
| 1529 /// with at least one url mapping. |
| 1530 static bool _useEmbedderUriResolver(List<UriResolver> resolvers) { |
| 1531 for (UriResolver resolver in resolvers) { |
| 1532 if (resolver is EmbedderUriResolver) { |
| 1533 if (resolver.length > 0) { |
| 1534 return true; |
| 1535 } |
| 1536 } |
| 1537 } |
| 1538 return false; |
| 1539 } |
| 1540 |
| 1527 /** | 1541 /** |
| 1528 * Set up a [SourceFactory] that resolves packages as appropriate for the | 1542 * Set up a [SourceFactory] that resolves packages as appropriate for the |
| 1529 * given [disposition]. | 1543 * given [disposition]. |
| 1530 */ | 1544 */ |
| 1531 SourceFactory _createSourceFactory(FolderDisposition disposition) { | 1545 SourceFactory _createSourceFactory(FolderDisposition disposition) { |
| 1532 UriResolver dartResolver = new DartUriResolver(analysisServer.defaultSdk); | |
| 1533 UriResolver resourceResolver = new ResourceUriResolver(resourceProvider); | |
| 1534 List<UriResolver> resolvers = []; | 1546 List<UriResolver> resolvers = []; |
| 1535 resolvers.add(dartResolver); | 1547 List<UriResolver> packageUriResolvers = |
| 1536 resolvers.addAll(disposition.createPackageUriResolvers(resourceProvider)); | 1548 disposition.createPackageUriResolvers(resourceProvider); |
| 1537 resolvers.add(resourceResolver); | 1549 if (!_useEmbedderUriResolver(packageUriResolvers)) { |
| 1550 // If we aren't using the embedder uri resolver for dart: libraries, |
| 1551 // insert the default Dart SDK uri resolver. |
| 1552 resolvers.add(new DartUriResolver(analysisServer.defaultSdk)); |
| 1553 } |
| 1554 resolvers.addAll(packageUriResolvers); |
| 1555 resolvers.add(new ResourceUriResolver(resourceProvider)); |
| 1538 return new SourceFactory(resolvers, disposition.packages); | 1556 return new SourceFactory(resolvers, disposition.packages); |
| 1539 } | 1557 } |
| 1540 } | 1558 } |
| 1541 | 1559 |
| 1542 /** | 1560 /** |
| 1543 * A class used by [AnalysisServer] to record performance information | 1561 * A class used by [AnalysisServer] to record performance information |
| 1544 * such as request latency. | 1562 * such as request latency. |
| 1545 */ | 1563 */ |
| 1546 class ServerPerformance { | 1564 class ServerPerformance { |
| 1547 /** | 1565 /** |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 /** | 1651 /** |
| 1634 * The [PerformanceTag] for time spent in server request handlers. | 1652 * The [PerformanceTag] for time spent in server request handlers. |
| 1635 */ | 1653 */ |
| 1636 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1654 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 1637 | 1655 |
| 1638 /** | 1656 /** |
| 1639 * The [PerformanceTag] for time spent in split store microtasks. | 1657 * The [PerformanceTag] for time spent in split store microtasks. |
| 1640 */ | 1658 */ |
| 1641 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1659 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 1642 } | 1660 } |
| OLD | NEW |