Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(366)

Side by Side Diff: pkg/analyzer_experimental/lib/src/generated/source.dart

Issue 14050010: New analyzer_experimental snapshot. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'sdk.dart' show DartSdk;
9 import 'engine.dart' show AnalysisContext; 9 import 'engine.dart' show AnalysisContext;
10 10
(...skipping 13 matching lines...) Expand all
24 /** 24 /**
25 * 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.
26 */ 26 */
27 ContentCache _contentCache; 27 ContentCache _contentCache;
28 /** 28 /**
29 * Initialize a newly created source factory. 29 * Initialize a newly created source factory.
30 * @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
31 * @param resolvers the resolvers used to resolve absolute URI's 31 * @param resolvers the resolvers used to resolve absolute URI's
32 */ 32 */
33 SourceFactory.con1(ContentCache contentCache2, List<UriResolver> resolvers2) { 33 SourceFactory.con1(ContentCache contentCache2, List<UriResolver> resolvers2) {
34 _jtd_constructor_332_impl(contentCache2, resolvers2); 34 _jtd_constructor_333_impl(contentCache2, resolvers2);
35 } 35 }
36 _jtd_constructor_332_impl(ContentCache contentCache2, List<UriResolver> resolv ers2) { 36 _jtd_constructor_333_impl(ContentCache contentCache2, List<UriResolver> resolv ers2) {
37 this._contentCache = contentCache2; 37 this._contentCache = contentCache2;
38 this._resolvers = resolvers2; 38 this._resolvers = resolvers2;
39 } 39 }
40 /** 40 /**
41 * Initialize a newly created source factory. 41 * Initialize a newly created source factory.
42 * @param resolvers the resolvers used to resolve absolute URI's 42 * @param resolvers the resolvers used to resolve absolute URI's
43 */ 43 */
44 SourceFactory.con2(List<UriResolver> resolvers) { 44 SourceFactory.con2(List<UriResolver> resolvers) {
45 _jtd_constructor_333_impl(resolvers); 45 _jtd_constructor_334_impl(resolvers);
46 } 46 }
47 _jtd_constructor_333_impl(List<UriResolver> resolvers) { 47 _jtd_constructor_334_impl(List<UriResolver> resolvers) {
48 _jtd_constructor_332_impl(new ContentCache(), resolvers); 48 _jtd_constructor_333_impl(new ContentCache(), resolvers);
49 } 49 }
50 /** 50 /**
51 * 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
52 * valid URI or if it is not an absolute URI. 52 * valid URI or if it is not an absolute URI.
53 * @param absoluteUri the absolute URI to be resolved 53 * @param absoluteUri the absolute URI to be resolved
54 * @return a source object representing the absolute URI 54 * @return a source object representing the absolute URI
55 */ 55 */
56 Source forUri(String absoluteUri) { 56 Source forUri(String absoluteUri) {
57 try { 57 try {
58 Uri uri = new Uri(absoluteUri); 58 Uri uri = new Uri(absoluteUri);
59 if (uri.isAbsolute) { 59 if (uri.isAbsolute) {
60 return resolveUri2(null, uri); 60 return resolveUri2(null, uri);
61 } 61 }
62 } on URISyntaxException catch (exception) { 62 } on URISyntaxException catch (exception) {
63 } 63 }
64 return null; 64 return null;
65 } 65 }
66 /** 66 /**
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 * Return a source object that is equal to the source object used to obtain th e given encoding.
68 * @param encoding the encoding of a source object 68 * @param encoding the encoding of a source object
69 * @return a source object that is described by the given encoding 69 * @return a source object that is described by the given encoding
70 * @throws IllegalArgumentException if the argument is not a valid encoding
70 * @see Source#getEncoding() 71 * @see Source#getEncoding()
71 */ 72 */
72 Source fromEncoding(String encoding) => forUri(encoding); 73 Source fromEncoding(String encoding) {
74 if (encoding.length < 2) {
75 throw new IllegalArgumentException("Invalid encoding length");
76 }
77 UriKind kind = UriKind.fromEncoding(encoding.codeUnitAt(0));
78 if (kind == null) {
79 throw new IllegalArgumentException("Invalid source kind in encoding: ${kin d}");
80 }
81 try {
82 Uri uri = new Uri(encoding.substring(1));
83 for (UriResolver resolver in _resolvers) {
84 Source result = resolver.fromEncoding(_contentCache, kind, uri);
85 if (result != null) {
86 return result;
87 }
88 }
89 throw new IllegalArgumentException("No resolver for kind: ${kind}");
90 } catch (exception) {
91 throw new IllegalArgumentException("Invalid URI in encoding");
92 }
93 }
73 /** 94 /**
74 * Return a cache of content used to override the default content of a source. 95 * 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 96 * @return a cache of content used to override the default content of a source
76 */ 97 */
77 ContentCache get contentCache => _contentCache; 98 ContentCache get contentCache => _contentCache;
78 /** 99 /**
79 * Return the analysis context that this source factory is associated with. 100 * Return the analysis context that this source factory is associated with.
80 * @return the analysis context that this source factory is associated with 101 * @return the analysis context that this source factory is associated with
81 */ 102 */
82 AnalysisContext get context => _context; 103 AnalysisContext get context => _context;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 * absolute URI. 197 * absolute URI.
177 * @coverage dart.engine.source 198 * @coverage dart.engine.source
178 */ 199 */
179 abstract class UriResolver { 200 abstract class UriResolver {
180 /** 201 /**
181 * Initialize a newly created resolver. 202 * Initialize a newly created resolver.
182 */ 203 */
183 UriResolver() : super() { 204 UriResolver() : super() {
184 } 205 }
185 /** 206 /**
207 * If this resolver should be used for URI's of the given kind, resolve the gi ven absolute URI.
208 * The URI does not need to have the scheme handled by this resolver if the ki nd matches. Return a{@link Source source} representing the file to which it was resolved, or {@code null} if it
209 * could not be resolved.
210 * @param contentCache the content cache used to access the contents of the re turned source
211 * @param kind the kind of URI that was originally resolved in order to produc e an encoding with
212 * the given URI
213 * @param uri the URI to be resolved
214 * @return a {@link Source source} representing the file to which given URI wa s resolved
215 */
216 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri);
217 /**
186 * Resolve the given absolute URI. Return a {@link Source source} representing the file to which 218 * Resolve the given absolute URI. Return a {@link Source source} representing the file to which
187 * it was resolved, or {@code null} if it could not be resolved. 219 * 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 220 * @param contentCache the content cache used to access the contents of the re turned source
189 * @param uri the URI to be resolved 221 * @param uri the URI to be resolved
190 * @return a {@link Source source} representing the URI to which given URI was resolved 222 * @return a {@link Source source} representing the file to which given URI wa s resolved
191 */ 223 */
192 Source resolveAbsolute(ContentCache contentCache, Uri uri); 224 Source resolveAbsolute(ContentCache contentCache, Uri uri);
193 } 225 }
194 /** 226 /**
195 * The interface {@code Source} defines the behavior of objects representing sou rce code that can be 227 * The interface {@code Source} defines the behavior of objects representing sou rce code that can be
196 * compiled. 228 * compiled.
197 * @coverage dart.engine.source 229 * @coverage dart.engine.source
198 */ 230 */
199 abstract class Source { 231 abstract class Source {
200 /** 232 /**
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 * @return the modification stamp for this source 279 * @return the modification stamp for this source
248 */ 280 */
249 int get modificationStamp; 281 int get modificationStamp;
250 /** 282 /**
251 * Return a short version of the name that can be displayed to the user to den ote this source. For 283 * Return a short version of the name that can be displayed to the user to den ote this source. For
252 * example, for a source representing a file this would typically be the name of the file. 284 * example, for a source representing a file this would typically be the name of the file.
253 * @return a name that can be displayed to the user to denote this source 285 * @return a name that can be displayed to the user to denote this source
254 */ 286 */
255 String get shortName; 287 String get shortName;
256 /** 288 /**
289 * Return the kind of URI from which this source was originally derived. If th is source was
290 * created from an absolute URI, then the returned kind will reflect the schem e of the absolute
291 * URI. If it was created from a relative URI, then the returned kind will be the same as the kind
292 * of the source against which the relative URI was resolved.
293 * @return the kind of URI from which this source was originally derived
294 */
295 UriKind get uriKind;
296 /**
257 * Return a hash code for this source. 297 * Return a hash code for this source.
258 * @return a hash code for this source 298 * @return a hash code for this source
259 * @see Object#hashCode() 299 * @see Object#hashCode()
260 */ 300 */
261 int get hashCode; 301 int get hashCode;
262 /** 302 /**
263 * Return {@code true} if this source is in one of the system libraries. 303 * Return {@code true} if this source is in one of the system libraries.
264 * @return {@code true} if this is in a system library 304 * @return {@code true} if this is in a system library
265 */ 305 */
266 bool isInSystemLibrary(); 306 bool isInSystemLibrary();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN]; 364 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN];
325 final String __name; 365 final String __name;
326 final int __ordinal; 366 final int __ordinal;
327 int get ordinal => __ordinal; 367 int get ordinal => __ordinal;
328 SourceKind(this.__name, this.__ordinal) { 368 SourceKind(this.__name, this.__ordinal) {
329 } 369 }
330 int compareTo(SourceKind other) => __ordinal - other.__ordinal; 370 int compareTo(SourceKind other) => __ordinal - other.__ordinal;
331 String toString() => __name; 371 String toString() => __name;
332 } 372 }
333 /** 373 /**
374 * The enumeration {@code UriKind} defines the different kinds of URI's that are known to the
375 * analysis engine. These are used to keep track of the kind of URI associated w ith a given source.
376 * @coverage dart.engine.source
377 */
378 class UriKind implements Comparable<UriKind> {
379 /**
380 * A 'dart:' URI.
381 */
382 static final UriKind DART_URI = new UriKind('DART_URI', 0, 0x64);
383 /**
384 * A 'file:' URI.
385 */
386 static final UriKind FILE_URI = new UriKind('FILE_URI', 1, 0x66);
387 /**
388 * A 'package:' URI.
389 */
390 static final UriKind PACKAGE_URI = new UriKind('PACKAGE_URI', 2, 0x70);
391 static final List<UriKind> values = [DART_URI, FILE_URI, PACKAGE_URI];
392 final String __name;
393 final int __ordinal;
394 int get ordinal => __ordinal;
395 /**
396 * The single character encoding used to identify this kind of URI.
397 */
398 int _encoding = 0;
399 /**
400 * Initialize a newly created URI kind to have the given encoding.
401 * @param encoding the single character encoding used to identify this kind of URI.
402 */
403 UriKind(this.__name, this.__ordinal, int encoding) {
404 this._encoding = encoding;
405 }
406 /**
407 * Return the URI kind represented by the given encoding, or {@code null} if t here is no kind with
408 * the given encoding.
409 * @param encoding the single character encoding used to identify the URI kind to be returned
410 * @return the URI kind represented by the given encoding
411 */
412 static UriKind fromEncoding(int encoding) {
413 while (true) {
414 if (encoding == 0x64) {
415 return DART_URI;
416 } else if (encoding == 0x66) {
417 return FILE_URI;
418 } else if (encoding == 0x70) {
419 return PACKAGE_URI;
420 }
421 break;
422 }
423 return null;
424 }
425 /**
426 * Return the single character encoding used to identify this kind of URI.
427 * @return the single character encoding used to identify this kind of URI
428 */
429 int get encoding => _encoding;
430 int compareTo(UriKind other) => __ordinal - other.__ordinal;
431 String toString() => __name;
432 }
433 /**
334 * A source range defines an {@link Element}'s source coordinates relative to it s {@link Source}. 434 * A source range defines an {@link Element}'s source coordinates relative to it s {@link Source}.
335 * @coverage dart.engine.utilities 435 * @coverage dart.engine.utilities
336 */ 436 */
337 class SourceRange { 437 class SourceRange {
338 /** 438 /**
339 * The 0-based index of the first character of the source code for this elemen t, relative to the 439 * The 0-based index of the first character of the source code for this elemen t, relative to the
340 * source buffer in which this element is contained. 440 * source buffer in which this element is contained.
341 */ 441 */
342 int _offset = 0; 442 int _offset = 0;
343 /** 443 /**
344 * The number of characters of the source code for this element, relative to t he source buffer in 444 * The number of characters of the source code for this element, relative to t he source buffer in
345 * which this element is contained. 445 * which this element is contained.
346 */ 446 */
347 int _length = 0; 447 int _length = 0;
348 /** 448 /**
349 * Initialize a newly created source range using the given offset and the give n length. 449 * Initialize a newly created source range using the given offset and the give n length.
350 * @param offset the given offset 450 * @param offset the given offset
351 * @param length the given length 451 * @param length the given length
352 */ 452 */
353 SourceRange(int offset, int length) { 453 SourceRange(int offset, int length) {
354 this._offset = offset; 454 this._offset = offset;
355 this._length = length; 455 this._length = length;
356 } 456 }
357 /** 457 /**
358 * @return {@code true} if <code>x</code> is in [offset, offset + length) inte rval. 458 * @return {@code true} if <code>x</code> is in [[offset, offset + length) int erval.
359 */ 459 */
360 bool contains(int x) => _offset <= x && x < _offset + _length; 460 bool contains(int x) => _offset <= x && x < _offset + _length;
361 /** 461 /**
362 * @return {@code true} if <code>x</code> is in (offset, offset + length) inte rval. 462 * @return {@code true} if <code>x</code> is in (offset, offset + length) inte rval.
363 */ 463 */
364 bool containsExclusive(int x) => _offset < x && x < _offset + _length; 464 bool containsExclusive(int x) => _offset < x && x < _offset + _length;
365 /** 465 /**
366 * @return {@code true} if <code>otherRange</code> covers this {@link SourceRa nge}. 466 * @return {@code true} if <code>otherRange</code> covers this {@link SourceRa nge}.
367 */ 467 */
368 bool coveredBy(SourceRange otherRange) => otherRange.covers(this); 468 bool coveredBy(SourceRange otherRange) => otherRange.covers(this);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 */ 578 */
479 static bool isDartUri(Uri uri) => uri.scheme == _DART_SCHEME; 579 static bool isDartUri(Uri uri) => uri.scheme == _DART_SCHEME;
480 /** 580 /**
481 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the 581 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
482 * given Dart SDK. 582 * given Dart SDK.
483 * @param sdk the Dart SDK against which URI's are to be resolved 583 * @param sdk the Dart SDK against which URI's are to be resolved
484 */ 584 */
485 DartUriResolver(DartSdk sdk) { 585 DartUriResolver(DartSdk sdk) {
486 this._sdk = sdk; 586 this._sdk = sdk;
487 } 587 }
588 Source fromEncoding(ContentCache contentCache, UriKind kind, Uri uri) {
589 if (identical(kind, UriKind.DART_URI)) {
590 return _sdk.fromEncoding(contentCache, kind, uri);
591 }
592 return null;
593 }
488 /** 594 /**
489 * Return the {@link DartSdk} against which URIs are to be resolved. 595 * Return the {@link DartSdk} against which URIs are to be resolved.
490 * @return the {@link DartSdk} against which URIs are to be resolved. 596 * @return the {@link DartSdk} against which URIs are to be resolved.
491 */ 597 */
492 DartSdk get dartSdk => _sdk; 598 DartSdk get dartSdk => _sdk;
493 Source resolveAbsolute(ContentCache contentCache, Uri uri) { 599 Source resolveAbsolute(ContentCache contentCache, Uri uri) {
494 if (!isDartUri(uri)) { 600 if (!isDartUri(uri)) {
495 return null; 601 return null;
496 } 602 }
497 return _sdk.mapDartUri(contentCache, uri.toString()); 603 return _sdk.mapDartUri(contentCache, uri.toString());
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 void setContents(Source source, String contents) { 723 void setContents(Source source, String contents) {
618 if (contents == null) { 724 if (contents == null) {
619 _contentMap.remove(source); 725 _contentMap.remove(source);
620 _stampMap.remove(source); 726 _stampMap.remove(source);
621 } else { 727 } else {
622 _contentMap[source] = contents; 728 _contentMap[source] = contents;
623 _stampMap[source] = JavaSystem.currentTimeMillis(); 729 _stampMap[source] = JavaSystem.currentTimeMillis();
624 } 730 }
625 } 731 }
626 } 732 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698