Chromium Code Reviews| 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; |
| 11 | 11 |
| 12 import 'package:analysis_server/plugin/analysis/resolver_provider.dart'; | 12 import 'package:analysis_server/plugin/analysis/resolver_provider.dart'; |
| 13 import 'package:analysis_server/src/analysis_server.dart'; | 13 import 'package:analysis_server/src/analysis_server.dart'; |
| 14 import 'package:analyzer/file_system/file_system.dart'; | 14 import 'package:analyzer/file_system/file_system.dart'; |
| 15 import 'package:analyzer/instrumentation/instrumentation.dart'; | 15 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 16 import 'package:analyzer/plugin/options.dart'; | 16 import 'package:analyzer/plugin/options.dart'; |
| 17 import 'package:analyzer/source/analysis_options_provider.dart'; | 17 import 'package:analyzer/source/analysis_options_provider.dart'; |
| 18 import 'package:analyzer/source/embedder.dart'; | |
| 18 import 'package:analyzer/source/package_map_provider.dart'; | 19 import 'package:analyzer/source/package_map_provider.dart'; |
| 19 import 'package:analyzer/source/package_map_resolver.dart'; | 20 import 'package:analyzer/source/package_map_resolver.dart'; |
| 20 import 'package:analyzer/source/path_filter.dart'; | 21 import 'package:analyzer/source/path_filter.dart'; |
| 21 import 'package:analyzer/source/pub_package_map_provider.dart'; | 22 import 'package:analyzer/source/pub_package_map_provider.dart'; |
| 22 import 'package:analyzer/source/sdk_ext.dart'; | 23 import 'package:analyzer/source/sdk_ext.dart'; |
| 23 import 'package:analyzer/src/context/context.dart' as context; | 24 import 'package:analyzer/src/context/context.dart' as context; |
| 24 import 'package:analyzer/src/generated/engine.dart'; | 25 import 'package:analyzer/src/generated/engine.dart'; |
| 25 import 'package:analyzer/src/generated/java_engine.dart'; | 26 import 'package:analyzer/src/generated/java_engine.dart'; |
| 26 import 'package:analyzer/src/generated/java_io.dart'; | 27 import 'package:analyzer/src/generated/java_io.dart'; |
| 27 import 'package:analyzer/src/generated/source.dart'; | 28 import 'package:analyzer/src/generated/source.dart'; |
| (...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1424 } | 1425 } |
| 1425 | 1426 |
| 1426 /** | 1427 /** |
| 1427 * Concrete [FolderDisposition] object indicating that the context for a given | 1428 * Concrete [FolderDisposition] object indicating that the context for a given |
| 1428 * folder should resolve packages using a ".packages" file. | 1429 * folder should resolve packages using a ".packages" file. |
| 1429 */ | 1430 */ |
| 1430 class PackagesFileDisposition extends FolderDisposition { | 1431 class PackagesFileDisposition extends FolderDisposition { |
| 1431 @override | 1432 @override |
| 1432 final Packages packages; | 1433 final Packages packages; |
| 1433 | 1434 |
| 1435 Map<String, List<Folder>> buildPackageMap(ResourceProvider resourceProvider) { | |
| 1436 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; | |
| 1437 if (packages == null) { | |
| 1438 return packageMap; | |
| 1439 } | |
| 1440 packages.asMap().forEach((String name, Uri uri) { | |
| 1441 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) { | |
| 1442 var path = resourceProvider.pathContext.fromUri(uri); | |
| 1443 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; | |
| 1444 } | |
| 1445 }); | |
| 1446 return packageMap; | |
| 1447 } | |
| 1448 | |
| 1434 PackagesFileDisposition(this.packages) {} | 1449 PackagesFileDisposition(this.packages) {} |
| 1435 | 1450 |
| 1436 @override | 1451 @override |
| 1437 String get packageRoot => null; | 1452 String get packageRoot => null; |
| 1438 | 1453 |
| 1439 @override | 1454 @override |
| 1440 Iterable<UriResolver> createPackageUriResolvers( | 1455 Iterable<UriResolver> createPackageUriResolvers( |
| 1441 ResourceProvider resourceProvider) { | 1456 ResourceProvider resourceProvider) { |
| 1442 if (packages != null) { | 1457 if (packages != null) { |
| 1443 // Construct package map for the SdkExtUriResolver. | 1458 // Construct package map for the SdkExtUriResolver. |
| 1444 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; | 1459 var packageMap = buildPackageMap(resourceProvider); |
|
pquitslund
2015/11/14 00:32:53
Nit: missing type:
Map<String, List<Folder>> pa
Cutch
2015/11/14 00:36:44
Done.
| |
| 1445 packages.asMap().forEach((String name, Uri uri) { | |
| 1446 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) { | |
| 1447 var path = resourceProvider.pathContext.fromUri(uri); | |
| 1448 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; | |
| 1449 } | |
| 1450 }); | |
| 1451 return <UriResolver>[new SdkExtUriResolver(packageMap)]; | 1460 return <UriResolver>[new SdkExtUriResolver(packageMap)]; |
| 1452 } else { | 1461 } else { |
| 1453 return const <UriResolver>[]; | 1462 return const <UriResolver>[]; |
| 1454 } | 1463 } |
| 1455 } | 1464 } |
| 1456 } | 1465 } |
| OLD | NEW |