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

Unified Diff: pkg/analyzer/lib/src/context/builder.dart

Issue 2163003002: Add a hook to ContextBuilder needed by server (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/builder_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/context/builder.dart
diff --git a/pkg/analyzer/lib/src/context/builder.dart b/pkg/analyzer/lib/src/context/builder.dart
index 6ee48d98dee79f4fa9de8585b4bf68c72de45234..375535328df656d2b4339d34a4cd7afacd48af35 100644
--- a/pkg/analyzer/lib/src/context/builder.dart
+++ b/pkg/analyzer/lib/src/context/builder.dart
@@ -75,6 +75,12 @@ class ContextBuilder {
ResolverProvider packageResolverProvider;
/**
+ * The resolver provider used to create a file: URI resolver, or `null` if
+ * the normal file URI resolver is to be used.
+ */
+ ResolverProvider fileResolverProvider;
+
+ /**
* The file path of the .packages file that should be used in place of any
* file found using the normal (Package Specification DEP) lookup mechanism,
* or `null` if the normal lookup mechanism should be used.
@@ -197,17 +203,23 @@ class ContextBuilder {
SourceFactory createSourceFactory(
String rootDirectoryPath, AnalysisOptions options) {
+ Folder _folder = null;
+ Folder folder() {
+ return _folder ??= resourceProvider.getResource('.');
+ }
+ UriResolver fileResolver = fileResolverProvider == null
+ ? new ResourceUriResolver(resourceProvider)
+ : fileResolverProvider(folder());
if (packageResolverProvider != null) {
- Folder folder = resourceProvider.getResource('.');
- UriResolver resolver = packageResolverProvider(folder);
- if (resolver != null) {
+ UriResolver packageResolver = packageResolverProvider(folder());
+ if (packageResolver != null) {
// TODO(brianwilkerson) This doesn't support either embedder files or
// sdk extensions because we don't have a way to get the package map
// from the resolver.
List<UriResolver> resolvers = <UriResolver>[
new DartUriResolver(findSdk(null, options)),
- resolver,
- new ResourceUriResolver(resourceProvider)
+ packageResolver,
+ fileResolver
];
return new SourceFactory(resolvers);
}
@@ -219,7 +231,7 @@ class ContextBuilder {
if (packageMap != null) {
resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap));
}
- resolvers.add(new ResourceUriResolver(resourceProvider));
+ resolvers.add(fileResolver);
return new SourceFactory(resolvers);
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/builder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698