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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 1455163005: Implement AnalysisServer.getContainingContext() using ContextManager. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/context_manager.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 2a3b29db91e0ec5d1b5fa017dbed4b6783564d9b..93c929c7daa1022a169cc4b5494d146a5bc885e4 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -473,22 +473,16 @@ class AnalysisServer {
}
/**
- * Return the [AnalysisContext] that contains the given [path].
- * Return `null` if no context contains the [path].
+ * Return the [AnalysisContext] for the "innermost" context whose associated
+ * folder is or contains the given path. ("innermost" refers to the nesting
+ * of contexts, so if there is a context for path /foo and a context for
+ * path /foo/bar, then the innermost context containing /foo/bar/baz.dart is
+ * the context for /foo/bar.)
+ *
+ * If no context contains the given path, `null` is returned.
*/
AnalysisContext getContainingContext(String path) {
- Folder containingFolder = null;
- AnalysisContext containingContext = null;
- folderMap.forEach((Folder folder, AnalysisContext context) {
- if (folder.isOrContains(path)) {
- if (containingFolder == null ||
- containingFolder.path.length < folder.path.length) {
- containingFolder = folder;
- containingContext = context;
- }
- }
- });
- return containingContext;
+ return contextManager.getContextFor(path);
}
/**
@@ -1539,25 +1533,12 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
}
}
- /// If [disposition] has a package map, attempt to locate `_embedder.yaml`
- /// files.
- void _locateEmbedderYamls(InternalAnalysisContext context,
- FolderDisposition disposition) {
- Map<String, List<Folder>> packageMap;
- if (disposition is PackageMapDisposition) {
- packageMap = disposition.packageMap;
- } else if (disposition is PackagesFileDisposition) {
- packageMap = disposition.buildPackageMap(resourceProvider);
- }
- context.embedderYamlLocator.refresh(packageMap);
- }
-
/**
* Set up a [SourceFactory] that resolves packages as appropriate for the
* given [disposition].
*/
- SourceFactory _createSourceFactory(InternalAnalysisContext context,
- FolderDisposition disposition) {
+ SourceFactory _createSourceFactory(
+ InternalAnalysisContext context, FolderDisposition disposition) {
List<UriResolver> resolvers = [];
List<UriResolver> packageUriResolvers =
disposition.createPackageUriResolvers(resourceProvider);
@@ -1576,6 +1557,19 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
resolvers.add(new ResourceUriResolver(resourceProvider));
return new SourceFactory(resolvers, disposition.packages);
}
+
+ /// If [disposition] has a package map, attempt to locate `_embedder.yaml`
+ /// files.
+ void _locateEmbedderYamls(
+ InternalAnalysisContext context, FolderDisposition disposition) {
+ Map<String, List<Folder>> packageMap;
+ if (disposition is PackageMapDisposition) {
+ packageMap = disposition.packageMap;
+ } else if (disposition is PackagesFileDisposition) {
+ packageMap = disposition.buildPackageMap(resourceProvider);
+ }
+ context.embedderYamlLocator.refresh(packageMap);
+ }
}
/**
« 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