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

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

Issue 2405953002: Support for Bazel workspaces in ContextBuilder. (Closed)
Patch Set: Created 4 years, 2 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 af7b60b1823f8a5141b3fbdfcd1d2e8422144777..6b817f02614a875edf74cc42bef8f01c86e18c73 100644
--- a/pkg/analyzer/lib/src/context/builder.dart
+++ b/pkg/analyzer/lib/src/context/builder.dart
@@ -14,6 +14,7 @@ import 'package:analyzer/plugin/resolver_provider.dart';
import 'package:analyzer/source/analysis_options_provider.dart';
import 'package:analyzer/source/package_map_resolver.dart';
import 'package:analyzer/src/dart/sdk/sdk.dart';
+import 'package:analyzer/src/generated/bazel.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
@@ -70,12 +71,14 @@ class ContextBuilder {
* The resolver provider used to create a package: URI resolver, or `null` if
* the normal (Package Specification DEP) lookup mechanism is to be used.
*/
+ @deprecated
ResolverProvider packageResolverProvider;
/**
* The resolver provider used to create a file: URI resolver, or `null` if
* the normal file URI resolver is to be used.
*/
+ @deprecated
ResolverProvider fileResolverProvider;
/**
@@ -220,38 +223,29 @@ class ContextBuilder {
return findPackagesFromFile(rootDirectoryPath);
}
- SourceFactory createSourceFactory(
- String rootDirectoryPath, AnalysisOptions options) {
- Folder _folder = null;
- Folder folder() {
- return _folder ??= resourceProvider.getFolder(rootDirectoryPath);
+ SourceFactory createSourceFactory(String rootPath, AnalysisOptions options) {
+ BazelWorkspace bazelWorkspace =
+ BazelWorkspace.find(resourceProvider, rootPath);
+ if (bazelWorkspace != null) {
+ UriResolver fileResolver = new BazelFileUriResolver(bazelWorkspace);
+ UriResolver packageResolver = new BazelPackageUriResolver(bazelWorkspace);
+ // TODO(brianwilkerson) This doesn't support either embedder files or
Brian Wilkerson 2016/10/10 20:47:43 I think we can remove this comment.
+ // 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)),
+ packageResolver,
+ fileResolver
+ ];
+ return new SourceFactory(resolvers, null, resourceProvider);
}
- UriResolver fileResolver;
- if (fileResolverProvider != null) {
- fileResolver = fileResolverProvider(folder());
- }
- fileResolver ??= new ResourceUriResolver(resourceProvider);
- if (packageResolverProvider != 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)),
- packageResolver,
- fileResolver
- ];
- return new SourceFactory(resolvers, null, resourceProvider);
- }
- }
- Packages packages = createPackageMap(rootDirectoryPath);
+ Packages packages = createPackageMap(rootPath);
Map<String, List<Folder>> packageMap = convertPackagesToMap(packages);
List<UriResolver> resolvers = <UriResolver>[
new DartUriResolver(findSdk(packageMap, options)),
new PackageMapUriResolver(resourceProvider, packageMap),
- fileResolver
+ new ResourceUriResolver(resourceProvider)
];
return new SourceFactory(resolvers, packages, resourceProvider);
}
« 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