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 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 final String packageRoot; | 1350 final String packageRoot; |
1351 | 1351 |
1352 PackageMapDisposition(this.packageMap, {this.packageRoot}); | 1352 PackageMapDisposition(this.packageMap, {this.packageRoot}); |
1353 | 1353 |
1354 @override | 1354 @override |
1355 Packages get packages => null; | 1355 Packages get packages => null; |
1356 | 1356 |
1357 @override | 1357 @override |
1358 Iterable<UriResolver> createPackageUriResolvers( | 1358 Iterable<UriResolver> createPackageUriResolvers( |
1359 ResourceProvider resourceProvider) => | 1359 ResourceProvider resourceProvider) => |
1360 <UriResolver>[new SdkExtUriResolver(packageMap), | 1360 <UriResolver>[ |
1361 new PackageMapUriResolver(resourceProvider, packageMap)]; | 1361 new SdkExtUriResolver(packageMap), |
| 1362 new PackageMapUriResolver(resourceProvider, packageMap) |
| 1363 ]; |
1362 } | 1364 } |
1363 | 1365 |
1364 /** | 1366 /** |
1365 * Concrete [FolderDisposition] object indicating that the context for a given | 1367 * Concrete [FolderDisposition] object indicating that the context for a given |
1366 * folder should resolve packages using a ".packages" file. | 1368 * folder should resolve packages using a ".packages" file. |
1367 */ | 1369 */ |
1368 class PackagesFileDisposition extends FolderDisposition { | 1370 class PackagesFileDisposition extends FolderDisposition { |
1369 @override | 1371 @override |
1370 final Packages packages; | 1372 final Packages packages; |
1371 | 1373 |
1372 PackagesFileDisposition(this.packages) {} | 1374 PackagesFileDisposition(this.packages) {} |
1373 | 1375 |
1374 @override | 1376 @override |
1375 String get packageRoot => null; | 1377 String get packageRoot => null; |
1376 | 1378 |
1377 @override | 1379 @override |
1378 Iterable<UriResolver> createPackageUriResolvers( | 1380 Iterable<UriResolver> createPackageUriResolvers( |
1379 ResourceProvider resourceProvider) { | 1381 ResourceProvider resourceProvider) { |
1380 if (packages != null) { | 1382 if (packages != null) { |
1381 // Construct package map for the SdkExtUriResolver. | 1383 // Construct package map for the SdkExtUriResolver. |
1382 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; | 1384 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; |
1383 packages.asMap().forEach((String name, Uri uri) { | 1385 packages.asMap().forEach((String name, Uri uri) { |
1384 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) { | 1386 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) { |
1385 var path = resourceProvider.pathContext.fromUri(uri); | 1387 var path = resourceProvider.pathContext.fromUri(uri); |
1386 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; | 1388 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; |
1387 } | 1389 } |
1388 }); | 1390 }); |
1389 return <UriResolver>[new SdkExtUriResolver(packageMap)]; | 1391 return <UriResolver>[new SdkExtUriResolver(packageMap)]; |
1390 } else { | 1392 } else { |
1391 return const <UriResolver>[]; | 1393 return const <UriResolver>[]; |
1392 } | 1394 } |
1393 } | 1395 } |
1394 } | 1396 } |
OLD | NEW |