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 engine.source; | 5 library engine.source; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import "dart:math" as math; | 8 import "dart:math" as math; |
9 | 9 |
10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 */ | 595 */ |
596 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK; | 596 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK; |
597 | 597 |
598 /** | 598 /** |
599 * Initialize a newly created source factory with the given absolute URI [reso
lvers] and | 599 * Initialize a newly created source factory with the given absolute URI [reso
lvers] and |
600 * optional [packages] resolution helper. | 600 * optional [packages] resolution helper. |
601 */ | 601 */ |
602 SourceFactory(this._resolvers, | 602 SourceFactory(this._resolvers, |
603 [this._packages, ResourceProvider resourceProvider]) | 603 [this._packages, ResourceProvider resourceProvider]) |
604 : _resourceProvider = resourceProvider != null | 604 : _resourceProvider = resourceProvider != null |
605 ? resourceProvider | 605 ? resourceProvider |
606 : PhysicalResourceProvider.INSTANCE; | 606 : PhysicalResourceProvider.INSTANCE; |
607 | 607 |
608 /** | 608 /** |
609 * Return the [DartSdk] associated with this [SourceFactory], or `null` if the
re | 609 * Return the [DartSdk] associated with this [SourceFactory], or `null` if the
re |
610 * is no such SDK. | 610 * is no such SDK. |
611 * | 611 * |
612 * @return the [DartSdk] associated with this [SourceFactory], or `null` if | 612 * @return the [DartSdk] associated with this [SourceFactory], or `null` if |
613 * there is no such SDK | 613 * there is no such SDK |
614 */ | 614 */ |
615 DartSdk get dartSdk { | 615 DartSdk get dartSdk { |
616 for (UriResolver resolver in _resolvers) { | 616 for (UriResolver resolver in _resolvers) { |
(...skipping 15 matching lines...) Expand all Loading... |
632 } | 632 } |
633 | 633 |
634 /// A table mapping package names to paths of directories containing | 634 /// A table mapping package names to paths of directories containing |
635 /// the package (or [null] if there is no registered package URI resolver). | 635 /// the package (or [null] if there is no registered package URI resolver). |
636 Map<String, List<Folder>> get packageMap { | 636 Map<String, List<Folder>> get packageMap { |
637 // Start by looking in .packages. | 637 // Start by looking in .packages. |
638 if (_packages != null) { | 638 if (_packages != null) { |
639 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; | 639 Map<String, List<Folder>> packageMap = <String, List<Folder>>{}; |
640 _packages.asMap().forEach((String name, Uri uri) { | 640 _packages.asMap().forEach((String name, Uri uri) { |
641 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) { | 641 if (uri.scheme == 'file' || uri.scheme == '' /* unspecified */) { |
642 packageMap[name] = | 642 packageMap[name] = <Folder>[ |
643 <Folder>[_resourceProvider.getFolder(uri.toFilePath())]; | 643 _resourceProvider.getFolder(uri.toFilePath()) |
| 644 ]; |
644 } | 645 } |
645 }); | 646 }); |
646 return packageMap; | 647 return packageMap; |
647 } | 648 } |
648 | 649 |
649 // Default to the PackageMapUriResolver. | 650 // Default to the PackageMapUriResolver. |
650 PackageMapUriResolver resolver = _resolvers.firstWhere( | 651 PackageMapUriResolver resolver = _resolvers |
651 (r) => r is PackageMapUriResolver, orElse: () => null); | 652 .firstWhere((r) => r is PackageMapUriResolver, orElse: () => null); |
652 return resolver != null ? resolver.packageMap : null; | 653 return resolver != null ? resolver.packageMap : null; |
653 } | 654 } |
654 | 655 |
655 /** | 656 /** |
656 * Return a source object representing the given absolute URI, or `null` if th
e URI is not a | 657 * Return a source object representing the given absolute URI, or `null` if th
e URI is not a |
657 * valid URI or if it is not an absolute URI. | 658 * valid URI or if it is not an absolute URI. |
658 * | 659 * |
659 * @param absoluteUri the absolute URI to be resolved | 660 * @param absoluteUri the absolute URI to be resolved |
660 * @return a source object representing the absolute URI | 661 * @return a source object representing the absolute URI |
661 */ | 662 */ |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 Source resolveAbsolute(Uri uri, [Uri actualUri]); | 1074 Source resolveAbsolute(Uri uri, [Uri actualUri]); |
1074 | 1075 |
1075 /** | 1076 /** |
1076 * Return an absolute URI that represents the given [source], or `null` if a | 1077 * Return an absolute URI that represents the given [source], or `null` if a |
1077 * valid URI cannot be computed. | 1078 * valid URI cannot be computed. |
1078 * | 1079 * |
1079 * The computation should be based solely on [source.fullName]. | 1080 * The computation should be based solely on [source.fullName]. |
1080 */ | 1081 */ |
1081 Uri restoreAbsolute(Source source) => null; | 1082 Uri restoreAbsolute(Source source) => null; |
1082 } | 1083 } |
OLD | NEW |