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 actualUri = containedUri; | |
819 | |
820 // Check .packages and update target and actual URIs as appropriate. | |
818 if (_packages != null && containedUri.scheme == 'package') { | 821 if (_packages != null && containedUri.scheme == 'package') { |
819 Uri packageUri = | 822 Uri packageUri = |
820 _packages.resolve(containedUri, notFound: (Uri packageUri) => null); | 823 _packages.resolve(containedUri, notFound: (Uri packageUri) => null); |
821 // Ensure scheme is set. | 824 |
822 if (packageUri != null && packageUri.scheme == '') { | 825 if (packageUri != null) { |
823 packageUri = packageUri.replace(scheme: 'file'); | 826 // Ensure scheme is set. |
827 if (packageUri.scheme == '') { | |
828 packageUri = packageUri.replace(scheme: 'file'); | |
829 } | |
830 containedUri = packageUri; | |
831 actualUri = containedUri; | |
Paul Berry
2015/07/21 21:33:47
Delete this line. It overwrites actualUri with th
pquitslund
2015/07/21 22:41:27
Sorry. Forgot to push this fix!
Already done. :)
| |
824 } | 832 } |
825 containedUri = packageUri; | |
826 } | 833 } |
834 | |
827 for (UriResolver resolver in _resolvers) { | 835 for (UriResolver resolver in _resolvers) { |
828 Source result = resolver.resolveAbsolute(containedUri); | 836 Source result = resolver.resolveAbsolute(containedUri, actualUri); |
829 if (result != null) { | 837 if (result != null) { |
830 return result; | 838 return result; |
831 } | 839 } |
832 } | 840 } |
841 | |
833 return null; | 842 return null; |
834 } | 843 } |
835 } | 844 } |
836 | 845 |
837 /** | 846 /** |
838 * The enumeration `SourceKind` defines the different kinds of sources that are known to the | 847 * The enumeration `SourceKind` defines the different kinds of sources that are known to the |
839 * analysis engine. | 848 * analysis engine. |
840 */ | 849 */ |
841 class SourceKind extends Enum<SourceKind> { | 850 class SourceKind extends Enum<SourceKind> { |
842 /** | 851 /** |
(...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 | 1064 * URI's for a source factory. Subclasses of this class are expected to resolve a single scheme of |
1056 * absolute URI. | 1065 * absolute URI. |
1057 */ | 1066 */ |
1058 abstract class UriResolver { | 1067 abstract class UriResolver { |
1059 /** | 1068 /** |
1060 * Resolve the given absolute URI. Return a [Source] representing the file to which | 1069 * 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 | 1070 * 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. | 1071 * resolved because the URI is invalid. |
1063 * | 1072 * |
1064 * @param uri the URI to be resolved | 1073 * @param uri the URI to be resolved |
1074 * @param actualUri the actual uri for this source -- if `null`, the value of [uri] will be used | |
1065 * @return a [Source] representing the file to which given URI was resolved | 1075 * @return a [Source] representing the file to which given URI was resolved |
1066 */ | 1076 */ |
1067 Source resolveAbsolute(Uri uri); | 1077 Source resolveAbsolute(Uri uri, [Uri actualUri]); |
1068 | 1078 |
1069 /** | 1079 /** |
1070 * Return an absolute URI that represents the given source, or `null` if a val id URI cannot | 1080 * Return an absolute URI that represents the given source, or `null` if a val id URI cannot |
1071 * be computed. | 1081 * be computed. |
1072 * | 1082 * |
1073 * @param source the source to get URI for | 1083 * @param source the source to get URI for |
1074 * @return the absolute URI representing the given source | 1084 * @return the absolute URI representing the given source |
1075 */ | 1085 */ |
1076 Uri restoreAbsolute(Source source) => null; | 1086 Uri restoreAbsolute(Source source) => null; |
1077 } | 1087 } |
OLD | NEW |