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

Unified Diff: pkg/analysis_server/lib/src/context_manager.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
Index: pkg/analysis_server/lib/src/context_manager.dart
diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart
index 767875ba42fafd915ecd96970444a459b825f228..22d9cc53e0232f02d0369e72650444e93795359e 100644
--- a/pkg/analysis_server/lib/src/context_manager.dart
+++ b/pkg/analysis_server/lib/src/context_manager.dart
@@ -15,7 +15,6 @@ import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:analyzer/plugin/options.dart';
import 'package:analyzer/source/analysis_options_provider.dart';
-import 'package:analyzer/source/embedder.dart';
import 'package:analyzer/source/package_map_provider.dart';
import 'package:analyzer/source/package_map_resolver.dart';
import 'package:analyzer/source/path_filter.dart';
@@ -229,6 +228,17 @@ abstract class ContextManager {
List<AnalysisContext> contextsInAnalysisRoot(Folder analysisRoot);
/**
+ * 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 getContextFor(String path);
+
+ /**
* Return `true` if the given absolute [path] is in one of the current
* root folders and is not excluded.
*/
@@ -445,6 +455,11 @@ class ContextManagerImpl implements ContextManager {
return contexts;
}
+ @override
+ AnalysisContext getContextFor(String path) {
+ return _getInnermostContextInfoFor(path)?.context;
+ }
+
/**
* For testing: get the [ContextInfo] object for the given [folder], if any.
*/
@@ -1454,6 +1469,11 @@ class PackagesFileDisposition extends FolderDisposition {
@override
final Packages packages;
+ PackagesFileDisposition(this.packages) {}
+
+ @override
+ String get packageRoot => null;
+
Map<String, List<Folder>> buildPackageMap(ResourceProvider resourceProvider) {
Map<String, List<Folder>> packageMap = <String, List<Folder>>{};
if (packages == null) {
@@ -1468,18 +1488,12 @@ class PackagesFileDisposition extends FolderDisposition {
return packageMap;
}
- PackagesFileDisposition(this.packages) {}
-
- @override
- String get packageRoot => null;
-
@override
Iterable<UriResolver> createPackageUriResolvers(
ResourceProvider resourceProvider) {
if (packages != null) {
// Construct package map for the SdkExtUriResolver.
- Map<String, List<Folder>> packageMap =
- buildPackageMap(resourceProvider);
+ Map<String, List<Folder>> packageMap = buildPackageMap(resourceProvider);
return <UriResolver>[new SdkExtUriResolver(packageMap)];
} else {
return const <UriResolver>[];
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/test/analysis/get_errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698