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

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

Issue 2133873003: Handle SDK extensions in the SDK (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 | « pkg/analyzer/lib/source/sdk_ext.dart ('k') | pkg/analyzer/lib/src/generated/sdk_io.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 6abd7bd19e0e3d69b4724e9836e4f98684d60be1..8e68b02723bc07a91b050567003683c938aab1d3 100644
--- a/pkg/analyzer/lib/src/context/builder.dart
+++ b/pkg/analyzer/lib/src/context/builder.dart
@@ -189,7 +189,6 @@ class ContextBuilder {
List<UriResolver> resolvers = <UriResolver>[];
resolvers.add(new DartUriResolver(findSdk(packageMap, options)));
if (packageMap != null) {
- resolvers.add(new SdkExtUriResolver(packageMap));
resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap));
}
resolvers.add(new ResourceUriResolver(resourceProvider));
@@ -202,23 +201,53 @@ class ContextBuilder {
DartSdk findSdk(
Map<String, List<Folder>> packageMap, AnalysisOptions options) {
if (packageMap != null) {
+ // TODO(brianwilkerson) Fix it so that we don't have to create a resolver
+ // to figure out what the extensions are.
+ SdkExtUriResolver extResolver = new SdkExtUriResolver(packageMap);
+ List<String> extFilePaths = extResolver.extensionFilePaths;
EmbedderYamlLocator locator = new EmbedderYamlLocator(packageMap);
Map<Folder, YamlMap> embedderYamls = locator.embedderYamls;
EmbedderSdk embedderSdk = new EmbedderSdk(embedderYamls);
if (embedderSdk.sdkLibraries.length > 0) {
+ //
+ // There is an embedder file that defines the content of the SDK and
+ // there might be an extension file that extends it.
+ //
List<String> paths = <String>[];
for (Folder folder in embedderYamls.keys) {
paths.add(folder
.getChildAssumingFile(EmbedderYamlLocator.EMBEDDER_FILE_NAME)
.path);
}
+ paths.addAll(extFilePaths);
SdkDescription description = new SdkDescription(paths, options);
DartSdk dartSdk = sdkManager.getSdk(description, () {
+ if (extFilePaths.isNotEmpty) {
+ embedderSdk.addExtensions(extResolver.urlMappings);
+ }
embedderSdk.analysisOptions = options;
embedderSdk.useSummary = sdkManager.canUseSummaries;
return embedderSdk;
});
return dartSdk;
+ } else if (extFilePaths != null) {
+ //
+ // We have an extension file, but no embedder file.
+ //
+ String sdkPath = sdkManager.defaultSdkDirectory;
+ List<String> paths = <String>[sdkPath];
+ paths.addAll(extFilePaths);
+ SdkDescription description = new SdkDescription(paths, options);
+ return sdkManager.getSdk(description, () {
+ DirectoryBasedDartSdk sdk =
+ new DirectoryBasedDartSdk(new JavaFile(sdkPath));
+ if (extFilePaths.isNotEmpty) {
+ embedderSdk.addExtensions(extResolver.urlMappings);
+ }
+ sdk.analysisOptions = options;
+ sdk.useSummary = sdkManager.canUseSummaries;
+ return sdk;
+ });
}
}
String sdkPath = sdkManager.defaultSdkDirectory;
« no previous file with comments | « pkg/analyzer/lib/source/sdk_ext.dart ('k') | pkg/analyzer/lib/src/generated/sdk_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698