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

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

Issue 214253002: Translate Java enums to Dart constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 // 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 'java_core.dart'; 10 import 'java_core.dart';
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 */ 62 */
63 class SourceFactory { 63 class SourceFactory {
64 /** 64 /**
65 * The analysis context that this source factory is associated with. 65 * The analysis context that this source factory is associated with.
66 */ 66 */
67 AnalysisContext context; 67 AnalysisContext context;
68 68
69 /** 69 /**
70 * The resolvers used to resolve absolute URI's. 70 * The resolvers used to resolve absolute URI's.
71 */ 71 */
72 List<UriResolver> _resolvers; 72 final List<UriResolver> _resolvers;
73 73
74 /** 74 /**
75 * The predicate to determine is [Source] is local. 75 * The predicate to determine is [Source] is local.
76 */ 76 */
77 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK; 77 LocalSourcePredicate _localSourcePredicate = LocalSourcePredicate.NOT_SDK;
78 78
79 /** 79 /**
80 * Initialize a newly created source factory. 80 * Initialize a newly created source factory.
81 * 81 *
82 * @param resolvers the resolvers used to resolve absolute URI's 82 * @param resolvers the resolvers used to resolve absolute URI's
83 */ 83 */
84 SourceFactory(List<UriResolver> resolvers) { 84 SourceFactory(this._resolvers);
85 this._resolvers = resolvers;
86 }
87 85
88 /** 86 /**
89 * Return a source object representing the given absolute URI, or `null` if th e URI is not a 87 * Return a source object representing the given absolute URI, or `null` if th e URI is not a
90 * valid URI or if it is not an absolute URI. 88 * valid URI or if it is not an absolute URI.
91 * 89 *
92 * @param absoluteUri the absolute URI to be resolved 90 * @param absoluteUri the absolute URI to be resolved
93 * @return a source object representing the absolute URI 91 * @return a source object representing the absolute URI
94 */ 92 */
95 Source forUri(String absoluteUri) { 93 Source forUri(String absoluteUri) {
96 try { 94 try {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 409 }
412 410
413 /** 411 /**
414 * The enumeration `SourceKind` defines the different kinds of sources that are known to the 412 * The enumeration `SourceKind` defines the different kinds of sources that are known to the
415 * analysis engine. 413 * analysis engine.
416 */ 414 */
417 class SourceKind extends Enum<SourceKind> { 415 class SourceKind extends Enum<SourceKind> {
418 /** 416 /**
419 * A source containing HTML. The HTML might or might not contain Dart scripts. 417 * A source containing HTML. The HTML might or might not contain Dart scripts.
420 */ 418 */
421 static final SourceKind HTML = new SourceKind('HTML', 0); 419 static const SourceKind HTML = const SourceKind('HTML', 0);
422 420
423 /** 421 /**
424 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not 422 * A Dart compilation unit that is not a part of another library. Libraries mi ght or might not
425 * contain any directives, including a library directive. 423 * contain any directives, including a library directive.
426 */ 424 */
427 static final SourceKind LIBRARY = new SourceKind('LIBRARY', 1); 425 static const SourceKind LIBRARY = const SourceKind('LIBRARY', 1);
428 426
429 /** 427 /**
430 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive. 428 * A Dart compilation unit that is part of another library. Parts contain a pa rt-of directive.
431 */ 429 */
432 static final SourceKind PART = new SourceKind('PART', 2); 430 static const SourceKind PART = const SourceKind('PART', 2);
433 431
434 /** 432 /**
435 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source 433 * An unknown kind of source. Used both when it is not possible to identify th e kind of a source
436 * and also when the kind of a source is not known without performing a comput ation and the client 434 * and also when the kind of a source is not known without performing a comput ation and the client
437 * does not want to spend the time to identify the kind. 435 * does not want to spend the time to identify the kind.
438 */ 436 */
439 static final SourceKind UNKNOWN = new SourceKind('UNKNOWN', 3); 437 static const SourceKind UNKNOWN = const SourceKind('UNKNOWN', 3);
440 438
441 static final List<SourceKind> values = [HTML, LIBRARY, PART, UNKNOWN]; 439 static const List<SourceKind> values = const [HTML, LIBRARY, PART, UNKNOWN];
442 440
443 SourceKind(String name, int ordinal) : super(name, ordinal); 441 const SourceKind(String name, int ordinal) : super(name, ordinal);
444 } 442 }
445 443
446 /** 444 /**
447 * The enumeration `UriKind` defines the different kinds of URI's that are known to the 445 * The enumeration `UriKind` defines the different kinds of URI's that are known to the
448 * analysis engine. These are used to keep track of the kind of URI associated w ith a given source. 446 * analysis engine. These are used to keep track of the kind of URI associated w ith a given source.
449 */ 447 */
450 class UriKind extends Enum<UriKind> { 448 class UriKind extends Enum<UriKind> {
451 /** 449 /**
452 * A 'dart:' URI. 450 * A 'dart:' URI.
453 */ 451 */
454 static final UriKind DART_URI = new UriKind('DART_URI', 0, 0x64); 452 static const UriKind DART_URI = const UriKind('DART_URI', 0, 0x64);
455 453
456 /** 454 /**
457 * A 'file:' URI. 455 * A 'file:' URI.
458 */ 456 */
459 static final UriKind FILE_URI = new UriKind('FILE_URI', 1, 0x66); 457 static const UriKind FILE_URI = const UriKind('FILE_URI', 1, 0x66);
460 458
461 /** 459 /**
462 * A 'package:' URI referencing source package itself. 460 * A 'package:' URI referencing source package itself.
463 */ 461 */
464 static final UriKind PACKAGE_SELF_URI = new UriKind('PACKAGE_SELF_URI', 2, 0x7 3); 462 static const UriKind PACKAGE_SELF_URI = const UriKind('PACKAGE_SELF_URI', 2, 0 x73);
465 463
466 /** 464 /**
467 * A 'package:' URI. 465 * A 'package:' URI.
468 */ 466 */
469 static final UriKind PACKAGE_URI = new UriKind('PACKAGE_URI', 3, 0x70); 467 static const UriKind PACKAGE_URI = const UriKind('PACKAGE_URI', 3, 0x70);
470 468
471 static final List<UriKind> values = [DART_URI, FILE_URI, PACKAGE_SELF_URI, PAC KAGE_URI]; 469 static const List<UriKind> values = const [DART_URI, FILE_URI, PACKAGE_SELF_UR I, PACKAGE_URI];
472 470
473 /** 471 /**
474 * Return the URI kind represented by the given encoding, or `null` if there i s no kind with 472 * Return the URI kind represented by the given encoding, or `null` if there i s no kind with
475 * the given encoding. 473 * the given encoding.
476 * 474 *
477 * @param encoding the single character encoding used to identify the URI kind to be returned 475 * @param encoding the single character encoding used to identify the URI kind to be returned
478 * @return the URI kind represented by the given encoding 476 * @return the URI kind represented by the given encoding
479 */ 477 */
480 static UriKind fromEncoding(int encoding) { 478 static UriKind fromEncoding(int encoding) {
481 while (true) { 479 while (true) {
482 if (encoding == 0x64) { 480 if (encoding == 0x64) {
483 return DART_URI; 481 return DART_URI;
484 } else if (encoding == 0x66) { 482 } else if (encoding == 0x66) {
485 return FILE_URI; 483 return FILE_URI;
486 } else if (encoding == 0x73) { 484 } else if (encoding == 0x73) {
487 return PACKAGE_SELF_URI; 485 return PACKAGE_SELF_URI;
488 } else if (encoding == 0x70) { 486 } else if (encoding == 0x70) {
489 return PACKAGE_URI; 487 return PACKAGE_URI;
490 } 488 }
491 break; 489 break;
492 } 490 }
493 return null; 491 return null;
494 } 492 }
495 493
496 /** 494 /**
497 * The single character encoding used to identify this kind of URI. 495 * The single character encoding used to identify this kind of URI.
498 */ 496 */
499 int encoding = 0; 497 final int encoding;
500 498
501 /** 499 /**
502 * Initialize a newly created URI kind to have the given encoding. 500 * Initialize a newly created URI kind to have the given encoding.
503 * 501 *
504 * @param encoding the single character encoding used to identify this kind of URI. 502 * @param encoding the single character encoding used to identify this kind of URI.
505 */ 503 */
506 UriKind(String name, int ordinal, int encoding) : super(name, ordinal) { 504 const UriKind(String name, int ordinal, this.encoding) : super(name, ordinal);
507 this.encoding = encoding;
508 }
509 } 505 }
510 506
511 /** 507 /**
512 * A source range defines an [Element]'s source coordinates relative to its [Sou rce]. 508 * A source range defines an [Element]'s source coordinates relative to its [Sou rce].
513 */ 509 */
514 class SourceRange { 510 class SourceRange {
515 /** 511 /**
516 * An empty [SourceRange] with offset `0` and length `0`. 512 * An empty [SourceRange] with offset `0` and length `0`.
517 */ 513 */
518 static SourceRange EMPTY = new SourceRange(0, 0); 514 static SourceRange EMPTY = new SourceRange(0, 0);
519 515
520 /** 516 /**
521 * The 0-based index of the first character of the source code for this elemen t, relative to the 517 * The 0-based index of the first character of the source code for this elemen t, relative to the
522 * source buffer in which this element is contained. 518 * source buffer in which this element is contained.
523 */ 519 */
524 int offset = 0; 520 final int offset;
525 521
526 /** 522 /**
527 * The number of characters of the source code for this element, relative to t he source buffer in 523 * The number of characters of the source code for this element, relative to t he source buffer in
528 * which this element is contained. 524 * which this element is contained.
529 */ 525 */
530 int length = 0; 526 final int length;
531 527
532 /** 528 /**
533 * Initialize a newly created source range using the given offset and the give n length. 529 * Initialize a newly created source range using the given offset and the give n length.
534 * 530 *
535 * @param offset the given offset 531 * @param offset the given offset
536 * @param length the given length 532 * @param length the given length
537 */ 533 */
538 SourceRange(int offset, int length) { 534 SourceRange(this.offset, this.length);
539 this.offset = offset;
540 this.length = length;
541 }
542 535
543 /** 536 /**
544 * @return `true` if <code>x</code> is in [offset, offset + length) interval. 537 * @return `true` if <code>x</code> is in [offset, offset + length) interval.
545 */ 538 */
546 bool contains(int x) => offset <= x && x < offset + length; 539 bool contains(int x) => offset <= x && x < offset + length;
547 540
548 /** 541 /**
549 * @return `true` if <code>x</code> is in (offset, offset + length) interval. 542 * @return `true` if <code>x</code> is in (offset, offset + length) interval.
550 */ 543 */
551 bool containsExclusive(int x) => offset < x && x < offset + length; 544 bool containsExclusive(int x) => offset < x && x < offset + length;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 * @return `true` if the receiver contains the source, else `false` 643 * @return `true` if the receiver contains the source, else `false`
651 */ 644 */
652 bool contains(Source source); 645 bool contains(Source source);
653 } 646 }
654 647
655 /** 648 /**
656 * Instances of the class `DartUriResolver` resolve `dart` URI's. 649 * Instances of the class `DartUriResolver` resolve `dart` URI's.
657 */ 650 */
658 class DartUriResolver extends UriResolver { 651 class DartUriResolver extends UriResolver {
659 /** 652 /**
653 * Return `true` if the given URI is a `dart-ext:` URI.
654 *
655 * @param uriContent the textual representation of the URI being tested
656 * @return `true` if the given URI is a `dart-ext:` URI
657 */
658 static bool isDartExtUri(String uriContent) => uriContent != null && uriConten t.startsWith(_DART_EXT_SCHEME);
659
660 /**
660 * The Dart SDK against which URI's are to be resolved. 661 * The Dart SDK against which URI's are to be resolved.
661 */ 662 */
662 DartSdk _sdk; 663 final DartSdk _sdk;
663 664
664 /** 665 /**
665 * The name of the `dart` scheme. 666 * The name of the `dart` scheme.
666 */ 667 */
667 static String _DART_SCHEME = "dart"; 668 static String _DART_SCHEME = "dart";
668 669
669 /** 670 /**
671 * The prefix of a URI using the dart-ext scheme to reference a native code li brary.
672 */
673 static String _DART_EXT_SCHEME = "dart-ext:";
674
675 /**
670 * Return `true` if the given URI is a `dart:` URI. 676 * Return `true` if the given URI is a `dart:` URI.
671 * 677 *
672 * @param uri the URI being tested 678 * @param uri the URI being tested
673 * @return `true` if the given URI is a `dart:` URI 679 * @return `true` if the given URI is a `dart:` URI
674 */ 680 */
675 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme; 681 static bool isDartUri(Uri uri) => _DART_SCHEME == uri.scheme;
676 682
677 /** 683 /**
678 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the 684 * Initialize a newly created resolver to resolve Dart URI's against the given platform within the
679 * given Dart SDK. 685 * given Dart SDK.
680 * 686 *
681 * @param sdk the Dart SDK against which URI's are to be resolved 687 * @param sdk the Dart SDK against which URI's are to be resolved
682 */ 688 */
683 DartUriResolver(DartSdk sdk) { 689 DartUriResolver(this._sdk);
684 this._sdk = sdk;
685 }
686 690
687 @override 691 @override
688 Source fromEncoding(UriKind kind, Uri uri) { 692 Source fromEncoding(UriKind kind, Uri uri) {
689 if (identical(kind, UriKind.DART_URI)) { 693 if (identical(kind, UriKind.DART_URI)) {
690 return _sdk.fromEncoding(kind, uri); 694 return _sdk.fromEncoding(kind, uri);
691 } 695 }
692 return null; 696 return null;
693 } 697 }
694 698
695 /** 699 /**
(...skipping 13 matching lines...) Expand all
709 } 713 }
710 714
711 /** 715 /**
712 * Instances of the class `LineInfo` encapsulate information about line and colu mn information 716 * Instances of the class `LineInfo` encapsulate information about line and colu mn information
713 * within a source file. 717 * within a source file.
714 */ 718 */
715 class LineInfo { 719 class LineInfo {
716 /** 720 /**
717 * An array containing the offsets of the first character of each line in the source code. 721 * An array containing the offsets of the first character of each line in the source code.
718 */ 722 */
719 List<int> _lineStarts; 723 final List<int> _lineStarts;
720 724
721 /** 725 /**
722 * Initialize a newly created set of line information to represent the data en coded in the given 726 * Initialize a newly created set of line information to represent the data en coded in the given
723 * array. 727 * array.
724 * 728 *
725 * @param lineStarts the offsets of the first character of each line in the so urce code 729 * @param lineStarts the offsets of the first character of each line in the so urce code
726 */ 730 */
727 LineInfo(List<int> lineStarts) { 731 LineInfo(this._lineStarts) {
728 if (lineStarts == null) { 732 if (_lineStarts == null) {
729 throw new IllegalArgumentException("lineStarts must be non-null"); 733 throw new IllegalArgumentException("lineStarts must be non-null");
730 } else if (lineStarts.length < 1) { 734 } else if (_lineStarts.length < 1) {
731 throw new IllegalArgumentException("lineStarts must be non-empty"); 735 throw new IllegalArgumentException("lineStarts must be non-empty");
732 } 736 }
733 this._lineStarts = lineStarts;
734 } 737 }
735 738
736 /** 739 /**
737 * Return the location information for the character at the given offset. 740 * Return the location information for the character at the given offset.
738 * 741 *
739 * @param offset the offset of the character for which location information is to be returned 742 * @param offset the offset of the character for which location information is to be returned
740 * @return the location information for the character at the given offset 743 * @return the location information for the character at the given offset
741 */ 744 */
742 LineInfo_Location getLocation(int offset) { 745 LineInfo_Location getLocation(int offset) {
743 int lineCount = _lineStarts.length; 746 int lineCount = _lineStarts.length;
744 for (int i = 1; i < lineCount; i++) { 747 for (int i = 1; i < lineCount; i++) {
745 if (offset < _lineStarts[i]) { 748 if (offset < _lineStarts[i]) {
746 return new LineInfo_Location(i, offset - _lineStarts[i - 1] + 1); 749 return new LineInfo_Location(i, offset - _lineStarts[i - 1] + 1);
747 } 750 }
748 } 751 }
749 return new LineInfo_Location(lineCount, offset - _lineStarts[lineCount - 1] + 1); 752 return new LineInfo_Location(lineCount, offset - _lineStarts[lineCount - 1] + 1);
750 } 753 }
751 } 754 }
752 755
753 /** 756 /**
754 * Instances of the class `Location` represent the location of a character as a line and 757 * Instances of the class `Location` represent the location of a character as a line and
755 * column pair. 758 * column pair.
756 */ 759 */
757 class LineInfo_Location { 760 class LineInfo_Location {
758 /** 761 /**
759 * The one-based index of the line containing the character. 762 * The one-based index of the line containing the character.
760 */ 763 */
761 int lineNumber = 0; 764 final int lineNumber;
762 765
763 /** 766 /**
764 * The one-based index of the column containing the character. 767 * The one-based index of the column containing the character.
765 */ 768 */
766 int columnNumber = 0; 769 final int columnNumber;
767 770
768 /** 771 /**
769 * Initialize a newly created location to represent the location of the charac ter at the given 772 * Initialize a newly created location to represent the location of the charac ter at the given
770 * line and column position. 773 * line and column position.
771 * 774 *
772 * @param lineNumber the one-based index of the line containing the character 775 * @param lineNumber the one-based index of the line containing the character
773 * @param columnNumber the one-based index of the column containing the charac ter 776 * @param columnNumber the one-based index of the column containing the charac ter
774 */ 777 */
775 LineInfo_Location(int lineNumber, int columnNumber) { 778 LineInfo_Location(this.lineNumber, this.columnNumber);
776 this.lineNumber = lineNumber;
777 this.columnNumber = columnNumber;
778 }
779 } 779 }
780 780
781 /** 781 /**
782 * Instances of class `ContentCache` hold content used to override the default c ontent of a 782 * Instances of class `ContentCache` hold content used to override the default c ontent of a
783 * [Source]. 783 * [Source].
784 */ 784 */
785 class ContentCache { 785 class ContentCache {
786 /** 786 /**
787 * A table mapping sources to the contents of those sources. This is used to o verride the default 787 * A table mapping sources to the contents of those sources. This is used to o verride the default
788 * contents of a source. 788 * contents of a source.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 int oldStamp = javaMapPut(_stampMap, source, newStamp); 837 int oldStamp = javaMapPut(_stampMap, source, newStamp);
838 // Occasionally, if this method is called in rapid succession, the timesta mps are equal. 838 // Occasionally, if this method is called in rapid succession, the timesta mps are equal.
839 // Guard against this by artificially incrementing the new timestamp 839 // Guard against this by artificially incrementing the new timestamp
840 if (newStamp == oldStamp) { 840 if (newStamp == oldStamp) {
841 _stampMap[source] = newStamp + 1; 841 _stampMap[source] = newStamp + 1;
842 } 842 }
843 return javaMapPut(_contentMap, source, contents); 843 return javaMapPut(_contentMap, source, contents);
844 } 844 }
845 } 845 }
846 } 846 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698