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

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

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

Powered by Google App Engine
This is Rietveld 408576698