OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 context.directory.manager; | 5 library context.directory.manager; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:core' hide Resource; | 10 import 'dart:core' hide Resource; |
(...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 * given [disposition]. | 1150 * given [disposition]. |
1151 */ | 1151 */ |
1152 SourceFactory _createSourceFactory(InternalAnalysisContext context, | 1152 SourceFactory _createSourceFactory(InternalAnalysisContext context, |
1153 AnalysisOptions options, FolderDisposition disposition, Folder folder) { | 1153 AnalysisOptions options, FolderDisposition disposition, Folder folder) { |
1154 List<UriResolver> resolvers = []; | 1154 List<UriResolver> resolvers = []; |
1155 List<UriResolver> packageUriResolvers = | 1155 List<UriResolver> packageUriResolvers = |
1156 disposition.createPackageUriResolvers(resourceProvider); | 1156 disposition.createPackageUriResolvers(resourceProvider); |
1157 | 1157 |
1158 EmbedderYamlLocator locator = | 1158 EmbedderYamlLocator locator = |
1159 disposition.getEmbedderLocator(resourceProvider); | 1159 disposition.getEmbedderLocator(resourceProvider); |
1160 EmbedderSdk sdk = new EmbedderSdk(locator.embedderYamls); | 1160 Map<Folder, YamlMap> embedderYamls = locator.embedderYamls; |
1161 if (sdk.libraryMap.size() == 0) { | 1161 EmbedderSdk embedderSdk = new EmbedderSdk(embedderYamls); |
1162 // The embedder uri resolver has no mappings. Use the default Dart SDK | 1162 if (embedderSdk.libraryMap.size() == 0) { |
1163 // uri resolver. | 1163 // There was no embedder file, or the file was empty, so used the default |
| 1164 // SDK. |
1164 resolvers.add(new DartUriResolver(sdkManager.getSdkForOptions(options))); | 1165 resolvers.add(new DartUriResolver(sdkManager.getSdkForOptions(options))); |
1165 } else { | 1166 } else { |
1166 // The embedder uri resolver has mappings, use it instead of the default | 1167 // The embedder file defines an alternate SDK, so use it. |
1167 // Dart SDK uri resolver. | 1168 List<String> paths = <String>[]; |
1168 resolvers.add(new DartUriResolver(sdk)); | 1169 for (Folder folder in embedderYamls.keys) { |
| 1170 paths.add(folder |
| 1171 .getChildAssumingFile(EmbedderYamlLocator.EMBEDDER_FILE_NAME) |
| 1172 .path); |
| 1173 } |
| 1174 DartSdk dartSdk = |
| 1175 sdkManager.getSdk(new SdkDescription(paths, options), () { |
| 1176 embedderSdk.analysisOptions = options; |
| 1177 // TODO(brianwilkerson) Enable summary use after we have decided where |
| 1178 // summary files for embedder files will live. |
| 1179 embedderSdk.useSummary = false; |
| 1180 return embedderSdk; |
| 1181 }); |
| 1182 resolvers.add(new DartUriResolver(dartSdk)); |
1169 } | 1183 } |
1170 | 1184 |
1171 resolvers.addAll(packageUriResolvers); | 1185 resolvers.addAll(packageUriResolvers); |
1172 resolvers.add(new ResourceUriResolver(resourceProvider)); | 1186 resolvers.add(new ResourceUriResolver(resourceProvider)); |
1173 return new SourceFactory(resolvers, disposition.packages); | 1187 return new SourceFactory(resolvers, disposition.packages); |
1174 } | 1188 } |
1175 | 1189 |
1176 /** | 1190 /** |
1177 * Clean up and destroy the context associated with the given folder. | 1191 * Clean up and destroy the context associated with the given folder. |
1178 */ | 1192 */ |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1852 | 1866 |
1853 @override | 1867 @override |
1854 EmbedderYamlLocator getEmbedderLocator(ResourceProvider resourceProvider) { | 1868 EmbedderYamlLocator getEmbedderLocator(ResourceProvider resourceProvider) { |
1855 if (_embedderLocator == null) { | 1869 if (_embedderLocator == null) { |
1856 _embedderLocator = | 1870 _embedderLocator = |
1857 new EmbedderYamlLocator(buildPackageMap(resourceProvider)); | 1871 new EmbedderYamlLocator(buildPackageMap(resourceProvider)); |
1858 } | 1872 } |
1859 return _embedderLocator; | 1873 return _embedderLocator; |
1860 } | 1874 } |
1861 } | 1875 } |
OLD | NEW |