Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 2078993002: Remove embedder locator from analysis context (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/context_manager.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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;
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
1549 1549
1550 ServerContextManagerCallbacks(this.analysisServer, this.resourceProvider); 1550 ServerContextManagerCallbacks(this.analysisServer, this.resourceProvider);
1551 1551
1552 @override 1552 @override
1553 AnalysisContext addContext( 1553 AnalysisContext addContext(
1554 Folder folder, AnalysisOptions options, FolderDisposition disposition) { 1554 Folder folder, AnalysisOptions options, FolderDisposition disposition) {
1555 InternalAnalysisContext context = 1555 InternalAnalysisContext context =
1556 AnalysisEngine.instance.createAnalysisContext(); 1556 AnalysisEngine.instance.createAnalysisContext();
1557 context.contentCache = analysisServer.overlayState; 1557 context.contentCache = analysisServer.overlayState;
1558 analysisServer.folderMap[folder] = context; 1558 analysisServer.folderMap[folder] = context;
1559 _locateEmbedderYamls(context, disposition);
1560 context.sourceFactory = 1559 context.sourceFactory =
1561 _createSourceFactory(context, options, disposition, folder); 1560 _createSourceFactory(context, options, disposition, folder);
1562 context.analysisOptions = options; 1561 context.analysisOptions = options;
1563 analysisServer._onContextsChangedController 1562 analysisServer._onContextsChangedController
1564 .add(new ContextsChangedEvent(added: [context])); 1563 .add(new ContextsChangedEvent(added: [context]));
1565 analysisServer.schedulePerformAnalysisOperation(context); 1564 analysisServer.schedulePerformAnalysisOperation(context);
1566 return context; 1565 return context;
1567 } 1566 }
1568 1567
1569 @override 1568 @override
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 * Set up a [SourceFactory] that resolves packages as appropriate for the 1616 * Set up a [SourceFactory] that resolves packages as appropriate for the
1618 * given [disposition]. 1617 * given [disposition].
1619 */ 1618 */
1620 SourceFactory _createSourceFactory(InternalAnalysisContext context, 1619 SourceFactory _createSourceFactory(InternalAnalysisContext context,
1621 AnalysisOptions options, FolderDisposition disposition, Folder folder) { 1620 AnalysisOptions options, FolderDisposition disposition, Folder folder) {
1622 List<UriResolver> resolvers = []; 1621 List<UriResolver> resolvers = [];
1623 List<UriResolver> packageUriResolvers = 1622 List<UriResolver> packageUriResolvers =
1624 disposition.createPackageUriResolvers(resourceProvider); 1623 disposition.createPackageUriResolvers(resourceProvider);
1625 1624
1626 // If no embedded URI resolver was provided, defer to a locator-backed one. 1625 // If no embedded URI resolver was provided, defer to a locator-backed one.
1627 EmbedderSdk sdk = 1626 EmbedderYamlLocator locator =
1628 new EmbedderSdk(context.embedderYamlLocator.embedderYamls); 1627 disposition.getEmbedderLocator(resourceProvider);
1628 EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls);
1629 if (sdk.libraryMap.size() == 0) { 1629 if (sdk.libraryMap.size() == 0) {
1630 // The embedder file has no mappings, so use the default Dart SDK. 1630 // The embedder file has no mappings, so use the default Dart SDK.
1631 resolvers.add(new DartUriResolver( 1631 resolvers.add(new DartUriResolver(
1632 analysisServer.sdkManager.getSdkForOptions(options))); 1632 analysisServer.sdkManager.getSdkForOptions(options)));
1633 } else { 1633 } else {
1634 // The embedder uri resolver has mappings, use it instead of the default 1634 // The embedder uri resolver has mappings, use it instead of the default
1635 // Dart SDK uri resolver. 1635 // Dart SDK uri resolver.
1636 resolvers.add(new DartUriResolver(sdk)); 1636 resolvers.add(new DartUriResolver(sdk));
1637 } 1637 }
1638 1638
1639 resolvers.addAll(packageUriResolvers); 1639 resolvers.addAll(packageUriResolvers);
1640 resolvers.add(new ResourceUriResolver(resourceProvider)); 1640 resolvers.add(new ResourceUriResolver(resourceProvider));
1641 return new SourceFactory(resolvers, disposition.packages); 1641 return new SourceFactory(resolvers, disposition.packages);
1642 } 1642 }
1643
1644 /// If [disposition] has a package map, attempt to locate `_embedder.yaml`
1645 /// files.
1646 void _locateEmbedderYamls(
1647 InternalAnalysisContext context, FolderDisposition disposition) {
1648 Map<String, List<Folder>> packageMap;
1649 if (disposition is PackageMapDisposition) {
1650 packageMap = disposition.packageMap;
1651 } else if (disposition is PackagesFileDisposition) {
1652 packageMap = disposition.buildPackageMap(resourceProvider);
1653 }
1654 context.embedderYamlLocator.refresh(packageMap);
1655 }
1656 } 1643 }
1657 1644
1658 /** 1645 /**
1659 * A class used by [AnalysisServer] to record performance information 1646 * A class used by [AnalysisServer] to record performance information
1660 * such as request latency. 1647 * such as request latency.
1661 */ 1648 */
1662 class ServerPerformance { 1649 class ServerPerformance {
1663 /** 1650 /**
1664 * The creation time and the time when performance information 1651 * The creation time and the time when performance information
1665 * started to be recorded here. 1652 * started to be recorded here.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 /** 1736 /**
1750 * The [PerformanceTag] for time spent in server request handlers. 1737 * The [PerformanceTag] for time spent in server request handlers.
1751 */ 1738 */
1752 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); 1739 static PerformanceTag serverRequests = new PerformanceTag('serverRequests');
1753 1740
1754 /** 1741 /**
1755 * The [PerformanceTag] for time spent in split store microtasks. 1742 * The [PerformanceTag] for time spent in split store microtasks.
1756 */ 1743 */
1757 static PerformanceTag splitStore = new PerformanceTag('splitStore'); 1744 static PerformanceTag splitStore = new PerformanceTag('splitStore');
1758 } 1745 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/context_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698