| 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 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 } | 1432 } |
| 1432 | 1433 |
| 1433 /** | 1434 /** |
| 1434 * Concrete [FolderDisposition] object indicating that the context for a given | 1435 * Concrete [FolderDisposition] object indicating that the context for a given |
| 1435 * folder should resolve packages using a ".packages" file. | 1436 * folder should resolve packages using a ".packages" file. |
| 1436 */ | 1437 */ |
| 1437 class PackagesFileDisposition extends FolderDisposition { | 1438 class PackagesFileDisposition extends FolderDisposition { |
| 1438 @override | 1439 @override |
| 1439 final Packages packages; | 1440 final Packages packages; |
| 1440 | 1441 |
| 1442 Map<String, List<Folder>> buildPackageMap(ResourceProvider resourceProvider) { |
| 1443 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; |
| 1444 if (packages == null) { |
| 1445 return packageMap; |
| 1446 } |
| 1447 packages.asMap().forEach((String name, Uri uri) { |
| 1448 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) { |
| 1449 var path = resourceProvider.pathContext.fromUri(uri); |
| 1450 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; |
| 1451 } |
| 1452 }); |
| 1453 return packageMap; |
| 1454 } |
| 1455 |
| 1441 PackagesFileDisposition(this.packages) {} | 1456 PackagesFileDisposition(this.packages) {} |
| 1442 | 1457 |
| 1443 @override | 1458 @override |
| 1444 String get packageRoot => null; | 1459 String get packageRoot => null; |
| 1445 | 1460 |
| 1446 @override | 1461 @override |
| 1447 Iterable<UriResolver> createPackageUriResolvers( | 1462 Iterable<UriResolver> createPackageUriResolvers( |
| 1448 ResourceProvider resourceProvider) { | 1463 ResourceProvider resourceProvider) { |
| 1449 if (packages != null) { | 1464 if (packages != null) { |
| 1450 // Construct package map for the SdkExtUriResolver. | 1465 // Construct package map for the SdkExtUriResolver. |
| 1451 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; | 1466 var packageMap = buildPackageMap(resourceProvider); |
| 1452 packages.asMap().forEach((String name, Uri uri) { | |
| 1453 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) { | |
| 1454 var path = resourceProvider.pathContext.fromUri(uri); | |
| 1455 packageMap[name] = <Folder>[resourceProvider.getFolder(path)]; | |
| 1456 } | |
| 1457 }); | |
| 1458 return <UriResolver>[new SdkExtUriResolver(packageMap)]; | 1467 return <UriResolver>[new SdkExtUriResolver(packageMap)]; |
| 1459 } else { | 1468 } else { |
| 1460 return const <UriResolver>[]; | 1469 return const <UriResolver>[]; |
| 1461 } | 1470 } |
| 1462 } | 1471 } |
| 1463 } | 1472 } |
| OLD | NEW |