| OLD | NEW |
| 1 // This code was auto-generated, is not intended to be edited, and is subject to | 1 // This code was auto-generated, is not intended to be edited, and is subject to |
| 2 // significant change. Please see the README file for more information. | 2 // significant change. Please see the README file for more information. |
| 3 | 3 |
| 4 library engine.source; | 4 library engine.source; |
| 5 | 5 |
| 6 import 'dart:uri'; | 6 import 'dart:uri'; |
| 7 import 'java_core.dart'; | 7 import 'java_core.dart'; |
| 8 import 'sdk.dart' show DartSdk; |
| 8 import 'engine.dart' show AnalysisContext; | 9 import 'engine.dart' show AnalysisContext; |
| 9 | 10 |
| 10 /** | 11 /** |
| 11 * Instances of the class {@code SourceFactory} resolve possibly relative URI's
against an existing{@link Source source}. | 12 * Instances of the class {@code SourceFactory} resolve possibly relative URI's
against an existing{@link Source source}. |
| 12 * @coverage dart.engine.source | 13 * @coverage dart.engine.source |
| 13 */ | 14 */ |
| 14 class SourceFactory { | 15 class SourceFactory { |
| 15 /** | 16 /** |
| 16 * The analysis context that this source factory is associated with. | 17 * The analysis context that this source factory is associated with. |
| 17 */ | 18 */ |
| 18 AnalysisContext _context; | 19 AnalysisContext _context; |
| 19 /** | 20 /** |
| 20 * The resolvers used to resolve absolute URI's. | 21 * The resolvers used to resolve absolute URI's. |
| 21 */ | 22 */ |
| 22 List<UriResolver> _resolvers; | 23 List<UriResolver> _resolvers; |
| 23 /** | 24 /** |
| 24 * A cache of content used to override the default content of a source. | 25 * A cache of content used to override the default content of a source. |
| 25 */ | 26 */ |
| 26 ContentCache _contentCache; | 27 ContentCache _contentCache; |
| 27 /** | 28 /** |
| 28 * Initialize a newly created source factory. | 29 * Initialize a newly created source factory. |
| 29 * @param contentCache the cache holding content used to override the default
content of a source. | 30 * @param contentCache the cache holding content used to override the default
content of a source |
| 30 * @param resolvers the resolvers used to resolve absolute URI's | 31 * @param resolvers the resolvers used to resolve absolute URI's |
| 31 */ | 32 */ |
| 32 SourceFactory.con1(ContentCache contentCache2, List<UriResolver> resolvers2) { | 33 SourceFactory.con1(ContentCache contentCache3, List<UriResolver> resolvers2) { |
| 33 _jtd_constructor_306_impl(contentCache2, resolvers2); | 34 _jtd_constructor_332_impl(contentCache3, resolvers2); |
| 34 } | 35 } |
| 35 _jtd_constructor_306_impl(ContentCache contentCache2, List<UriResolver> resolv
ers2) { | 36 _jtd_constructor_332_impl(ContentCache contentCache3, List<UriResolver> resolv
ers2) { |
| 36 this._contentCache = contentCache2; | 37 this._contentCache = contentCache3; |
| 37 this._resolvers = resolvers2; | 38 this._resolvers = resolvers2; |
| 38 } | 39 } |
| 39 /** | 40 /** |
| 40 * Initialize a newly created source factory. | 41 * Initialize a newly created source factory. |
| 41 * @param resolvers the resolvers used to resolve absolute URI's | 42 * @param resolvers the resolvers used to resolve absolute URI's |
| 42 */ | 43 */ |
| 43 SourceFactory.con2(List<UriResolver> resolvers) { | 44 SourceFactory.con2(List<UriResolver> resolvers) { |
| 44 _jtd_constructor_307_impl(resolvers); | 45 _jtd_constructor_333_impl(resolvers); |
| 45 } | 46 } |
| 46 _jtd_constructor_307_impl(List<UriResolver> resolvers) { | 47 _jtd_constructor_333_impl(List<UriResolver> resolvers) { |
| 47 _jtd_constructor_306_impl(new ContentCache(), resolvers); | 48 _jtd_constructor_332_impl(new ContentCache(), resolvers); |
| 48 } | 49 } |
| 49 /** | 50 /** |
| 50 * Return a source object representing the given absolute URI, or {@code null}
if the URI is not a | 51 * Return a source object representing the given absolute URI, or {@code null}
if the URI is not a |
| 51 * valid URI or if it is not an absolute URI. | 52 * valid URI or if it is not an absolute URI. |
| 52 * @param absoluteUri the absolute URI to be resolved | 53 * @param absoluteUri the absolute URI to be resolved |
| 53 * @return a source object representing the absolute URI | 54 * @return a source object representing the absolute URI |
| 54 */ | 55 */ |
| 55 Source forUri(String absoluteUri) { | 56 Source forUri(String absoluteUri) { |
| 56 try { | 57 try { |
| 57 Uri uri = new Uri(absoluteUri); | 58 Uri uri = new Uri(absoluteUri); |
| 58 if (uri.isAbsolute) { | 59 if (uri.isAbsolute) { |
| 59 return resolveUri2(null, uri); | 60 return resolveUri2(null, uri); |
| 60 } | 61 } |
| 61 } on URISyntaxException catch (exception) { | 62 } on URISyntaxException catch (exception) { |
| 62 } | 63 } |
| 63 return null; | 64 return null; |
| 64 } | 65 } |
| 65 /** | 66 /** |
| 66 * Return a source object that is equal to the source object used to obtain th
e given encoding, or{@code null} if the argument is not a valid encoding. | 67 * Return a source object that is equal to the source object used to obtain th
e given encoding, or{@code null} if the argument is not a valid encoding. |
| 67 * @param encoding the encoding of a source object | 68 * @param encoding the encoding of a source object |
| 68 * @return a source object that is described by the given encoding | 69 * @return a source object that is described by the given encoding |
| 69 * @see Source#getEncoding() | 70 * @see Source#getEncoding() |
| 70 */ | 71 */ |
| 71 Source fromEncoding(String encoding) => forUri(encoding); | 72 Source fromEncoding(String encoding) => forUri(encoding); |
| 72 /** | 73 /** |
| 74 * Return a cache of content used to override the default content of a source. |
| 75 * @return a cache of content used to override the default content of a source |
| 76 */ |
| 77 ContentCache get contentCache => _contentCache; |
| 78 /** |
| 73 * Return the analysis context that this source factory is associated with. | 79 * Return the analysis context that this source factory is associated with. |
| 74 * @return the analysis context that this source factory is associated with | 80 * @return the analysis context that this source factory is associated with |
| 75 */ | 81 */ |
| 76 AnalysisContext get context => _context; | 82 AnalysisContext get context => _context; |
| 77 /** | 83 /** |
| 84 * Return the {@link DartSdk} associated with this {@link SourceFactory}, or {
@code null} if there |
| 85 * is no such SDK. |
| 86 * @return the {@link DartSdk} associated with this {@link SourceFactory}, or
{@code null} if |
| 87 * there is no such SDK |
| 88 */ |
| 89 DartSdk get dartSdk { |
| 90 for (UriResolver resolver in _resolvers) { |
| 91 if (resolver is DartUriResolver) { |
| 92 DartUriResolver dartUriResolver = resolver as DartUriResolver; |
| 93 return dartUriResolver.dartSdk; |
| 94 } |
| 95 } |
| 96 return null; |
| 97 } |
| 98 /** |
| 78 * Return a source object representing the URI that results from resolving the
given (possibly | 99 * Return a source object representing the URI that results from resolving the
given (possibly |
| 79 * relative) contained URI against the URI associated with an existing source
object, or{@code null} if either the contained URI is invalid or if it cannot be
resolved against the | 100 * relative) contained URI against the URI associated with an existing source
object, or{@code null} if either the contained URI is invalid or if it cannot be
resolved against the |
| 80 * source object's URI. | 101 * source object's URI. |
| 81 * @param containingSource the source containing the given URI | 102 * @param containingSource the source containing the given URI |
| 82 * @param containedUri the (possibly relative) URI to be resolved against the
containing source | 103 * @param containedUri the (possibly relative) URI to be resolved against the
containing source |
| 83 * @return the source representing the contained URI | 104 * @return the source representing the contained URI |
| 84 */ | 105 */ |
| 85 Source resolveUri(Source containingSource, String containedUri) { | 106 Source resolveUri(Source containingSource, String containedUri) { |
| 86 try { | 107 try { |
| 87 return resolveUri2(containingSource, new Uri(containedUri)); | 108 return resolveUri2(containingSource, new Uri(containedUri)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 * Return a source object representing the URI that results from resolving the
given (possibly | 152 * Return a source object representing the URI that results from resolving the
given (possibly |
| 132 * relative) contained URI against the URI associated with an existing source
object, or{@code null} if either the contained URI is invalid or if it cannot be
resolved against the | 153 * relative) contained URI against the URI associated with an existing source
object, or{@code null} if either the contained URI is invalid or if it cannot be
resolved against the |
| 133 * source object's URI. | 154 * source object's URI. |
| 134 * @param containingSource the source containing the given URI | 155 * @param containingSource the source containing the given URI |
| 135 * @param containedUri the (possibly relative) URI to be resolved against the
containing source | 156 * @param containedUri the (possibly relative) URI to be resolved against the
containing source |
| 136 * @return the source representing the contained URI | 157 * @return the source representing the contained URI |
| 137 */ | 158 */ |
| 138 Source resolveUri2(Source containingSource, Uri containedUri) { | 159 Source resolveUri2(Source containingSource, Uri containedUri) { |
| 139 if (containedUri.isAbsolute) { | 160 if (containedUri.isAbsolute) { |
| 140 for (UriResolver resolver in _resolvers) { | 161 for (UriResolver resolver in _resolvers) { |
| 141 Source result = resolver.resolveAbsolute(this, containedUri); | 162 Source result = resolver.resolveAbsolute(_contentCache, containedUri); |
| 142 if (result != null) { | 163 if (result != null) { |
| 143 return result; | 164 return result; |
| 144 } | 165 } |
| 145 } | 166 } |
| 146 return null; | 167 return null; |
| 147 } else { | 168 } else { |
| 148 return containingSource.resolveRelative(containedUri); | 169 return containingSource.resolveRelative(containedUri); |
| 149 } | 170 } |
| 150 } | 171 } |
| 151 } | 172 } |
| 152 /** | 173 /** |
| 153 * The abstract class {@code UriResolver} defines the behavior of objects that a
re used to resolve | 174 * The abstract class {@code UriResolver} defines the behavior of objects that a
re used to resolve |
| 154 * URI's for a source factory. Subclasses of this class are expected to resolve
a single scheme of | 175 * URI's for a source factory. Subclasses of this class are expected to resolve
a single scheme of |
| 155 * absolute URI. | 176 * absolute URI. |
| 156 * @coverage dart.engine.source | 177 * @coverage dart.engine.source |
| 157 */ | 178 */ |
| 158 abstract class UriResolver { | 179 abstract class UriResolver { |
| 159 /** | 180 /** |
| 160 * Initialize a newly created resolver. | 181 * Initialize a newly created resolver. |
| 161 */ | 182 */ |
| 162 UriResolver() : super() { | 183 UriResolver() : super() { |
| 163 } | 184 } |
| 164 /** | 185 /** |
| 165 * Resolve the given absolute URI. Return a {@link Source source} representing
the file to which | 186 * Resolve the given absolute URI. Return a {@link Source source} representing
the file to which |
| 166 * it was resolved, or {@code null} if it could not be resolved. | 187 * it was resolved, or {@code null} if it could not be resolved. |
| 188 * @param contentCache the content cache used to access the contents of the re
turned source |
| 167 * @param uri the URI to be resolved | 189 * @param uri the URI to be resolved |
| 168 * @return a {@link Source source} representing the URI to which given URI was
resolved | 190 * @return a {@link Source source} representing the URI to which given URI was
resolved |
| 169 */ | 191 */ |
| 170 Source resolveAbsolute(SourceFactory factory, Uri uri); | 192 Source resolveAbsolute(ContentCache contentCache, Uri uri); |
| 171 } | 193 } |
| 172 /** | 194 /** |
| 173 * The interface {@code Source} defines the behavior of objects representing sou
rce code that can be | 195 * The interface {@code Source} defines the behavior of objects representing sou
rce code that can be |
| 174 * compiled. | 196 * compiled. |
| 175 * @coverage dart.engine.source | 197 * @coverage dart.engine.source |
| 176 */ | 198 */ |
| 177 abstract class Source { | 199 abstract class Source { |
| 178 /** | 200 /** |
| 179 * An empty array of sources. | 201 * An empty array of sources. |
| 180 */ | 202 */ |
| 181 static List<Source> EMPTY_ARRAY = new List<Source>(0); | 203 static List<Source> EMPTY_ARRAY = new List<Source>(0); |
| 182 /** | 204 /** |
| 183 * Return {@code true} if the given object is a source that represents the sam
e source code as | 205 * Return {@code true} if the given object is a source that represents the sam
e source code as |
| 184 * this source. | 206 * this source. |
| 185 * @param object the object to be compared with this object | 207 * @param object the object to be compared with this object |
| 186 * @return {@code true} if the given object is a source that represents the sa
me source code as | 208 * @return {@code true} if the given object is a source that represents the sa
me source code as |
| 187 * this source | 209 * this source |
| 188 * @see Object#equals(Object) | 210 * @see Object#equals(Object) |
| 189 */ | 211 */ |
| 190 bool operator ==(Object object); | 212 bool operator ==(Object object); |
| 191 /** | 213 /** |
| 192 * Return {@code true} if this source exists. | 214 * Return {@code true} if this source exists. |
| 193 * @return {@code true} if this source exists | 215 * @return {@code true} if this source exists |
| 194 */ | 216 */ |
| 195 bool exists(); | 217 bool exists(); |
| 196 /** | 218 /** |
| 197 * Return the analysis context in which this source is defined. | |
| 198 * @return the analysis context in which this source is defined | |
| 199 */ | |
| 200 AnalysisContext get context; | |
| 201 /** | |
| 202 * Get the contents of this source and pass it to the given receiver. Exactly
one of the methods | 219 * Get the contents of this source and pass it to the given receiver. Exactly
one of the methods |
| 203 * defined on the receiver will be invoked unless an exception is thrown. The
method that will be | 220 * defined on the receiver will be invoked unless an exception is thrown. The
method that will be |
| 204 * invoked depends on which of the possible representations of the contents is
the most efficient. | 221 * invoked depends on which of the possible representations of the contents is
the most efficient. |
| 205 * Whichever method is invoked, it will be invoked before this method returns. | 222 * Whichever method is invoked, it will be invoked before this method returns. |
| 206 * @param receiver the content receiver to which the content of this source wi
ll be passed | 223 * @param receiver the content receiver to which the content of this source wi
ll be passed |
| 207 * @throws Exception if the contents of this source could not be accessed | 224 * @throws Exception if the contents of this source could not be accessed |
| 208 */ | 225 */ |
| 209 void getContents(Source_ContentReceiver receiver); | 226 void getContents(Source_ContentReceiver receiver); |
| 210 /** | 227 /** |
| 211 * Return an encoded representation of this source that can be used to create
a source that is | 228 * Return an encoded representation of this source that can be used to create
a source that is |
| (...skipping 29 matching lines...) Expand all Loading... |
| 241 * @return a hash code for this source | 258 * @return a hash code for this source |
| 242 * @see Object#hashCode() | 259 * @see Object#hashCode() |
| 243 */ | 260 */ |
| 244 int get hashCode; | 261 int get hashCode; |
| 245 /** | 262 /** |
| 246 * Return {@code true} if this source is in one of the system libraries. | 263 * Return {@code true} if this source is in one of the system libraries. |
| 247 * @return {@code true} if this is in a system library | 264 * @return {@code true} if this is in a system library |
| 248 */ | 265 */ |
| 249 bool isInSystemLibrary(); | 266 bool isInSystemLibrary(); |
| 250 /** | 267 /** |
| 251 * Resolve the given URI relative to the location of this source. | |
| 252 * @param uri the URI to be resolved against this source | |
| 253 * @return a source representing the resolved URI | |
| 254 */ | |
| 255 Source resolve(String uri); | |
| 256 /** | |
| 257 * Resolve the relative URI against the URI associated with this source object
. Return a{@link Source source} representing the URI to which it was resolved, o
r {@code null} if it | 268 * Resolve the relative URI against the URI associated with this source object
. Return a{@link Source source} representing the URI to which it was resolved, o
r {@code null} if it |
| 258 * could not be resolved. | 269 * could not be resolved. |
| 259 * <p> | 270 * <p> |
| 260 * Note: This method is not intended for public use, it is only visible out of
necessity. It is | 271 * Note: This method is not intended for public use, it is only visible out of
necessity. It is |
| 261 * only intended to be invoked by a {@link SourceFactory source factory}. Sour
ce factories will | 272 * only intended to be invoked by a {@link SourceFactory source factory}. Sour
ce factories will |
| 262 * only invoke this method if the URI is relative, so implementations of this
method are not | 273 * only invoke this method if the URI is relative, so implementations of this
method are not |
| 263 * required to, and generally do not, verify the argument. The result of invok
ing this method with | 274 * required to, and generally do not, verify the argument. The result of invok
ing this method with |
| 264 * an absolute URI is intentionally left unspecified. | 275 * an absolute URI is intentionally left unspecified. |
| 265 * @param relativeUri the relative URI to be resolved against the containing s
ource | 276 * @param relativeUri the relative URI to be resolved against the containing s
ource |
| 266 * @return a {@link Source source} representing the URI to which given URI was
resolved | 277 * @return a {@link Source source} representing the URI to which given URI was
resolved |
| 267 */ | 278 */ |
| 268 Source resolveRelative(Uri relativeUri); | 279 Source resolveRelative(Uri relativeUri); |
| 269 } | 280 } |
| 270 /** | 281 /** |
| 271 * The interface {@code ContentReceiver} defines the behavior of objects that ca
n receive the | 282 * The interface {@code ContentReceiver} defines the behavior of objects that ca
n receive the |
| 272 * content of a source. | 283 * content of a source. |
| 273 */ | 284 */ |
| 274 abstract class Source_ContentReceiver { | 285 abstract class Source_ContentReceiver { |
| 275 /** | 286 /** |
| 276 * Accept the contents of a source represented as a character buffer. | 287 * Accept the contents of a source represented as a character buffer. |
| 277 * @param contents the contents of the source | 288 * @param contents the contents of the source |
| 289 * @param modificationTime the time at which the contents were last set |
| 278 */ | 290 */ |
| 279 accept(CharBuffer contents); | 291 void accept(CharBuffer contents, int modificationTime); |
| 280 /** | 292 /** |
| 281 * Accept the contents of a source represented as a string. | 293 * Accept the contents of a source represented as a string. |
| 282 * @param contents the contents of the source | 294 * @param contents the contents of the source |
| 295 * @param modificationTime the time at which the contents were last set |
| 283 */ | 296 */ |
| 284 void accept2(String contents); | 297 void accept2(String contents, int modificationTime); |
| 285 } | 298 } |
| 286 /** | 299 /** |
| 287 * The enumeration {@code SourceKind} defines the different kinds of sources tha
t are known to the | 300 * The enumeration {@code SourceKind} defines the different kinds of sources tha
t are known to the |
| 288 * analysis engine. | 301 * analysis engine. |
| 289 * @coverage dart.engine.source | 302 * @coverage dart.engine.source |
| 290 */ | 303 */ |
| 291 class SourceKind { | 304 class SourceKind implements Comparable<SourceKind> { |
| 292 /** | 305 /** |
| 293 * A source containing HTML. The HTML might or might not contain Dart scripts. | 306 * A source containing HTML. The HTML might or might not contain Dart scripts. |
| 294 */ | 307 */ |
| 295 static final SourceKind HTML = new SourceKind('HTML', 0); | 308 static final SourceKind HTML = new SourceKind('HTML', 0); |
| 296 /** | 309 /** |
| 297 * A Dart compilation unit that is not a part of another library. Libraries mi
ght or might not | 310 * A Dart compilation unit that is not a part of another library. Libraries mi
ght or might not |
| 298 * contain any directives, including a library directive. | 311 * contain any directives, including a library directive. |
| 299 */ | 312 */ |
| 300 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1); | 313 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1); |
| 301 /** | 314 /** |
| 302 * A Dart compilation unit that is part of another library. Parts contain a pa
rt-of directive. | 315 * A Dart compilation unit that is part of another library. Parts contain a pa
rt-of directive. |
| 303 */ | 316 */ |
| 304 static final SourceKind PART = new SourceKind('PART', 2); | 317 static final SourceKind PART = new SourceKind('PART', 2); |
| 305 /** | 318 /** |
| 306 * An unknown kind of source. Used both when it is not possible to identify th
e kind of a source | 319 * An unknown kind of source. Used both when it is not possible to identify th
e kind of a source |
| 307 * and also when the kind of a source is not known without performing a comput
ation and the client | 320 * and also when the kind of a source is not known without performing a comput
ation and the client |
| 308 * does not want to spend the time to identify the kind. | 321 * does not want to spend the time to identify the kind. |
| 309 */ | 322 */ |
| 310 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3); | 323 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3); |
| 311 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN]; | 324 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN]; |
| 312 final String __name; | 325 final String __name; |
| 313 final int __ordinal; | 326 final int __ordinal; |
| 314 int get ordinal => __ordinal; | 327 int get ordinal => __ordinal; |
| 315 SourceKind(this.__name, this.__ordinal) { | 328 SourceKind(this.__name, this.__ordinal) { |
| 316 } | 329 } |
| 330 int compareTo(SourceKind other) => __ordinal - other.__ordinal; |
| 317 String toString() => __name; | 331 String toString() => __name; |
| 318 } | 332 } |
| 319 /** | 333 /** |
| 320 * A source range defines an {@link Element}'s source coordinates relative to it
s {@link Source}. | 334 * A source range defines an {@link Element}'s source coordinates relative to it
s {@link Source}. |
| 321 * @coverage dart.engine.utilities | 335 * @coverage dart.engine.utilities |
| 322 */ | 336 */ |
| 323 class SourceRange { | 337 class SourceRange { |
| 324 /** | 338 /** |
| 325 * The 0-based index of the first character of the source code for this elemen
t, relative to the | 339 * The 0-based index of the first character of the source code for this elemen
t, relative to the |
| 326 * source buffer in which this element is contained. | 340 * source buffer in which this element is contained. |
| 327 */ | 341 */ |
| 328 int _offset = 0; | 342 int _offset = 0; |
| 329 /** | 343 /** |
| 330 * The number of characters of the source code for this element, relative to t
he source buffer in | 344 * The number of characters of the source code for this element, relative to t
he source buffer in |
| 331 * which this element is contained. | 345 * which this element is contained. |
| 332 */ | 346 */ |
| 333 int _length = 0; | 347 int _length = 0; |
| 334 /** | 348 /** |
| 335 * Initialize a newly created source range using the given offset and the give
n length. | 349 * Initialize a newly created source range using the given offset and the give
n length. |
| 336 * @param offset the given offset | 350 * @param offset the given offset |
| 337 * @param length the given length | 351 * @param length the given length |
| 338 */ | 352 */ |
| 339 SourceRange(int offset, int length) { | 353 SourceRange(int offset, int length) { |
| 340 this._offset = offset; | 354 this._offset = offset; |
| 341 this._length = length; | 355 this._length = length; |
| 342 } | 356 } |
| 343 /** | 357 /** |
| 344 * @return <code>true</code> if <code>x</code> is in [offset, offset + length)
interval. | 358 * @return {@code true} if <code>x</code> is in [offset, offset + length) inte
rval. |
| 345 */ | 359 */ |
| 346 bool contains(int x) => _offset <= x && x < _offset + _length; | 360 bool contains(int x) => _offset <= x && x < _offset + _length; |
| 347 /** | 361 /** |
| 348 * @return <code>true</code> if <code>x</code> is in (offset, offset + length)
interval. | 362 * @return {@code true} if <code>x</code> is in (offset, offset + length) inte
rval. |
| 349 */ | 363 */ |
| 350 bool containsExclusive(int x) => _offset < x && x < _offset + _length; | 364 bool containsExclusive(int x) => _offset < x && x < _offset + _length; |
| 351 /** | 365 /** |
| 352 * @return <code>true</code> if <code>otherRange</code> covers this {@link Sou
rceRange}. | 366 * @return {@code true} if <code>otherRange</code> covers this {@link SourceRa
nge}. |
| 353 */ | 367 */ |
| 354 bool coveredBy(SourceRange otherRange) => otherRange.covers(this); | 368 bool coveredBy(SourceRange otherRange) => otherRange.covers(this); |
| 355 /** | 369 /** |
| 356 * @return <code>true</code> if this {@link SourceRange} covers <code>otherRan
ge</code>. | 370 * @return {@code true} if this {@link SourceRange} covers <code>otherRange</c
ode>. |
| 357 */ | 371 */ |
| 358 bool covers(SourceRange otherRange) => offset <= otherRange.offset && otherRan
ge.end <= end; | 372 bool covers(SourceRange otherRange) => offset <= otherRange.offset && otherRan
ge.end <= end; |
| 359 /** | 373 /** |
| 360 * @return <code>true</code> if this {@link SourceRange} ends in <code>otherRa
nge</code>. | 374 * @return {@code true} if this {@link SourceRange} ends in <code>otherRange</
code>. |
| 361 */ | 375 */ |
| 362 bool endsIn(SourceRange otherRange) { | 376 bool endsIn(SourceRange otherRange) { |
| 363 int thisEnd = end; | 377 int thisEnd = end; |
| 364 return otherRange.contains(thisEnd); | 378 return otherRange.contains(thisEnd); |
| 365 } | 379 } |
| 366 bool operator ==(Object obj) { | 380 bool operator ==(Object obj) { |
| 367 if (obj is! SourceRange) { | 381 if (obj is! SourceRange) { |
| 368 return false; | 382 return false; |
| 369 } | 383 } |
| 370 SourceRange sourceRange = obj as SourceRange; | 384 SourceRange sourceRange = obj as SourceRange; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 392 SourceRange getMoveEnd(int delta) => new SourceRange(_offset, _length + delta)
; | 406 SourceRange getMoveEnd(int delta) => new SourceRange(_offset, _length + delta)
; |
| 393 /** | 407 /** |
| 394 * Returns the 0-based index of the first character of the source code for thi
s element, relative | 408 * Returns the 0-based index of the first character of the source code for thi
s element, relative |
| 395 * to the source buffer in which this element is contained. | 409 * to the source buffer in which this element is contained. |
| 396 * @return the 0-based index of the first character of the source code for thi
s element, relative | 410 * @return the 0-based index of the first character of the source code for thi
s element, relative |
| 397 * to the source buffer in which this element is contained | 411 * to the source buffer in which this element is contained |
| 398 */ | 412 */ |
| 399 int get offset => _offset; | 413 int get offset => _offset; |
| 400 int get hashCode => 31 * _offset + _length; | 414 int get hashCode => 31 * _offset + _length; |
| 401 /** | 415 /** |
| 402 * @return <code>true</code> if this {@link SourceRange} intersects with given
. | 416 * @return {@code true} if this {@link SourceRange} intersects with given. |
| 403 */ | 417 */ |
| 404 bool intersects(SourceRange other) { | 418 bool intersects(SourceRange other) { |
| 405 if (other == null) { | 419 if (other == null) { |
| 406 return false; | 420 return false; |
| 407 } | 421 } |
| 408 if (end <= other.offset) { | 422 if (end <= other.offset) { |
| 409 return false; | 423 return false; |
| 410 } | 424 } |
| 411 if (offset >= other.end) { | 425 if (offset >= other.end) { |
| 412 return false; | 426 return false; |
| 413 } | 427 } |
| 414 return true; | 428 return true; |
| 415 } | 429 } |
| 416 /** | 430 /** |
| 417 * @return <code>true</code> if this {@link SourceRange} starts in <code>other
Range</code>. | 431 * @return {@code true} if this {@link SourceRange} starts in <code>otherRange
</code>. |
| 418 */ | 432 */ |
| 419 bool startsIn(SourceRange otherRange) => otherRange.contains(_offset); | 433 bool startsIn(SourceRange otherRange) => otherRange.contains(_offset); |
| 420 String toString() { | 434 String toString() { |
| 421 JavaStringBuilder builder = new JavaStringBuilder(); | 435 JavaStringBuilder builder = new JavaStringBuilder(); |
| 422 builder.append("[offset="); | 436 builder.append("[offset="); |
| 423 builder.append(_offset); | 437 builder.append(_offset); |
| 424 builder.append(", length="); | 438 builder.append(", length="); |
| 425 builder.append(_length); | 439 builder.append(_length); |
| 426 builder.append("]"); | 440 builder.append("]"); |
| 427 return builder.toString(); | 441 return builder.toString(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 438 */ | 452 */ |
| 439 abstract class SourceContainer { | 453 abstract class SourceContainer { |
| 440 /** | 454 /** |
| 441 * Determine if the specified source is part of the receiver's collection of s
ources. | 455 * Determine if the specified source is part of the receiver's collection of s
ources. |
| 442 * @param source the source in question | 456 * @param source the source in question |
| 443 * @return {@code true} if the receiver contains the source, else {@code false
} | 457 * @return {@code true} if the receiver contains the source, else {@code false
} |
| 444 */ | 458 */ |
| 445 bool contains(Source source); | 459 bool contains(Source source); |
| 446 } | 460 } |
| 447 /** | 461 /** |
| 462 * Instances of the class {@code DartUriResolver} resolve {@code dart} URI's. |
| 463 * @coverage dart.engine.source |
| 464 */ |
| 465 class DartUriResolver extends UriResolver { |
| 466 /** |
| 467 * The Dart SDK against which URI's are to be resolved. |
| 468 */ |
| 469 DartSdk _sdk; |
| 470 /** |
| 471 * The name of the {@code dart} scheme. |
| 472 */ |
| 473 static String _DART_SCHEME = "dart"; |
| 474 /** |
| 475 * Return {@code true} if the given URI is a {@code dart:} URI. |
| 476 * @param uri the URI being tested |
| 477 * @return {@code true} if the given URI is a {@code dart:} URI |
| 478 */ |
| 479 static bool isDartUri(Uri uri) => uri.scheme == _DART_SCHEME; |
| 480 /** |
| 481 * Initialize a newly created resolver to resolve Dart URI's against the given
platform within the |
| 482 * given Dart SDK. |
| 483 * @param sdk the Dart SDK against which URI's are to be resolved |
| 484 */ |
| 485 DartUriResolver(DartSdk sdk) { |
| 486 this._sdk = sdk; |
| 487 } |
| 488 /** |
| 489 * Return the {@link DartSdk} against which URIs are to be resolved. |
| 490 * @return the {@link DartSdk} against which URIs are to be resolved. |
| 491 */ |
| 492 DartSdk get dartSdk => _sdk; |
| 493 Source resolveAbsolute(ContentCache contentCache, Uri uri) { |
| 494 if (!isDartUri(uri)) { |
| 495 return null; |
| 496 } |
| 497 return _sdk.mapDartUri(contentCache, uri.toString()); |
| 498 } |
| 499 } |
| 500 /** |
| 448 * Instances of the class {@code LineInfo} encapsulate information about line an
d column information | 501 * Instances of the class {@code LineInfo} encapsulate information about line an
d column information |
| 449 * within a source file. | 502 * within a source file. |
| 450 * @coverage dart.engine.utilities | 503 * @coverage dart.engine.utilities |
| 451 */ | 504 */ |
| 452 class LineInfo { | 505 class LineInfo { |
| 453 /** | 506 /** |
| 454 * An array containing the offsets of the first character of each line in the
source code. | 507 * An array containing the offsets of the first character of each line in the
source code. |
| 455 */ | 508 */ |
| 456 List<int> _lineStarts; | 509 List<int> _lineStarts; |
| 457 /** | 510 /** |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 void setContents(Source source, String contents) { | 617 void setContents(Source source, String contents) { |
| 565 if (contents == null) { | 618 if (contents == null) { |
| 566 _contentMap.remove(source); | 619 _contentMap.remove(source); |
| 567 _stampMap.remove(source); | 620 _stampMap.remove(source); |
| 568 } else { | 621 } else { |
| 569 _contentMap[source] = contents; | 622 _contentMap[source] = contents; |
| 570 _stampMap[source] = JavaSystem.currentTimeMillis(); | 623 _stampMap[source] = JavaSystem.currentTimeMillis(); |
| 571 } | 624 } |
| 572 } | 625 } |
| 573 } | 626 } |
| OLD | NEW |