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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.source; | 8 library engine.source; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 class CustomUriResolver extends UriResolver { | 106 class CustomUriResolver extends UriResolver { |
| 107 final Map<String, String> _urlMappings; | 107 final Map<String, String> _urlMappings; |
| 108 | 108 |
| 109 CustomUriResolver(this._urlMappings); | 109 CustomUriResolver(this._urlMappings); |
| 110 | 110 |
| 111 @override | 111 @override |
| 112 Source resolveAbsolute(Uri uri) { | 112 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 113 String mapping = _urlMappings[uri.toString()]; | 113 String mapping = _urlMappings[uri.toString()]; |
| 114 if (mapping == null) return null; | 114 if (mapping == null) return null; |
| 115 | 115 |
| 116 Uri fileUri = new Uri.file(mapping); | 116 Uri fileUri = new Uri.file(mapping); |
| 117 if (!fileUri.isAbsolute) return null; | 117 if (!fileUri.isAbsolute) return null; |
| 118 | 118 |
| 119 JavaFile javaFile = new JavaFile.fromUri(fileUri); | 119 JavaFile javaFile = new JavaFile.fromUri(fileUri); |
| 120 return new FileBasedSource(javaFile); | 120 return new FileBasedSource(javaFile, actualUri); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 | 123 |
| 124 /** | 124 /** |
| 125 * Instances of the class `DartUriResolver` resolve `dart` URI's. | 125 * Instances of the class `DartUriResolver` resolve `dart` URI's. |
| 126 */ | 126 */ |
| 127 class DartUriResolver extends UriResolver { | 127 class DartUriResolver extends UriResolver { |
| 128 /** | 128 /** |
| 129 * The name of the `dart` scheme. | 129 * The name of the `dart` scheme. |
| 130 */ | 130 */ |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 149 DartUriResolver(this._sdk); | 149 DartUriResolver(this._sdk); |
| 150 | 150 |
| 151 /** | 151 /** |
| 152 * Return the [DartSdk] against which URIs are to be resolved. | 152 * Return the [DartSdk] against which URIs are to be resolved. |
| 153 * | 153 * |
| 154 * @return the [DartSdk] against which URIs are to be resolved. | 154 * @return the [DartSdk] against which URIs are to be resolved. |
| 155 */ | 155 */ |
| 156 DartSdk get dartSdk => _sdk; | 156 DartSdk get dartSdk => _sdk; |
| 157 | 157 |
| 158 @override | 158 @override |
| 159 Source resolveAbsolute(Uri uri) { | 159 Source resolveAbsolute(Uri uri, [Uri actualUri]) { |
| 160 if (!isDartUri(uri)) { | 160 if (!isDartUri(uri)) { |
| 161 return null; | 161 return null; |
| 162 } | 162 } |
| 163 return _sdk.mapDartUri(uri.toString()); | 163 return _sdk.mapDartUri(uri.toString()); |
| 164 } | 164 } |
| 165 | 165 |
| 166 /** | 166 /** |
| 167 * Return `true` if the given URI is a `dart-ext:` URI. | 167 * Return `true` if the given URI is a `dart-ext:` URI. |
| 168 * | 168 * |
| 169 * @param uriContent the textual representation of the URI being tested | 169 * @param uriContent the textual representation of the URI being tested |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 807 * against the source object's URI | 807 * against the source object's URI |
| 808 */ | 808 */ |
| 809 Source _internalResolveUri(Source containingSource, Uri containedUri) { | 809 Source _internalResolveUri(Source containingSource, Uri containedUri) { |
| 810 if (!containedUri.isAbsolute) { | 810 if (!containedUri.isAbsolute) { |
| 811 if (containingSource == null) { | 811 if (containingSource == null) { |
| 812 throw new AnalysisException( | 812 throw new AnalysisException( |
| 813 "Cannot resolve a relative URI without a containing source: $contain edUri"); | 813 "Cannot resolve a relative URI without a containing source: $contain edUri"); |
| 814 } | 814 } |
| 815 containedUri = containingSource.resolveRelativeUri(containedUri); | 815 containedUri = containingSource.resolveRelativeUri(containedUri); |
| 816 } | 816 } |
| 817 // Now check .packages. | 817 |
| 818 Uri uriToResolve = containedUri; | |
| 819 Uri actualUri = null; | |
|
Brian Wilkerson
2015/07/21 18:48:34
I'm not convinced that it's ever necessary to pass
Paul Berry
2015/07/21 19:39:27
I agree--AFAIK, always passing containedUri to res
pquitslund
2015/07/21 20:55:10
Ok. Fixed up!
| |
| 820 | |
| 821 // Check .packages and update target and actual URIs as appropriate. | |
| 818 if (_packages != null && containedUri.scheme == 'package') { | 822 if (_packages != null && containedUri.scheme == 'package') { |
| 819 Uri packageUri = | 823 Uri packageUri = |
| 820 _packages.resolve(containedUri, notFound: (Uri packageUri) => null); | 824 _packages.resolve(containedUri, notFound: (Uri packageUri) => null); |
| 821 // Ensure scheme is set. | 825 |
| 822 if (packageUri != null && packageUri.scheme == '') { | 826 if (packageUri != null) { |
| 823 packageUri = packageUri.replace(scheme: 'file'); | 827 // Ensure scheme is set. |
| 828 if (packageUri.scheme == '') { | |
| 829 packageUri = packageUri.replace(scheme: 'file'); | |
| 830 } | |
| 831 uriToResolve = packageUri; | |
| 832 actualUri = containedUri; | |
| 824 } | 833 } |
| 825 containedUri = packageUri; | |
| 826 } | 834 } |
| 835 | |
| 827 for (UriResolver resolver in _resolvers) { | 836 for (UriResolver resolver in _resolvers) { |
| 828 Source result = resolver.resolveAbsolute(containedUri); | 837 Source result = resolver.resolveAbsolute(uriToResolve, actualUri); |
| 829 if (result != null) { | 838 if (result != null) { |
| 830 return result; | 839 return result; |
| 831 } | 840 } |
| 832 } | 841 } |
| 842 | |
| 833 return null; | 843 return null; |
| 834 } | 844 } |
| 835 } | 845 } |
| 836 | 846 |
| 837 /** | 847 /** |
| 838 * The enumeration `SourceKind` defines the different kinds of sources that are known to the | 848 * The enumeration `SourceKind` defines the different kinds of sources that are known to the |
| 839 * analysis engine. | 849 * analysis engine. |
| 840 */ | 850 */ |
| 841 class SourceKind extends Enum<SourceKind> { | 851 class SourceKind extends Enum<SourceKind> { |
| 842 /** | 852 /** |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1055 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of | 1065 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of |
| 1056 * absolute URI. | 1066 * absolute URI. |
| 1057 */ | 1067 */ |
| 1058 abstract class UriResolver { | 1068 abstract class UriResolver { |
| 1059 /** | 1069 /** |
| 1060 * Resolve the given absolute URI. Return a [Source] representing the file to which | 1070 * Resolve the given absolute URI. Return a [Source] representing the file to which |
| 1061 * it was resolved, whether or not the resulting source exists, or `null` if i t could not be | 1071 * it was resolved, whether or not the resulting source exists, or `null` if i t could not be |
| 1062 * resolved because the URI is invalid. | 1072 * resolved because the URI is invalid. |
| 1063 * | 1073 * |
| 1064 * @param uri the URI to be resolved | 1074 * @param uri the URI to be resolved |
| 1075 * @param actualUri the actual uri for this source | |
|
Paul Berry
2015/07/21 19:39:27
We should document that the caller is allowed to p
pquitslund
2015/07/21 20:55:10
Done.
| |
| 1065 * @return a [Source] representing the file to which given URI was resolved | 1076 * @return a [Source] representing the file to which given URI was resolved |
| 1066 */ | 1077 */ |
| 1067 Source resolveAbsolute(Uri uri); | 1078 Source resolveAbsolute(Uri uri, [Uri actualUri]); |
| 1068 | 1079 |
| 1069 /** | 1080 /** |
| 1070 * Return an absolute URI that represents the given source, or `null` if a val id URI cannot | 1081 * Return an absolute URI that represents the given source, or `null` if a val id URI cannot |
| 1071 * be computed. | 1082 * be computed. |
| 1072 * | 1083 * |
| 1073 * @param source the source to get URI for | 1084 * @param source the source to get URI for |
| 1074 * @return the absolute URI representing the given source | 1085 * @return the absolute URI representing the given source |
| 1075 */ | 1086 */ |
| 1076 Uri restoreAbsolute(Source source) => null; | 1087 Uri restoreAbsolute(Source source) => null; |
| 1077 } | 1088 } |
| OLD | NEW |