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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.context.context_builder; 5 library analyzer.src.context.context_builder;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:core' hide Resource; 8 import 'dart:core' hide Resource;
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 new ResourceUriResolver(resourceProvider) 182 new ResourceUriResolver(resourceProvider)
183 ]; 183 ];
184 return new SourceFactory(resolvers); 184 return new SourceFactory(resolvers);
185 } 185 }
186 } 186 }
187 Map<String, List<Folder>> packageMap = 187 Map<String, List<Folder>> packageMap =
188 convertPackagesToMap(createPackageMap(rootDirectoryPath)); 188 convertPackagesToMap(createPackageMap(rootDirectoryPath));
189 List<UriResolver> resolvers = <UriResolver>[]; 189 List<UriResolver> resolvers = <UriResolver>[];
190 resolvers.add(new DartUriResolver(findSdk(packageMap, options))); 190 resolvers.add(new DartUriResolver(findSdk(packageMap, options)));
191 if (packageMap != null) { 191 if (packageMap != null) {
192 resolvers.add(new SdkExtUriResolver(packageMap));
193 resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap)); 192 resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap));
194 } 193 }
195 resolvers.add(new ResourceUriResolver(resourceProvider)); 194 resolvers.add(new ResourceUriResolver(resourceProvider));
196 return new SourceFactory(resolvers); 195 return new SourceFactory(resolvers);
197 } 196 }
198 197
199 /** 198 /**
200 * Use the given [packageMap] and [options] to locate the SDK. 199 * Use the given [packageMap] and [options] to locate the SDK.
201 */ 200 */
202 DartSdk findSdk( 201 DartSdk findSdk(
203 Map<String, List<Folder>> packageMap, AnalysisOptions options) { 202 Map<String, List<Folder>> packageMap, AnalysisOptions options) {
204 if (packageMap != null) { 203 if (packageMap != null) {
204 // TODO(brianwilkerson) Fix it so that we don't have to create a resolver
205 // to figure out what the extensions are.
206 SdkExtUriResolver extResolver = new SdkExtUriResolver(packageMap);
207 List<String> extFilePaths = extResolver.extensionFilePaths;
205 EmbedderYamlLocator locator = new EmbedderYamlLocator(packageMap); 208 EmbedderYamlLocator locator = new EmbedderYamlLocator(packageMap);
206 Map<Folder, YamlMap> embedderYamls = locator.embedderYamls; 209 Map<Folder, YamlMap> embedderYamls = locator.embedderYamls;
207 EmbedderSdk embedderSdk = new EmbedderSdk(embedderYamls); 210 EmbedderSdk embedderSdk = new EmbedderSdk(embedderYamls);
208 if (embedderSdk.sdkLibraries.length > 0) { 211 if (embedderSdk.sdkLibraries.length > 0) {
212 //
213 // There is an embedder file that defines the content of the SDK and
214 // there might be an extension file that extends it.
215 //
209 List<String> paths = <String>[]; 216 List<String> paths = <String>[];
210 for (Folder folder in embedderYamls.keys) { 217 for (Folder folder in embedderYamls.keys) {
211 paths.add(folder 218 paths.add(folder
212 .getChildAssumingFile(EmbedderYamlLocator.EMBEDDER_FILE_NAME) 219 .getChildAssumingFile(EmbedderYamlLocator.EMBEDDER_FILE_NAME)
213 .path); 220 .path);
214 } 221 }
222 paths.addAll(extFilePaths);
215 SdkDescription description = new SdkDescription(paths, options); 223 SdkDescription description = new SdkDescription(paths, options);
216 DartSdk dartSdk = sdkManager.getSdk(description, () { 224 DartSdk dartSdk = sdkManager.getSdk(description, () {
225 if (extFilePaths.isNotEmpty) {
226 embedderSdk.addExtensions(extResolver.urlMappings);
227 }
217 embedderSdk.analysisOptions = options; 228 embedderSdk.analysisOptions = options;
218 embedderSdk.useSummary = sdkManager.canUseSummaries; 229 embedderSdk.useSummary = sdkManager.canUseSummaries;
219 return embedderSdk; 230 return embedderSdk;
220 }); 231 });
221 return dartSdk; 232 return dartSdk;
233 } else if (extFilePaths != null) {
234 //
235 // We have an extension file, but no embedder file.
236 //
237 String sdkPath = sdkManager.defaultSdkDirectory;
238 List<String> paths = <String>[sdkPath];
239 paths.addAll(extFilePaths);
240 SdkDescription description = new SdkDescription(paths, options);
241 return sdkManager.getSdk(description, () {
242 DirectoryBasedDartSdk sdk =
243 new DirectoryBasedDartSdk(new JavaFile(sdkPath));
244 if (extFilePaths.isNotEmpty) {
245 embedderSdk.addExtensions(extResolver.urlMappings);
246 }
247 sdk.analysisOptions = options;
248 sdk.useSummary = sdkManager.canUseSummaries;
249 return sdk;
250 });
222 } 251 }
223 } 252 }
224 String sdkPath = sdkManager.defaultSdkDirectory; 253 String sdkPath = sdkManager.defaultSdkDirectory;
225 SdkDescription description = new SdkDescription(<String>[sdkPath], options); 254 SdkDescription description = new SdkDescription(<String>[sdkPath], options);
226 return sdkManager.getSdk(description, () { 255 return sdkManager.getSdk(description, () {
227 DirectoryBasedDartSdk sdk = 256 DirectoryBasedDartSdk sdk =
228 new DirectoryBasedDartSdk(new JavaFile(sdkPath)); 257 new DirectoryBasedDartSdk(new JavaFile(sdkPath));
229 sdk.analysisOptions = options; 258 sdk.analysisOptions = options;
230 sdk.useSummary = sdkManager.canUseSummaries; 259 sdk.useSummary = sdkManager.canUseSummaries;
231 return sdk; 260 return sdk;
(...skipping 24 matching lines...) Expand all
256 } 285 }
257 file = folder 286 file = folder
258 .getChildAssumingFile(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); 287 .getChildAssumingFile(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
259 if (file.exists) { 288 if (file.exists) {
260 return file; 289 return file;
261 } 290 }
262 } 291 }
263 return null; 292 return null;
264 } 293 }
265 } 294 }
OLDNEW
« 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