| 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; | 4 library engine; |
| 5 | 5 |
| 6 import 'dart:collection' show HasNextIterator; | 6 import 'dart:collection' show HasNextIterator; |
| 7 import 'dart:uri' show Uri; | 7 import 'dart:uri' show Uri; |
| 8 import 'java_core.dart'; | 8 import 'java_core.dart'; |
| 9 import 'java_engine.dart'; | 9 import 'java_engine.dart'; |
| 10 import 'instrumentation.dart'; | 10 import 'instrumentation.dart'; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 * proposed future state, such as the state after a refactoring. | 136 * proposed future state, such as the state after a refactoring. |
| 137 */ | 137 */ |
| 138 abstract class AnalysisContext { | 138 abstract class AnalysisContext { |
| 139 /** | 139 /** |
| 140 * Apply the changes specified by the given change set to this context. Any an
alysis results that | 140 * Apply the changes specified by the given change set to this context. Any an
alysis results that |
| 141 * have been invalidated by these changes will be removed. | 141 * have been invalidated by these changes will be removed. |
| 142 * @param changeSet a description of the changes that are to be applied | 142 * @param changeSet a description of the changes that are to be applied |
| 143 */ | 143 */ |
| 144 void applyChanges(ChangeSet changeSet); | 144 void applyChanges(ChangeSet changeSet); |
| 145 /** | 145 /** |
| 146 * Return the documentation comment for the given element as it appears in the
original source |
| 147 * (complete with the beginning and ending delimiters), or {@code null} if the
element does not |
| 148 * have a documentation comment associated with it. This can be a long-running
operation if the |
| 149 * information needed to access the comment is not cached. |
| 150 * @param element the element whose documentation comment is to be returned |
| 151 * @return the element's documentation comment |
| 152 * @throws AnalysisException if the documentation comment could not be determi
ned because the |
| 153 * analysis could not be performed |
| 154 */ |
| 155 String computeDocumentationComment(Element element); |
| 156 /** |
| 146 * Return an array containing all of the errors associated with the given sour
ce. If the errors | 157 * Return an array containing all of the errors associated with the given sour
ce. If the errors |
| 147 * are not already known then the source will be analyzed in order to determin
e the errors | 158 * are not already known then the source will be analyzed in order to determin
e the errors |
| 148 * associated with it. | 159 * associated with it. |
| 149 * @param source the source whose errors are to be returned | 160 * @param source the source whose errors are to be returned |
| 150 * @return all of the errors associated with the given source | 161 * @return all of the errors associated with the given source |
| 151 * @throws AnalysisException if the errors could not be determined because the
analysis could not | 162 * @throws AnalysisException if the errors could not be determined because the
analysis could not |
| 152 * be performed | 163 * be performed |
| 153 * @see #getErrors(Source) | 164 * @see #getErrors(Source) |
| 154 */ | 165 */ |
| 155 List<AnalysisError> computeErrors(Source source); | 166 List<AnalysisError> computeErrors(Source source); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 * Record that the specified source container has been removed. | 606 * Record that the specified source container has been removed. |
| 596 * @param container the source container that was removed | 607 * @param container the source container that was removed |
| 597 */ | 608 */ |
| 598 void removedContainer(SourceContainer container) { | 609 void removedContainer(SourceContainer container) { |
| 599 if (container != null) { | 610 if (container != null) { |
| 600 _removedContainers.add(container); | 611 _removedContainers.add(container); |
| 601 } | 612 } |
| 602 } | 613 } |
| 603 } | 614 } |
| 604 /** | 615 /** |
| 616 * The interface {@code DartEntry} defines the behavior of objects that maintain
the information |
| 617 * cached by an analysis context about an individual Dart file. |
| 618 * @coverage dart.engine |
| 619 */ |
| 620 abstract class DartEntry implements SourceEntry { |
| 621 /** |
| 622 * The data descriptor representing the library element for the library. This
data is only |
| 623 * available for Dart files that are the defining compilation unit of a librar
y. |
| 624 */ |
| 625 static DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<LibraryElem
ent>("DartEntry.ELEMENT"); |
| 626 /** |
| 627 * The data descriptor representing the list of included parts. This data is o
nly available for |
| 628 * Dart files that are the defining compilation unit of a library. |
| 629 */ |
| 630 static DataDescriptor<List<Source>> INCLUDED_PARTS = new DataDescriptor<List<S
ource>>("DartEntry.INCLUDED_PARTS"); |
| 631 /** |
| 632 * The data descriptor representing the client flag. This data is only availab
le for Dart files |
| 633 * that are the defining compilation unit of a library. |
| 634 */ |
| 635 static DataDescriptor<bool> IS_CLIENT = new DataDescriptor<bool>("DartEntry.IS
_CLIENT"); |
| 636 /** |
| 637 * The data descriptor representing the launchable flag. This data is only ava
ilable for Dart |
| 638 * files that are the defining compilation unit of a library. |
| 639 */ |
| 640 static DataDescriptor<bool> IS_LAUNCHABLE = new DataDescriptor<bool>("DartEntr
y.IS_LAUNCHABLE"); |
| 641 /** |
| 642 * The data descriptor representing the errors resulting from parsing the sour
ce. |
| 643 */ |
| 644 static DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescriptor<L
ist<AnalysisError>>("DartEntry.PARSE_ERRORS"); |
| 645 /** |
| 646 * The data descriptor representing the parsed AST structure. |
| 647 */ |
| 648 static DataDescriptor<CompilationUnit> PARSED_UNIT = new DataDescriptor<Compil
ationUnit>("DartEntry.PARSED_UNIT"); |
| 649 /** |
| 650 * The data descriptor representing the public namespace of the library. This
data is only |
| 651 * available for Dart files that are the defining compilation unit of a librar
y. |
| 652 */ |
| 653 static DataDescriptor<Namespace> PUBLIC_NAMESPACE = new DataDescriptor<Namespa
ce>("DartEntry.PUBLIC_NAMESPACE"); |
| 654 /** |
| 655 * The data descriptor representing the errors resulting from resolving the so
urce. |
| 656 */ |
| 657 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip
tor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS"); |
| 658 /** |
| 659 * The data descriptor representing the resolved AST structure. |
| 660 */ |
| 661 static DataDescriptor<CompilationUnit> RESOLVED_UNIT = new DataDescriptor<Comp
ilationUnit>("DartEntry.RESOLVED_UNIT"); |
| 662 /** |
| 663 * The data descriptor representing the source kind. |
| 664 */ |
| 665 static DataDescriptor<SourceKind> SOURCE_KIND = new DataDescriptor<SourceKind>
("DartEntry.SOURCE_KIND"); |
| 666 /** |
| 667 * Return all of the errors associated with the compilation unit that are curr
ently cached. |
| 668 * @return all of the errors associated with the compilation unit |
| 669 */ |
| 670 List<AnalysisError> get allErrors; |
| 671 /** |
| 672 * Return a valid parsed compilation unit, either an unresolved AST structure
or the result of |
| 673 * resolving the AST structure in the context of some library, or {@code null}
if there is no |
| 674 * parsed compilation unit available. |
| 675 * @return a valid parsed compilation unit |
| 676 */ |
| 677 CompilationUnit get anyParsedCompilationUnit; |
| 678 /** |
| 679 * Return the result of resolving the compilation unit as part of any library,
or {@code null} if |
| 680 * there is no cached resolved compilation unit. |
| 681 * @return any resolved compilation unit |
| 682 */ |
| 683 CompilationUnit get anyResolvedCompilationUnit; |
| 684 /** |
| 685 * Return the state of the data represented by the given descriptor in the con
text of the given |
| 686 * library. |
| 687 * @param descriptor the descriptor representing the data whose state is to be
returned |
| 688 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 689 * context for the data |
| 690 * @return the value of the data represented by the given descriptor and libra
ry |
| 691 */ |
| 692 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource); |
| 693 /** |
| 694 * Return the value of the data represented by the given descriptor in the con
text of the given |
| 695 * library, or {@code null} if the data represented by the descriptor is not i
n the cache. |
| 696 * @param descriptor the descriptor representing which data is to be returned |
| 697 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 698 * context for the data |
| 699 * @return the value of the data represented by the given descriptor and libra
ry |
| 700 */ |
| 701 Object getValue2(DataDescriptor descriptor, Source librarySource); |
| 702 DartEntryImpl get writableCopy; |
| 703 } |
| 704 /** |
| 705 * Instances of the class {@code DartEntryImpl} implement a {@link DartEntry}. |
| 706 * @coverage dart.engine |
| 707 */ |
| 708 class DartEntryImpl extends SourceEntryImpl implements DartEntry { |
| 709 /** |
| 710 * The state of the cached source kind. |
| 711 */ |
| 712 CacheState _sourceKindState = CacheState.INVALID; |
| 713 /** |
| 714 * The kind of this source. |
| 715 */ |
| 716 SourceKind _sourceKind = SourceKind.UNKNOWN; |
| 717 /** |
| 718 * The state of the cached parsed compilation unit. |
| 719 */ |
| 720 CacheState _parsedUnitState = CacheState.INVALID; |
| 721 /** |
| 722 * The parsed compilation unit, or {@code null} if the parsed compilation unit
is not currently |
| 723 * cached. |
| 724 */ |
| 725 CompilationUnit _parsedUnit; |
| 726 /** |
| 727 * The state of the cached parse errors. |
| 728 */ |
| 729 CacheState _parseErrorsState = CacheState.INVALID; |
| 730 /** |
| 731 * The errors produced while scanning and parsing the compilation unit, or {@c
ode null} if the |
| 732 * errors are not currently cached. |
| 733 */ |
| 734 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; |
| 735 /** |
| 736 * The state of the cached list of included parts. |
| 737 */ |
| 738 CacheState _includedPartsState = CacheState.INVALID; |
| 739 /** |
| 740 * The list of parts included in the library, or {@code null} if the list is n
ot currently cached. |
| 741 * The list will be empty if the Dart file is a part rather than a library. |
| 742 */ |
| 743 List<Source> _includedParts = Source.EMPTY_ARRAY; |
| 744 /** |
| 745 * The source for the defining compilation unit of the library that contains t
his unit, or{@code null} if this unit is contained in multiple libraries. (If th
is unit is the defining |
| 746 * compilation unit for it's library, then this will be the source for this un
it.) |
| 747 */ |
| 748 Source _librarySource; |
| 749 /** |
| 750 * The information known as a result of resolving this compilation unit as par
t of the library |
| 751 * that contains this unit, or {@code null} if this unit is contained in multi
ple libraries. |
| 752 */ |
| 753 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS
tate(); |
| 754 /** |
| 755 * A table mapping the sources of the libraries containing this compilation un
it to the |
| 756 * information known as a result of resolving this compilation unit as part of
the library, or{@code null} if this unit is contained in a single library. |
| 757 */ |
| 758 Map<Source, DartEntryImpl_ResolutionState> _resolutionMap; |
| 759 /** |
| 760 * The state of the cached library element. |
| 761 */ |
| 762 CacheState _elementState = CacheState.INVALID; |
| 763 /** |
| 764 * The element representing the library, or {@code null} if the element is not
currently cached. |
| 765 */ |
| 766 LibraryElement _element; |
| 767 /** |
| 768 * The state of the cached public namespace. |
| 769 */ |
| 770 CacheState _publicNamespaceState = CacheState.INVALID; |
| 771 /** |
| 772 * The public namespace of the library, or {@code null} if the namespace is no
t currently cached. |
| 773 */ |
| 774 Namespace _publicNamespace; |
| 775 /** |
| 776 * The state of the cached client/ server flag. |
| 777 */ |
| 778 CacheState _clientServerState = CacheState.INVALID; |
| 779 /** |
| 780 * The state of the cached launchable flag. |
| 781 */ |
| 782 CacheState _launchableState = CacheState.INVALID; |
| 783 /** |
| 784 * An integer holding bit masks such as {@link #LAUNCHABLE} and {@link #CLIENT
_CODE}. |
| 785 */ |
| 786 int _bitmask = 0; |
| 787 /** |
| 788 * Mask indicating that this library is launchable: that the file has a main m
ethod. |
| 789 */ |
| 790 static int _LAUNCHABLE = 1 << 1; |
| 791 /** |
| 792 * Mask indicating that the library is client code: that the library depends o
n the html library. |
| 793 * If the library is not "client code", then it is referenced as "server code"
. |
| 794 */ |
| 795 static int _CLIENT_CODE = 1 << 2; |
| 796 /** |
| 797 * Initialize a newly created cache entry to be empty. |
| 798 */ |
| 799 DartEntryImpl() : super() { |
| 800 } |
| 801 /** |
| 802 * Record the fact that we are about to parse the compilation unit by marking
the results of |
| 803 * parsing as being in progress. |
| 804 */ |
| 805 void aboutToParse() { |
| 806 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS); |
| 807 _parsedUnitState = CacheState.IN_PROCESS; |
| 808 _parseErrorsState = CacheState.IN_PROCESS; |
| 809 } |
| 810 List<AnalysisError> get allErrors { |
| 811 List<AnalysisError> errors = new List<AnalysisError>(); |
| 812 for (AnalysisError error in _parseErrors) { |
| 813 errors.add(error); |
| 814 } |
| 815 if (_resolutionMap == null) { |
| 816 for (AnalysisError error in _resolutionState._resolutionErrors) { |
| 817 errors.add(error); |
| 818 } |
| 819 } else { |
| 820 for (DartEntryImpl_ResolutionState state in _resolutionMap.values) { |
| 821 for (AnalysisError error in state._resolutionErrors) { |
| 822 errors.add(error); |
| 823 } |
| 824 } |
| 825 } |
| 826 if (errors.length == 0) { |
| 827 return AnalysisError.NO_ERRORS; |
| 828 } |
| 829 return new List.from(errors); |
| 830 } |
| 831 CompilationUnit get anyParsedCompilationUnit { |
| 832 if (identical(_parsedUnitState, CacheState.VALID)) { |
| 833 return _parsedUnit; |
| 834 } |
| 835 if (_resolutionMap == null) { |
| 836 return _resolutionState._resolvedUnit; |
| 837 } else { |
| 838 for (DartEntryImpl_ResolutionState state in _resolutionMap.values) { |
| 839 if (identical(state._resolvedUnitState, CacheState.VALID)) { |
| 840 return state._resolvedUnit; |
| 841 } |
| 842 } |
| 843 } |
| 844 return null; |
| 845 } |
| 846 CompilationUnit get anyResolvedCompilationUnit { |
| 847 for (DartEntryImpl_ResolutionState state in _resolutionMap.values) { |
| 848 if (identical(state._resolvedUnitState, CacheState.VALID)) { |
| 849 return state._resolvedUnit; |
| 850 } |
| 851 } |
| 852 return null; |
| 853 } |
| 854 SourceKind get kind => _sourceKind; |
| 855 CacheState getState(DataDescriptor<Object> descriptor) { |
| 856 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 857 return _elementState; |
| 858 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 859 return _includedPartsState; |
| 860 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 861 return _clientServerState; |
| 862 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 863 return _launchableState; |
| 864 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 865 return _parseErrorsState; |
| 866 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 867 return _parsedUnitState; |
| 868 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 869 return _publicNamespaceState; |
| 870 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 871 return _sourceKindState; |
| 872 } else { |
| 873 return super.getState(descriptor); |
| 874 } |
| 875 } |
| 876 CacheState getState2(DataDescriptor<Object> descriptor, Source librarySource)
{ |
| 877 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 878 if (_resolutionMap == null) { |
| 879 return _resolutionState._resolutionErrorsState; |
| 880 } else { |
| 881 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource]; |
| 882 if (state != null) { |
| 883 return state._resolutionErrorsState; |
| 884 } |
| 885 } |
| 886 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 887 if (_resolutionMap == null) { |
| 888 return _resolutionState._resolvedUnitState; |
| 889 } else { |
| 890 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource]; |
| 891 if (state != null) { |
| 892 return state._resolvedUnitState; |
| 893 } |
| 894 } |
| 895 } else { |
| 896 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 897 } |
| 898 return CacheState.INVALID; |
| 899 } |
| 900 Object getValue(DataDescriptor descriptor) { |
| 901 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 902 return _element as Object; |
| 903 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 904 return _includedParts as Object; |
| 905 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 906 return ((_bitmask & _CLIENT_CODE) != 0 ? true : false) as Object; |
| 907 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 908 return ((_bitmask & _LAUNCHABLE) != 0 ? true : false) as Object; |
| 909 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 910 return _parseErrors as Object; |
| 911 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 912 return _parsedUnit as Object; |
| 913 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 914 return _publicNamespace as Object; |
| 915 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 916 return _sourceKind as Object; |
| 917 } |
| 918 return super.getValue(descriptor); |
| 919 } |
| 920 Object getValue2(DataDescriptor descriptor, Source librarySource2) { |
| 921 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 922 if (_resolutionMap == null) { |
| 923 if (librarySource2 == this._librarySource) { |
| 924 return _resolutionState._resolutionErrors as Object; |
| 925 } else { |
| 926 return AnalysisError.NO_ERRORS as Object; |
| 927 } |
| 928 } else { |
| 929 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2]; |
| 930 if (state != null) { |
| 931 return state._resolutionErrors as Object; |
| 932 } |
| 933 } |
| 934 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 935 if (_resolutionMap == null) { |
| 936 if (librarySource2 == this._librarySource) { |
| 937 return _resolutionState._resolvedUnit as Object; |
| 938 } else { |
| 939 return null; |
| 940 } |
| 941 } else { |
| 942 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2]; |
| 943 if (state != null) { |
| 944 return state._resolvedUnit as Object; |
| 945 } |
| 946 } |
| 947 } else { |
| 948 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 949 } |
| 950 return null; |
| 951 } |
| 952 DartEntryImpl get writableCopy { |
| 953 DartEntryImpl copy = new DartEntryImpl(); |
| 954 copy.copyFrom(this); |
| 955 return copy; |
| 956 } |
| 957 /** |
| 958 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 959 */ |
| 960 void invalidateAllResolutionInformation() { |
| 961 if (_resolutionMap == null) { |
| 962 _resolutionState.invalidateAllResolutionInformation(); |
| 963 } else { |
| 964 for (DartEntryImpl_ResolutionState state in _resolutionMap.values) { |
| 965 state.invalidateAllResolutionInformation(); |
| 966 } |
| 967 } |
| 968 _elementState = CacheState.INVALID; |
| 969 _element = null; |
| 970 _publicNamespaceState = CacheState.INVALID; |
| 971 _publicNamespace = null; |
| 972 _launchableState = CacheState.INVALID; |
| 973 _clientServerState = CacheState.INVALID; |
| 974 _bitmask = 0; |
| 975 } |
| 976 /** |
| 977 * Remove any resolution information associated with this compilation unit bei
ng part of the given |
| 978 * library, presumably because it is no longer part of the library. |
| 979 * @param librarySource the source of the defining compilation unit of the lib
rary that used to |
| 980 * contain this part but no longer does |
| 981 */ |
| 982 void removeResolution(Source librarySource2) { |
| 983 if (_resolutionMap == null) { |
| 984 if (librarySource2 == this._librarySource) { |
| 985 _resolutionState.invalidateAllResolutionInformation(); |
| 986 this._librarySource = null; |
| 987 } |
| 988 } else { |
| 989 _resolutionMap.remove(librarySource2); |
| 990 if (_resolutionMap.length == 1) { |
| 991 MapEntry<Source, DartEntryImpl_ResolutionState> entry = new JavaIterator
(getMapEntrySet(_resolutionMap)).next(); |
| 992 this._librarySource = entry.getKey(); |
| 993 _resolutionState = entry.getValue(); |
| 994 _resolutionMap = null; |
| 995 } |
| 996 } |
| 997 } |
| 998 /** |
| 999 * Set the results of parsing the compilation unit at the given time to the gi
ven values. |
| 1000 * @param modificationStamp the earliest time at which the source was last mod
ified before the |
| 1001 * parsing was started |
| 1002 * @param lineInfo the line information resulting from parsing the compilation
unit |
| 1003 * @param unit the AST structure resulting from parsing the compilation unit |
| 1004 * @param errors the parse errors resulting from parsing the compilation unit |
| 1005 */ |
| 1006 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit
unit, List<AnalysisError> errors) { |
| 1007 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { |
| 1008 setValue(SourceEntry.LINE_INFO, lineInfo); |
| 1009 } |
| 1010 if (_parsedUnitState != CacheState.VALID) { |
| 1011 _parsedUnit = unit; |
| 1012 } |
| 1013 if (_parseErrorsState != CacheState.VALID) { |
| 1014 _parseErrors = errors == null ? AnalysisError.NO_ERRORS : errors; |
| 1015 } |
| 1016 } |
| 1017 void setState(DataDescriptor<Object> descriptor, CacheState state) { |
| 1018 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 1019 _element = updatedValue(state, _element, null); |
| 1020 _elementState = state; |
| 1021 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 1022 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); |
| 1023 _includedPartsState = state; |
| 1024 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 1025 _bitmask = updatedValue2(state, _bitmask, _CLIENT_CODE); |
| 1026 _clientServerState = state; |
| 1027 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 1028 _bitmask = updatedValue2(state, _bitmask, _LAUNCHABLE); |
| 1029 _launchableState = state; |
| 1030 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 1031 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); |
| 1032 _parseErrorsState = state; |
| 1033 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 1034 _parsedUnit = updatedValue(state, _parsedUnit, null); |
| 1035 _parsedUnitState = state; |
| 1036 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 1037 _publicNamespace = updatedValue(state, _publicNamespace, null); |
| 1038 _publicNamespaceState = state; |
| 1039 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 1040 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN); |
| 1041 _sourceKindState = state; |
| 1042 } else { |
| 1043 super.setState(descriptor, state); |
| 1044 } |
| 1045 } |
| 1046 /** |
| 1047 * Set the state of the data represented by the given descriptor in the contex
t of the given |
| 1048 * library to the given state. |
| 1049 * @param descriptor the descriptor representing the data whose state is to be
set |
| 1050 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 1051 * context for the data |
| 1052 * @param state the new state of the data represented by the given descriptor |
| 1053 */ |
| 1054 void setState2(DataDescriptor<Object> descriptor, Source librarySource2, Cache
State state) { |
| 1055 if (_resolutionMap == null && this._librarySource != librarySource2) { |
| 1056 _resolutionMap = new Map<Source, DartEntryImpl_ResolutionState>(); |
| 1057 _resolutionMap[this._librarySource] = _resolutionState; |
| 1058 this._librarySource = null; |
| 1059 _resolutionState = null; |
| 1060 } |
| 1061 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1062 if (_resolutionMap == null) { |
| 1063 _resolutionState._resolutionErrors = updatedValue(state, _resolutionStat
e._resolutionErrors, AnalysisError.NO_ERRORS); |
| 1064 _resolutionState._resolutionErrorsState = state; |
| 1065 } else { |
| 1066 DartEntryImpl_ResolutionState resolutionState = _resolutionMap[librarySo
urce2]; |
| 1067 if (resolutionState == null) { |
| 1068 resolutionState = new DartEntryImpl_ResolutionState(); |
| 1069 _resolutionMap[librarySource2] = resolutionState; |
| 1070 } |
| 1071 resolutionState._resolutionErrors = updatedValue(state, resolutionState.
_resolutionErrors, AnalysisError.NO_ERRORS); |
| 1072 resolutionState._resolutionErrorsState = state; |
| 1073 } |
| 1074 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1075 if (_resolutionMap == null) { |
| 1076 _resolutionState._resolvedUnit = updatedValue(state, _resolutionState._r
esolvedUnit, null); |
| 1077 _resolutionState._resolvedUnitState = state; |
| 1078 } else { |
| 1079 DartEntryImpl_ResolutionState resolutionState = _resolutionMap[librarySo
urce2]; |
| 1080 if (resolutionState == null) { |
| 1081 resolutionState = new DartEntryImpl_ResolutionState(); |
| 1082 _resolutionMap[librarySource2] = resolutionState; |
| 1083 } |
| 1084 resolutionState._resolvedUnit = updatedValue(state, resolutionState._res
olvedUnit, null); |
| 1085 resolutionState._resolvedUnitState = state; |
| 1086 } |
| 1087 } else { |
| 1088 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1089 } |
| 1090 } |
| 1091 void setValue(DataDescriptor descriptor, Object value) { |
| 1092 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 1093 _element = value as LibraryElement; |
| 1094 _elementState = CacheState.VALID; |
| 1095 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 1096 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); |
| 1097 _includedPartsState = CacheState.VALID; |
| 1098 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 1099 if (((value as bool))) { |
| 1100 _bitmask |= _CLIENT_CODE; |
| 1101 } else { |
| 1102 _bitmask &= ~_CLIENT_CODE; |
| 1103 } |
| 1104 _clientServerState = CacheState.VALID; |
| 1105 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 1106 if (((value as bool))) { |
| 1107 _bitmask |= _LAUNCHABLE; |
| 1108 } else { |
| 1109 _bitmask &= ~_LAUNCHABLE; |
| 1110 } |
| 1111 _launchableState = CacheState.VALID; |
| 1112 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 1113 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); |
| 1114 _parseErrorsState = CacheState.VALID; |
| 1115 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 1116 _parsedUnit = value as CompilationUnit; |
| 1117 _parsedUnitState = CacheState.VALID; |
| 1118 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 1119 _publicNamespace = value as Namespace; |
| 1120 _publicNamespaceState = CacheState.VALID; |
| 1121 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 1122 _sourceKind = value as SourceKind; |
| 1123 _sourceKindState = CacheState.VALID; |
| 1124 } else { |
| 1125 super.setValue(descriptor, value); |
| 1126 } |
| 1127 } |
| 1128 /** |
| 1129 * Set the value of the data represented by the given descriptor in the contex
t of the given |
| 1130 * library to the given value, and set the state of that data to {@link CacheS
tate#VALID}. |
| 1131 * @param descriptor the descriptor representing which data is to have its val
ue set |
| 1132 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 1133 * context for the data |
| 1134 * @param value the new value of the data represented by the given descriptor
and library |
| 1135 */ |
| 1136 void setValue2(DataDescriptor descriptor, Source librarySource2, Object value)
{ |
| 1137 if (_resolutionMap == null) { |
| 1138 if (this._librarySource == null) { |
| 1139 this._librarySource = librarySource2; |
| 1140 } else if (librarySource2 != this._librarySource) { |
| 1141 _resolutionMap = new Map<Source, DartEntryImpl_ResolutionState>(); |
| 1142 _resolutionMap[this._librarySource] = _resolutionState; |
| 1143 this._librarySource = null; |
| 1144 _resolutionState = null; |
| 1145 } |
| 1146 } |
| 1147 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 1148 if (_resolutionMap == null) { |
| 1149 _resolutionState._resolutionErrors = value == null ? AnalysisError.NO_ER
RORS : (value as List<AnalysisError>); |
| 1150 _resolutionState._resolutionErrorsState = CacheState.VALID; |
| 1151 } else { |
| 1152 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2]; |
| 1153 if (state != null) { |
| 1154 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (v
alue as List<AnalysisError>); |
| 1155 state._resolutionErrorsState = CacheState.VALID; |
| 1156 } |
| 1157 } |
| 1158 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 1159 if (_resolutionMap == null) { |
| 1160 _resolutionState._resolvedUnit = value as CompilationUnit; |
| 1161 _resolutionState._resolvedUnitState = CacheState.VALID; |
| 1162 } else { |
| 1163 DartEntryImpl_ResolutionState state = _resolutionMap[librarySource2]; |
| 1164 if (state != null) { |
| 1165 state._resolvedUnit = value as CompilationUnit; |
| 1166 state._resolvedUnitState = CacheState.VALID; |
| 1167 } |
| 1168 } |
| 1169 } |
| 1170 } |
| 1171 void copyFrom(SourceEntryImpl entry) { |
| 1172 super.copyFrom(entry); |
| 1173 DartEntryImpl other = entry as DartEntryImpl; |
| 1174 _sourceKindState = other._sourceKindState; |
| 1175 _sourceKind = other._sourceKind; |
| 1176 _parsedUnitState = other._parsedUnitState; |
| 1177 _parsedUnit = other._parsedUnit; |
| 1178 _parseErrorsState = other._parseErrorsState; |
| 1179 _parseErrors = other._parseErrors; |
| 1180 _includedPartsState = other._includedPartsState; |
| 1181 _includedParts = other._includedParts; |
| 1182 if (other._resolutionMap == null) { |
| 1183 _librarySource = other._librarySource; |
| 1184 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionState
(); |
| 1185 newState.copyFrom(_resolutionState); |
| 1186 _resolutionState = newState; |
| 1187 } else { |
| 1188 _resolutionMap = new Map<Source, DartEntryImpl_ResolutionState>(); |
| 1189 for (MapEntry<Source, DartEntryImpl_ResolutionState> mapEntry in getMapEnt
rySet(other._resolutionMap)) { |
| 1190 DartEntryImpl_ResolutionState newState = new DartEntryImpl_ResolutionSta
te(); |
| 1191 newState.copyFrom(mapEntry.getValue()); |
| 1192 _resolutionMap[mapEntry.getKey()] = newState; |
| 1193 } |
| 1194 } |
| 1195 _elementState = other._elementState; |
| 1196 _element = other._element; |
| 1197 _publicNamespaceState = other._publicNamespaceState; |
| 1198 _publicNamespace = other._publicNamespace; |
| 1199 _clientServerState = other._clientServerState; |
| 1200 _launchableState = other._launchableState; |
| 1201 _bitmask = other._bitmask; |
| 1202 } |
| 1203 /** |
| 1204 * Given that one of the flags is being transitioned to the given state, retur
n the value of the |
| 1205 * flags that should be kept in the cache. |
| 1206 * @param state the state to which the data is being transitioned |
| 1207 * @param currentValue the value of the flags before the transition |
| 1208 * @param bitMask the mask used to access the bit whose state is being set |
| 1209 * @return the value of the data that should be kept in the cache |
| 1210 */ |
| 1211 int updatedValue2(CacheState state, int currentValue, int bitMask) { |
| 1212 if (identical(state, CacheState.VALID)) { |
| 1213 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 1214 } else if (identical(state, CacheState.IN_PROCESS)) { |
| 1215 return currentValue; |
| 1216 } |
| 1217 return currentValue &= ~bitMask; |
| 1218 } |
| 1219 } |
| 1220 /** |
| 1221 * Instances of the class {@code ResolutionState} represent the information prod
uced by resolving |
| 1222 * a compilation unit as part of a specific library. |
| 1223 */ |
| 1224 class DartEntryImpl_ResolutionState { |
| 1225 /** |
| 1226 * The state of the cached resolved compilation unit. |
| 1227 */ |
| 1228 CacheState _resolvedUnitState = CacheState.INVALID; |
| 1229 /** |
| 1230 * The resolved compilation unit, or {@code null} if the resolved compilation
unit is not |
| 1231 * currently cached. |
| 1232 */ |
| 1233 CompilationUnit _resolvedUnit; |
| 1234 /** |
| 1235 * The state of the cached resolution errors. |
| 1236 */ |
| 1237 CacheState _resolutionErrorsState = CacheState.INVALID; |
| 1238 /** |
| 1239 * The errors produced while resolving the compilation unit, or {@code null} i
f the errors are |
| 1240 * not currently cached. |
| 1241 */ |
| 1242 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1243 /** |
| 1244 * Initialize a newly created resolution state. |
| 1245 */ |
| 1246 DartEntryImpl_ResolutionState() : super() { |
| 1247 } |
| 1248 /** |
| 1249 * Set this state to be exactly like the given state. |
| 1250 * @param other the state to be copied |
| 1251 */ |
| 1252 void copyFrom(DartEntryImpl_ResolutionState other) { |
| 1253 _resolvedUnitState = other._resolvedUnitState; |
| 1254 _resolvedUnit = other._resolvedUnit; |
| 1255 _resolutionErrorsState = other._resolutionErrorsState; |
| 1256 _resolutionErrors = other._resolutionErrors; |
| 1257 } |
| 1258 /** |
| 1259 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 1260 */ |
| 1261 void invalidateAllResolutionInformation() { |
| 1262 _resolvedUnitState = CacheState.INVALID; |
| 1263 _resolvedUnit = null; |
| 1264 _resolutionErrorsState = CacheState.INVALID; |
| 1265 _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1266 } |
| 1267 } |
| 1268 /** |
| 1269 * Instances of the class {@code DataDescriptor} are immutable constants represe
nting data that can |
| 1270 * be stored in the cache. |
| 1271 */ |
| 1272 class DataDescriptor<E> { |
| 1273 /** |
| 1274 * The name of the descriptor, used for debugging purposes. |
| 1275 */ |
| 1276 String _name; |
| 1277 /** |
| 1278 * Initialize a newly created descriptor to have the given name. |
| 1279 * @param name the name of the descriptor |
| 1280 */ |
| 1281 DataDescriptor(String name) { |
| 1282 this._name = name; |
| 1283 } |
| 1284 String toString() => _name; |
| 1285 } |
| 1286 /** |
| 1287 * The interface {@code HtmlEntry} defines the behavior of objects that maintain
the information |
| 1288 * cached by an analysis context about an individual HTML file. |
| 1289 * @coverage dart.engine |
| 1290 */ |
| 1291 abstract class HtmlEntry implements SourceEntry { |
| 1292 /** |
| 1293 * The data descriptor representing the HTML element. |
| 1294 */ |
| 1295 static DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElement>("
HtmlEntry.ELEMENT"); |
| 1296 /** |
| 1297 * The data descriptor representing the parsed AST structure. |
| 1298 */ |
| 1299 static DataDescriptor<HtmlUnit> PARSED_UNIT = new DataDescriptor<HtmlUnit>("Ht
mlEntry.PARSED_UNIT"); |
| 1300 /** |
| 1301 * The data descriptor representing the list of referenced libraries. |
| 1302 */ |
| 1303 static DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescriptor<
List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); |
| 1304 /** |
| 1305 * The data descriptor representing the errors resulting from resolving the so
urce. |
| 1306 */ |
| 1307 static DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataDescrip
tor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); |
| 1308 /** |
| 1309 * The data descriptor representing the resolved AST structure. |
| 1310 */ |
| 1311 static DataDescriptor<HtmlUnit> RESOLVED_UNIT = new DataDescriptor<HtmlUnit>("
HtmlEntry.RESOLVED_UNIT"); |
| 1312 HtmlEntryImpl get writableCopy; |
| 1313 } |
| 1314 /** |
| 1315 * Instances of the class {@code HtmlEntryImpl} implement an {@link HtmlEntry}. |
| 1316 * @coverage dart.engine |
| 1317 */ |
| 1318 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { |
| 1319 /** |
| 1320 * The state of the cached parsed (but not resolved) HTML unit. |
| 1321 */ |
| 1322 CacheState _parsedUnitState = CacheState.INVALID; |
| 1323 /** |
| 1324 * The parsed HTML unit, or {@code null} if the parsed HTML unit is not curren
tly cached. |
| 1325 */ |
| 1326 HtmlUnit _parsedUnit; |
| 1327 /** |
| 1328 * The state of the cached resolution errors. |
| 1329 */ |
| 1330 CacheState _resolutionErrorsState = CacheState.INVALID; |
| 1331 /** |
| 1332 * The errors produced while resolving the compilation unit, or {@code null} i
f the errors are not |
| 1333 * currently cached. |
| 1334 */ |
| 1335 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 1336 /** |
| 1337 * The state of the cached parsed and resolved HTML unit. |
| 1338 */ |
| 1339 CacheState _resolvedUnitState = CacheState.INVALID; |
| 1340 /** |
| 1341 * The resolved HTML unit, or {@code null} if the resolved HTML unit is not cu
rrently cached. |
| 1342 */ |
| 1343 HtmlUnit _resolvedUnit; |
| 1344 /** |
| 1345 * The state of the cached list of referenced libraries. |
| 1346 */ |
| 1347 CacheState _referencedLibrariesState = CacheState.INVALID; |
| 1348 /** |
| 1349 * The list of libraries referenced in the HTML, or {@code null} if the list i
s not currently |
| 1350 * cached. Note that this list does not include libraries defined directly wit
hin the HTML file. |
| 1351 */ |
| 1352 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; |
| 1353 /** |
| 1354 * The state of the cached HTML element. |
| 1355 */ |
| 1356 CacheState _elementState = CacheState.INVALID; |
| 1357 /** |
| 1358 * The element representing the HTML file, or {@code null} if the element is n
ot currently cached. |
| 1359 */ |
| 1360 HtmlElement _element; |
| 1361 /** |
| 1362 * Initialize a newly created cache entry to be empty. |
| 1363 */ |
| 1364 HtmlEntryImpl() : super() { |
| 1365 } |
| 1366 SourceKind get kind => SourceKind.HTML; |
| 1367 CacheState getState(DataDescriptor<Object> descriptor) { |
| 1368 if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 1369 return _elementState; |
| 1370 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 1371 return _parsedUnitState; |
| 1372 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 1373 return _referencedLibrariesState; |
| 1374 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 1375 return _resolutionErrorsState; |
| 1376 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 1377 return _resolvedUnitState; |
| 1378 } |
| 1379 return super.getState(descriptor); |
| 1380 } |
| 1381 Object getValue(DataDescriptor descriptor) { |
| 1382 if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 1383 return _element as Object; |
| 1384 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 1385 return _parsedUnit as Object; |
| 1386 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 1387 return _referencedLibraries as Object; |
| 1388 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 1389 return _resolutionErrors as Object; |
| 1390 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 1391 return _resolvedUnit as Object; |
| 1392 } |
| 1393 return super.getValue(descriptor); |
| 1394 } |
| 1395 HtmlEntryImpl get writableCopy { |
| 1396 HtmlEntryImpl copy = new HtmlEntryImpl(); |
| 1397 copy.copyFrom(this); |
| 1398 return copy; |
| 1399 } |
| 1400 void setState(DataDescriptor<Object> descriptor, CacheState state) { |
| 1401 if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 1402 _element = updatedValue(state, _element, null); |
| 1403 _elementState = state; |
| 1404 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 1405 _parsedUnit = updatedValue(state, _parsedUnit, null); |
| 1406 _parsedUnitState = state; |
| 1407 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 1408 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM
PTY_ARRAY); |
| 1409 _referencedLibrariesState = state; |
| 1410 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 1411 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N
O_ERRORS); |
| 1412 _resolutionErrorsState = state; |
| 1413 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 1414 _resolvedUnit = updatedValue(state, _resolvedUnit, null); |
| 1415 _resolvedUnitState = state; |
| 1416 } else { |
| 1417 super.setState(descriptor, state); |
| 1418 } |
| 1419 } |
| 1420 void setValue(DataDescriptor descriptor, Object value) { |
| 1421 if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 1422 _element = value as HtmlElement; |
| 1423 _elementState = CacheState.VALID; |
| 1424 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 1425 _parsedUnit = value as HtmlUnit; |
| 1426 _parsedUnitState = CacheState.VALID; |
| 1427 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 1428 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List
<Source>); |
| 1429 _referencedLibrariesState = CacheState.VALID; |
| 1430 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 1431 _resolutionErrors = value as List<AnalysisError>; |
| 1432 _resolutionErrorsState = CacheState.VALID; |
| 1433 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 1434 _resolvedUnit = value as HtmlUnit; |
| 1435 _resolvedUnitState = CacheState.VALID; |
| 1436 } else { |
| 1437 super.setValue(descriptor, value); |
| 1438 } |
| 1439 } |
| 1440 void copyFrom(SourceEntryImpl entry) { |
| 1441 super.copyFrom(entry); |
| 1442 HtmlEntryImpl other = entry as HtmlEntryImpl; |
| 1443 _parsedUnitState = other._parsedUnitState; |
| 1444 _parsedUnit = other._parsedUnit; |
| 1445 _referencedLibrariesState = other._referencedLibrariesState; |
| 1446 _referencedLibraries = other._referencedLibraries; |
| 1447 _resolutionErrors = other._resolutionErrors; |
| 1448 _resolutionErrorsState = other._resolutionErrorsState; |
| 1449 _resolvedUnitState = other._resolvedUnitState; |
| 1450 _resolvedUnit = other._resolvedUnit; |
| 1451 _elementState = other._elementState; |
| 1452 _element = other._element; |
| 1453 } |
| 1454 } |
| 1455 /** |
| 1456 * The interface {@code SourceEntry} defines the behavior of objects that mainta
in the information |
| 1457 * cached by an analysis context about an individual source, no matter what kind
of source it is. |
| 1458 * <p> |
| 1459 * Source entries should be treated as if they were immutable unless a writable
copy of the entry |
| 1460 * has been obtained and has not yet been made visible to other threads. |
| 1461 * @coverage dart.engine |
| 1462 */ |
| 1463 abstract class SourceEntry { |
| 1464 /** |
| 1465 * The data descriptor representing the line information. |
| 1466 */ |
| 1467 static DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>("Sour
ceEntry.LINE_INFO"); |
| 1468 /** |
| 1469 * Return the kind of the source, or {@code null} if the kind is not currently
cached. |
| 1470 * @return the kind of the source |
| 1471 */ |
| 1472 SourceKind get kind; |
| 1473 /** |
| 1474 * Return the most recent time at which the state of the source matched the st
ate represented by |
| 1475 * this entry. |
| 1476 * @return the modification time of this entry |
| 1477 */ |
| 1478 int get modificationTime; |
| 1479 /** |
| 1480 * Return the state of the data represented by the given descriptor. |
| 1481 * @param descriptor the descriptor representing the data whose state is to be
returned |
| 1482 * @return the state of the data represented by the given descriptor |
| 1483 */ |
| 1484 CacheState getState(DataDescriptor<Object> descriptor); |
| 1485 /** |
| 1486 * Return the value of the data represented by the given descriptor, or {@code
null} if the data |
| 1487 * represented by the descriptor is not in the cache. |
| 1488 * @param descriptor the descriptor representing which data is to be returned |
| 1489 * @return the value of the data represented by the given descriptor |
| 1490 */ |
| 1491 Object getValue(DataDescriptor descriptor); |
| 1492 /** |
| 1493 * Return a new entry that is initialized to the same state as this entry but
that can be |
| 1494 * modified. |
| 1495 * @return a writable copy of this entry |
| 1496 */ |
| 1497 SourceEntryImpl get writableCopy; |
| 1498 } |
| 1499 /** |
| 1500 * Instances of the abstract class {@code SourceEntryImpl} implement the behavio
r common to all{@link SourceEntry source entries}. |
| 1501 * @coverage dart.engine |
| 1502 */ |
| 1503 abstract class SourceEntryImpl implements SourceEntry { |
| 1504 /** |
| 1505 * The most recent time at which the state of the source matched the state rep
resented by this |
| 1506 * entry. |
| 1507 */ |
| 1508 int _modificationTime = 0; |
| 1509 /** |
| 1510 * The state of the cached line information. |
| 1511 */ |
| 1512 CacheState _lineInfoState = CacheState.INVALID; |
| 1513 /** |
| 1514 * The line information computed for the source, or {@code null} if the line i
nformation is not |
| 1515 * currently cached. |
| 1516 */ |
| 1517 LineInfo _lineInfo; |
| 1518 /** |
| 1519 * Initialize a newly created cache entry to be empty. |
| 1520 */ |
| 1521 SourceEntryImpl() : super() { |
| 1522 } |
| 1523 int get modificationTime => _modificationTime; |
| 1524 CacheState getState(DataDescriptor<Object> descriptor) { |
| 1525 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 1526 return _lineInfoState; |
| 1527 } else { |
| 1528 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1529 } |
| 1530 } |
| 1531 Object getValue(DataDescriptor descriptor) { |
| 1532 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 1533 return _lineInfo as Object; |
| 1534 } else { |
| 1535 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1536 } |
| 1537 } |
| 1538 /** |
| 1539 * Set the most recent time at which the state of the source matched the state
represented by this |
| 1540 * entry to the given time. |
| 1541 * @param time the new modification time of this entry |
| 1542 */ |
| 1543 void set modificationTime(int time) { |
| 1544 _modificationTime = time; |
| 1545 } |
| 1546 /** |
| 1547 * Set the state of the data represented by the given descriptor to the given
state. |
| 1548 * @param descriptor the descriptor representing the data whose state is to be
set |
| 1549 * @param the new state of the data represented by the given descriptor |
| 1550 */ |
| 1551 void setState(DataDescriptor<Object> descriptor, CacheState state) { |
| 1552 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 1553 _lineInfo = updatedValue(state, _lineInfo, null); |
| 1554 _lineInfoState = state; |
| 1555 } else { |
| 1556 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1557 } |
| 1558 } |
| 1559 /** |
| 1560 * Set the value of the data represented by the given descriptor to the given
value. |
| 1561 * @param descriptor the descriptor representing the data whose value is to be
set |
| 1562 * @param value the new value of the data represented by the given descriptor |
| 1563 */ |
| 1564 void setValue(DataDescriptor descriptor, Object value) { |
| 1565 if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 1566 _lineInfo = value as LineInfo; |
| 1567 _lineInfoState = CacheState.VALID; |
| 1568 } else { |
| 1569 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1570 } |
| 1571 } |
| 1572 /** |
| 1573 * Copy the information from the given cache entry. |
| 1574 * @param entry the cache entry from which information will be copied |
| 1575 */ |
| 1576 void copyFrom(SourceEntryImpl entry) { |
| 1577 _modificationTime = entry._modificationTime; |
| 1578 _lineInfoState = entry._lineInfoState; |
| 1579 _lineInfo = entry._lineInfo; |
| 1580 } |
| 1581 /** |
| 1582 * Given that some data is being transitioned to the given state, return the v
alue that should be |
| 1583 * kept in the cache. |
| 1584 * @param state the state to which the data is being transitioned |
| 1585 * @param currentValue the value of the data before the transition |
| 1586 * @param defaultValue the value to be used if the current value is to be remo
ved from the cache |
| 1587 * @return the value of the data that should be kept in the cache |
| 1588 */ |
| 1589 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { |
| 1590 if (identical(state, CacheState.VALID)) { |
| 1591 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 1592 } else if (identical(state, CacheState.IN_PROCESS)) { |
| 1593 return currentValue; |
| 1594 } |
| 1595 return defaultValue; |
| 1596 } |
| 1597 } |
| 1598 /** |
| 605 * Instances of the class {@code AnalysisContextImpl} implement an {@link Analys
isContext analysis | 1599 * Instances of the class {@code AnalysisContextImpl} implement an {@link Analys
isContext analysis |
| 606 * context}. | 1600 * context}. |
| 607 * @coverage dart.engine | 1601 * @coverage dart.engine |
| 608 */ | 1602 */ |
| 609 class AnalysisContextImpl implements InternalAnalysisContext { | 1603 class AnalysisContextImpl implements InternalAnalysisContext { |
| 610 /** | 1604 /** |
| 611 * The source factory used to create the sources that can be analyzed in this
context. | 1605 * The source factory used to create the sources that can be analyzed in this
context. |
| 612 */ | 1606 */ |
| 613 SourceFactory _sourceFactory; | 1607 SourceFactory _sourceFactory; |
| 614 /** | 1608 /** |
| 615 * A table mapping the sources known to the context to the information known a
bout the source. | 1609 * A table mapping the sources known to the context to the information known a
bout the source. |
| 616 */ | 1610 */ |
| 617 Map<Source, SourceInfo> _sourceMap = new Map<Source, SourceInfo>(); | 1611 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); |
| 618 /** | 1612 /** |
| 619 * A table mapping sources to the change notices that are waiting to be return
ed related to that | 1613 * A table mapping sources to the change notices that are waiting to be return
ed related to that |
| 620 * source. | 1614 * source. |
| 621 */ | 1615 */ |
| 622 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); | 1616 Map<Source, ChangeNoticeImpl> _pendingNotices = new Map<Source, ChangeNoticeIm
pl>(); |
| 623 /** | 1617 /** |
| 624 * A list containing the most recently accessed sources with the most recently
used at the end of | 1618 * A list containing the most recently accessed sources with the most recently
used at the end of |
| 625 * the list. When more sources are added than the maximum allowed then the lea
st recently used | 1619 * the list. When more sources are added than the maximum allowed then the lea
st recently used |
| 626 * source will be removed and will have it's cached AST structure flushed. | 1620 * source will be removed and will have it's cached AST structure flushed. |
| 627 */ | 1621 */ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 645 /** | 1639 /** |
| 646 * The number of times that the flushing of information from the cache has bee
n disabled without | 1640 * The number of times that the flushing of information from the cache has bee
n disabled without |
| 647 * being re-enabled. | 1641 * being re-enabled. |
| 648 */ | 1642 */ |
| 649 int _cacheRemovalCount = 0; | 1643 int _cacheRemovalCount = 0; |
| 650 /** | 1644 /** |
| 651 * Initialize a newly created analysis context. | 1645 * Initialize a newly created analysis context. |
| 652 */ | 1646 */ |
| 653 AnalysisContextImpl() : super() { | 1647 AnalysisContextImpl() : super() { |
| 654 } | 1648 } |
| 655 void addSourceInfo(Source source, SourceInfo info) { | 1649 void addSourceInfo(Source source, SourceEntry info) { |
| 656 _sourceMap[source] = info; | 1650 _sourceMap[source] = info; |
| 657 } | 1651 } |
| 658 void applyChanges(ChangeSet changeSet) { | 1652 void applyChanges(ChangeSet changeSet) { |
| 659 if (changeSet.isEmpty()) { | 1653 if (changeSet.isEmpty()) { |
| 660 return; | 1654 return; |
| 661 } | 1655 } |
| 662 { | 1656 { |
| 663 List<Source> removedSources = new List<Source>.from(changeSet.removed); | 1657 List<Source> removedSources = new List<Source>.from(changeSet.removed); |
| 664 for (SourceContainer container in changeSet.removedContainers) { | 1658 for (SourceContainer container in changeSet.removedContainers) { |
| 665 addSourcesInContainer(removedSources, container); | 1659 addSourcesInContainer(removedSources, container); |
| 666 } | 1660 } |
| 1661 bool addedDartSource = false; |
| 667 for (Source source in changeSet.added3) { | 1662 for (Source source in changeSet.added3) { |
| 668 sourceAvailable(source); | 1663 if (sourceAvailable(source)) { |
| 1664 addedDartSource = true; |
| 1665 } |
| 669 } | 1666 } |
| 670 for (Source source in changeSet.changed3) { | 1667 for (Source source in changeSet.changed3) { |
| 671 sourceChanged(source); | 1668 sourceChanged(source); |
| 672 } | 1669 } |
| 673 for (Source source in removedSources) { | 1670 for (Source source in removedSources) { |
| 674 sourceRemoved(source); | 1671 sourceRemoved(source); |
| 675 } | 1672 } |
| 676 } | 1673 if (addedDartSource) { |
| 1674 for (MapEntry<Source, SourceEntry> mapEntry in getMapEntrySet(_sourceMap
)) { |
| 1675 if (!mapEntry.getKey().isInSystemLibrary() && mapEntry.getValue() is D
artEntry) { |
| 1676 ((mapEntry.getValue() as DartEntryImpl)).invalidateAllResolutionInfo
rmation(); |
| 1677 } |
| 1678 } |
| 1679 } |
| 1680 } |
| 1681 } |
| 1682 String computeDocumentationComment(Element element) { |
| 1683 if (element == null) { |
| 1684 return null; |
| 1685 } |
| 1686 Source source2 = element.source; |
| 1687 if (source2 == null) { |
| 1688 return null; |
| 1689 } |
| 1690 List<CharSequence> contentHolder = new List<CharSequence>(1); |
| 1691 try { |
| 1692 source2.getContents(new Source_ContentReceiver_5(contentHolder)); |
| 1693 } catch (exception) { |
| 1694 throw new AnalysisException.con2("Could not get contents of ${source2.full
Name}", exception); |
| 1695 } |
| 1696 if (contentHolder[0] == null) { |
| 1697 return null; |
| 1698 } |
| 1699 CompilationUnit unit = parseCompilationUnit(source2); |
| 1700 if (unit == null) { |
| 1701 return null; |
| 1702 } |
| 1703 NodeLocator locator = new NodeLocator.con1(element.nameOffset); |
| 1704 ASTNode nameNode = locator.searchWithin(unit); |
| 1705 while (nameNode != null) { |
| 1706 if (nameNode is AnnotatedNode) { |
| 1707 Comment comment = ((nameNode as AnnotatedNode)).documentationComment; |
| 1708 if (comment == null) { |
| 1709 return null; |
| 1710 } |
| 1711 int offset2 = comment.offset; |
| 1712 return contentHolder[0].subSequence(offset2, offset2 + comment.length).t
oString(); |
| 1713 } |
| 1714 nameNode = nameNode.parent; |
| 1715 } |
| 1716 return null; |
| 677 } | 1717 } |
| 678 List<AnalysisError> computeErrors(Source source) { | 1718 List<AnalysisError> computeErrors(Source source) { |
| 679 { | 1719 { |
| 680 CompilationUnitInfo info = getCompilationUnitInfo(source); | 1720 SourceEntry sourceEntry = getSourceEntry(source); |
| 681 if (info == null) { | 1721 if (sourceEntry is DartEntry) { |
| 682 return AnalysisError.NO_ERRORS; | 1722 DartEntry dartEntry = sourceEntry as DartEntry; |
| 683 } | 1723 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS)
; |
| 684 if (info.hasInvalidParseErrors()) { | 1724 if (parseErrorsState != CacheState.VALID && parseErrorsState != CacheSta
te.ERROR) { |
| 685 parseCompilationUnit(source); | 1725 parseCompilationUnit(source); |
| 686 } | 1726 } |
| 687 if (info.hasInvalidResolutionErrors()) { | 1727 List<Source> libraries = getLibrariesContaining(source); |
| 688 } | 1728 for (Source librarySource in libraries) { |
| 689 return info.allErrors; | 1729 CacheState resolutionErrorsState = dartEntry.getState2(DartEntry.RESOL
UTION_ERRORS, librarySource); |
| 1730 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState
!= CacheState.ERROR) { |
| 1731 } |
| 1732 } |
| 1733 return dartEntry.allErrors; |
| 1734 } else if (sourceEntry is HtmlEntry) { |
| 1735 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 1736 CacheState resolutionErrorsState = htmlEntry.getState(HtmlEntry.RESOLUTI
ON_ERRORS); |
| 1737 if (resolutionErrorsState != CacheState.VALID && resolutionErrorsState !
= CacheState.ERROR) { |
| 1738 computeHtmlElement(source); |
| 1739 } |
| 1740 return htmlEntry.getValue(HtmlEntry.RESOLUTION_ERRORS); |
| 1741 } |
| 1742 return AnalysisError.NO_ERRORS; |
| 690 } | 1743 } |
| 691 } | 1744 } |
| 692 HtmlElement computeHtmlElement(Source source) { | 1745 HtmlElement computeHtmlElement(Source source) { |
| 693 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { | 1746 if (!AnalysisEngine.isHtmlFileName(source.shortName)) { |
| 694 return null; | 1747 return null; |
| 695 } | 1748 } |
| 696 { | 1749 { |
| 697 HtmlUnitInfo htmlUnitInfo = getHtmlUnitInfo(source); | 1750 HtmlEntry htmlEntry = getHtmlEntry(source); |
| 698 if (htmlUnitInfo == null) { | 1751 if (htmlEntry == null) { |
| 699 return null; | 1752 return null; |
| 700 } | 1753 } |
| 701 HtmlElement element2 = htmlUnitInfo.element; | 1754 HtmlElement element = htmlEntry.getValue(HtmlEntry.ELEMENT); |
| 702 if (element2 == null) { | 1755 if (element == null) { |
| 703 HtmlUnit unit = htmlUnitInfo.resolvedUnit; | 1756 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 704 if (unit == null) { | 1757 if (unit == null) { |
| 705 unit = htmlUnitInfo.parsedUnit; | 1758 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); |
| 706 if (unit == null) { | 1759 if (unit == null) { |
| 707 unit = parseHtmlUnit(source); | 1760 unit = parseHtmlUnit(source); |
| 708 } | 1761 } |
| 709 } | 1762 } |
| 710 HtmlUnitBuilder builder = new HtmlUnitBuilder(this); | 1763 RecordingErrorListener listener = new RecordingErrorListener(); |
| 711 element2 = builder.buildHtmlElement2(source, unit); | 1764 HtmlUnitBuilder builder = new HtmlUnitBuilder(this, listener); |
| 712 htmlUnitInfo.resolvedUnit = unit; | 1765 element = builder.buildHtmlElement2(source, unit); |
| 713 htmlUnitInfo.element = element2; | 1766 List<AnalysisError> resolutionErrors = listener.getErrors2(source); |
| 714 } | 1767 HtmlEntryImpl htmlCopy = (htmlEntry as HtmlEntryImpl); |
| 715 return element2; | 1768 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, unit); |
| 1769 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, resolutionErrors); |
| 1770 htmlCopy.setValue(HtmlEntry.ELEMENT, element); |
| 1771 getNotice(source).setErrors(resolutionErrors, htmlCopy.getValue(SourceEn
try.LINE_INFO)); |
| 1772 } |
| 1773 return element; |
| 716 } | 1774 } |
| 717 } | 1775 } |
| 718 SourceKind computeKindOf(Source source) { | 1776 SourceKind computeKindOf(Source source) { |
| 719 { | 1777 { |
| 720 SourceInfo sourceInfo = getSourceInfo(source); | 1778 SourceEntry sourceEntry = getSourceEntry(source); |
| 721 if (sourceInfo == null) { | 1779 if (sourceEntry == null) { |
| 722 return SourceKind.UNKNOWN; | 1780 return SourceKind.UNKNOWN; |
| 723 } else if (identical(sourceInfo, DartInfo.pendingInstance)) { | 1781 } else if (sourceEntry is DartEntry) { |
| 724 sourceInfo = internalComputeKindOf(source); | 1782 DartEntry dartEntry = sourceEntry as DartEntry; |
| 725 } | 1783 CacheState sourceKindState = dartEntry.getState(DartEntry.SOURCE_KIND); |
| 726 return sourceInfo.kind; | 1784 if (sourceKindState != CacheState.VALID && sourceKindState != CacheState
.ERROR) { |
| 1785 internalComputeKindOf(source); |
| 1786 } |
| 1787 } |
| 1788 return sourceEntry.kind; |
| 727 } | 1789 } |
| 728 } | 1790 } |
| 729 LibraryElement computeLibraryElement(Source source) { | 1791 LibraryElement computeLibraryElement(Source source) { |
| 730 if (!AnalysisEngine.isDartFileName(source.shortName)) { | 1792 if (!AnalysisEngine.isDartFileName(source.shortName)) { |
| 731 return null; | 1793 return null; |
| 732 } | 1794 } |
| 733 { | 1795 { |
| 734 LibraryInfo libraryInfo = getLibraryInfo(source); | 1796 DartEntry dartEntry = getDartEntry(source); |
| 735 if (libraryInfo == null) { | 1797 if (dartEntry == null) { |
| 736 return null; | 1798 return null; |
| 737 } | 1799 } |
| 738 LibraryElement element2 = libraryInfo.element; | 1800 LibraryElement element = dartEntry.getValue(DartEntry.ELEMENT); |
| 739 if (element2 == null) { | 1801 if (element == null) { |
| 740 if (computeKindOf(source) != SourceKind.LIBRARY) { | 1802 if (computeKindOf(source) != SourceKind.LIBRARY) { |
| 741 return null; | 1803 throw new AnalysisException.con1("Cannot compute library element for n
on-library: ${source.fullName}"); |
| 742 } | 1804 } |
| 743 LibraryResolver resolver = new LibraryResolver.con1(this); | 1805 LibraryResolver resolver = new LibraryResolver.con1(this); |
| 744 try { | 1806 try { |
| 745 element2 = resolver.resolveLibrary(source, true); | 1807 element = resolver.resolveLibrary(source, true); |
| 746 if (element2 != null) { | 1808 if (element != null) { |
| 747 libraryInfo.element = element2; | 1809 ((dartEntry as DartEntryImpl)).setValue(DartEntry.ELEMENT, element); |
| 748 } | 1810 } |
| 749 } on AnalysisException catch (exception) { | 1811 } on AnalysisException catch (exception) { |
| 750 AnalysisEngine.instance.logger.logError2("Could not resolve the librar
y ${source.fullName}", exception); | 1812 AnalysisEngine.instance.logger.logError2("Could not resolve the librar
y ${source.fullName}", exception); |
| 751 } | 1813 } |
| 752 } | 1814 } |
| 753 return element2; | 1815 return element; |
| 754 } | 1816 } |
| 755 } | 1817 } |
| 756 LineInfo computeLineInfo(Source source) { | 1818 LineInfo computeLineInfo(Source source) { |
| 757 { | 1819 { |
| 758 SourceInfo sourceInfo = getSourceInfo(source); | 1820 SourceEntry sourceEntry = getSourceEntry(source); |
| 759 if (sourceInfo == null) { | 1821 if (sourceEntry == null) { |
| 760 return null; | 1822 return null; |
| 761 } | 1823 } |
| 762 LineInfo lineInfo2 = sourceInfo.lineInfo; | 1824 LineInfo lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO); |
| 763 if (lineInfo2 == null) { | 1825 if (lineInfo == null) { |
| 764 if (identical(sourceInfo, DartInfo.pendingInstance)) { | 1826 if (sourceEntry is HtmlEntry) { |
| 765 sourceInfo = internalComputeKindOf(source); | |
| 766 } | |
| 767 if (sourceInfo is HtmlUnitInfo) { | |
| 768 parseHtmlUnit(source); | 1827 parseHtmlUnit(source); |
| 769 lineInfo2 = sourceInfo.lineInfo; | 1828 lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO); |
| 770 } else if (sourceInfo is CompilationUnitInfo) { | 1829 } else if (sourceEntry is DartEntry) { |
| 771 parseCompilationUnit(source); | 1830 parseCompilationUnit(source); |
| 772 lineInfo2 = sourceInfo.lineInfo; | 1831 lineInfo = sourceEntry.getValue(SourceEntry.LINE_INFO); |
| 773 } | 1832 } |
| 774 } | 1833 } |
| 775 return lineInfo2; | 1834 return lineInfo; |
| 776 } | 1835 } |
| 777 } | 1836 } |
| 778 CompilationUnit computeResolvableCompilationUnit(Source source) { | 1837 CompilationUnit computeResolvableCompilationUnit(Source source) { |
| 779 { | 1838 { |
| 780 CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source); | 1839 DartEntry dartEntry = getDartEntry(source); |
| 781 if (compilationUnitInfo == null) { | 1840 if (dartEntry == null) { |
| 782 return null; | 1841 return null; |
| 783 } | 1842 } |
| 784 CompilationUnit unit = compilationUnitInfo.parsedCompilationUnit; | 1843 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; |
| 785 if (unit == null) { | |
| 786 unit = compilationUnitInfo.resolvedCompilationUnit; | |
| 787 } | |
| 788 if (unit != null) { | 1844 if (unit != null) { |
| 789 return unit.accept(new ASTCloner()) as CompilationUnit; | 1845 return unit.accept(new ASTCloner()) as CompilationUnit; |
| 790 } | 1846 } |
| 791 unit = internalParseCompilationUnit(compilationUnitInfo, source); | 1847 unit = internalParseCompilationUnit(((dartEntry as DartEntryImpl)), source
); |
| 792 compilationUnitInfo.clearParsedUnit(); | 1848 ((dartEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, CacheState.
FLUSHED); |
| 793 return unit; | 1849 return unit; |
| 794 } | 1850 } |
| 795 } | 1851 } |
| 796 AnalysisContext extractContext(SourceContainer container) => extractContextInt
o(container, (AnalysisEngine.instance.createAnalysisContext() as AnalysisContext
Impl)); | 1852 AnalysisContext extractContext(SourceContainer container) => extractContextInt
o(container, (AnalysisEngine.instance.createAnalysisContext() as AnalysisContext
Impl)); |
| 797 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) { | 1853 InternalAnalysisContext extractContextInto(SourceContainer container, Internal
AnalysisContext newContext) { |
| 798 List<Source> sourcesToRemove = new List<Source>(); | 1854 List<Source> sourcesToRemove = new List<Source>(); |
| 799 { | 1855 { |
| 800 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) { | 1856 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 801 Source source = entry.getKey(); | 1857 Source source = entry.getKey(); |
| 802 if (container.contains(source)) { | 1858 if (container.contains(source)) { |
| 803 sourcesToRemove.add(source); | 1859 sourcesToRemove.add(source); |
| 804 newContext.addSourceInfo(source, entry.getValue().copy()); | 1860 newContext.addSourceInfo(source, entry.getValue().writableCopy); |
| 805 } | 1861 } |
| 806 } | 1862 } |
| 807 } | 1863 } |
| 808 return newContext; | 1864 return newContext; |
| 809 } | 1865 } |
| 810 Element getElement(ElementLocation location) { | 1866 Element getElement(ElementLocation location) { |
| 811 List<String> components2 = ((location as ElementLocationImpl)).components; | 1867 List<String> components2 = ((location as ElementLocationImpl)).components; |
| 812 ElementImpl element; | 1868 ElementImpl element; |
| 813 { | 1869 { |
| 814 Source librarySource = _sourceFactory.fromEncoding(components2[0]); | 1870 Source librarySource = _sourceFactory.fromEncoding(components2[0]); |
| 815 try { | 1871 try { |
| 816 element = computeLibraryElement(librarySource) as ElementImpl; | 1872 element = computeLibraryElement(librarySource) as ElementImpl; |
| 817 } on AnalysisException catch (exception) { | 1873 } on AnalysisException catch (exception) { |
| 818 return null; | 1874 return null; |
| 819 } | 1875 } |
| 820 } | 1876 } |
| 821 for (int i = 1; i < components2.length; i++) { | 1877 for (int i = 1; i < components2.length; i++) { |
| 822 if (element == null) { | 1878 if (element == null) { |
| 823 return null; | 1879 return null; |
| 824 } | 1880 } |
| 825 element = element.getChild(components2[i]); | 1881 element = element.getChild(components2[i]); |
| 826 } | 1882 } |
| 827 return element; | 1883 return element; |
| 828 } | 1884 } |
| 829 AnalysisErrorInfo getErrors(Source source) { | 1885 AnalysisErrorInfo getErrors(Source source) { |
| 830 { | 1886 { |
| 831 SourceInfo info = getSourceInfo(source); | 1887 SourceEntry sourceEntry = getSourceEntry(source); |
| 832 if (info is CompilationUnitInfo) { | 1888 if (sourceEntry is DartEntry) { |
| 833 CompilationUnitInfo compilationUnitInfo = info as CompilationUnitInfo; | 1889 DartEntry dartEntry = sourceEntry as DartEntry; |
| 834 return new AnalysisErrorInfoImpl(compilationUnitInfo.allErrors, compilat
ionUnitInfo.lineInfo); | 1890 return new AnalysisErrorInfoImpl(dartEntry.allErrors, dartEntry.getValue
(SourceEntry.LINE_INFO)); |
| 835 } | 1891 } else if (sourceEntry is HtmlEntry) { |
| 836 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, info.lineInfo); | 1892 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 1893 return new AnalysisErrorInfoImpl(htmlEntry.getValue(HtmlEntry.RESOLUTION
_ERRORS), htmlEntry.getValue(SourceEntry.LINE_INFO)); |
| 1894 } |
| 1895 return new AnalysisErrorInfoImpl(AnalysisError.NO_ERRORS, sourceEntry.getV
alue(SourceEntry.LINE_INFO)); |
| 837 } | 1896 } |
| 838 } | 1897 } |
| 839 HtmlElement getHtmlElement(Source source) { | 1898 HtmlElement getHtmlElement(Source source) { |
| 840 { | 1899 { |
| 841 SourceInfo info = getSourceInfo(source); | 1900 SourceEntry sourceEntry = getSourceEntry(source); |
| 842 if (info is HtmlUnitInfo) { | 1901 if (sourceEntry is HtmlEntry) { |
| 843 return ((info as HtmlUnitInfo)).element; | 1902 return ((sourceEntry as HtmlEntry)).getValue(HtmlEntry.ELEMENT); |
| 844 } | 1903 } |
| 845 return null; | 1904 return null; |
| 846 } | 1905 } |
| 847 } | 1906 } |
| 848 List<Source> getHtmlFilesReferencing(Source source) { | 1907 List<Source> getHtmlFilesReferencing(Source source) { |
| 849 { | 1908 { |
| 850 List<Source> htmlSources = new List<Source>(); | 1909 List<Source> htmlSources = new List<Source>(); |
| 851 while (true) { | 1910 while (true) { |
| 852 if (getKindOf(source) == SourceKind.LIBRARY) { | 1911 if (getKindOf(source) == SourceKind.LIBRARY) { |
| 853 } else if (getKindOf(source) == SourceKind.PART) { | 1912 } else if (getKindOf(source) == SourceKind.PART) { |
| 854 List<Source> librarySources = getLibrariesContaining(source); | 1913 List<Source> librarySources = getLibrariesContaining(source); |
| 855 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap))
{ | 1914 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)
) { |
| 856 if (identical(entry.getValue().kind, SourceKind.HTML)) { | 1915 if (identical(entry.getValue().kind, SourceKind.HTML)) { |
| 857 if (containsAny(((entry.getValue() as HtmlUnitInfo)).librarySource
s, librarySources)) { | 1916 List<Source> referencedLibraries = ((entry.getValue() as HtmlEntry
)).getValue(HtmlEntry.REFERENCED_LIBRARIES); |
| 1917 if (containsAny(referencedLibraries, librarySources)) { |
| 858 htmlSources.add(entry.getKey()); | 1918 htmlSources.add(entry.getKey()); |
| 859 } | 1919 } |
| 860 } | 1920 } |
| 861 } | 1921 } |
| 862 } | 1922 } |
| 863 break; | 1923 break; |
| 864 } | 1924 } |
| 865 if (htmlSources.isEmpty) { | 1925 if (htmlSources.isEmpty) { |
| 866 return Source.EMPTY_ARRAY; | 1926 return Source.EMPTY_ARRAY; |
| 867 } | 1927 } |
| 868 return new List.from(htmlSources); | 1928 return new List.from(htmlSources); |
| 869 } | 1929 } |
| 870 } | 1930 } |
| 871 List<Source> get htmlSources => getSources(SourceKind.HTML); | 1931 List<Source> get htmlSources => getSources(SourceKind.HTML); |
| 872 SourceKind getKindOf(Source source) { | 1932 SourceKind getKindOf(Source source) { |
| 873 { | 1933 { |
| 874 SourceInfo sourceInfo = getSourceInfo(source); | 1934 SourceEntry sourceEntry = getSourceEntry(source); |
| 875 if (sourceInfo == null) { | 1935 if (sourceEntry == null) { |
| 876 return SourceKind.UNKNOWN; | 1936 return SourceKind.UNKNOWN; |
| 877 } | 1937 } |
| 878 return sourceInfo.kind; | 1938 return sourceEntry.kind; |
| 879 } | 1939 } |
| 880 } | 1940 } |
| 881 List<Source> get launchableClientLibrarySources { | 1941 List<Source> get launchableClientLibrarySources { |
| 882 List<Source> sources = new List<Source>(); | 1942 List<Source> sources = new List<Source>(); |
| 883 { | 1943 { |
| 884 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) { | 1944 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 885 Source source = entry.getKey(); | 1945 Source source = entry.getKey(); |
| 886 SourceInfo info = entry.getValue(); | 1946 SourceEntry sourceEntry = entry.getValue(); |
| 887 if (identical(info.kind, SourceKind.LIBRARY) && !source.isInSystemLibrar
y()) { | 1947 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste
mLibrary()) { |
| 888 sources.add(source); | 1948 sources.add(source); |
| 889 } | 1949 } |
| 890 } | 1950 } |
| 891 } | 1951 } |
| 892 return new List.from(sources); | 1952 return new List.from(sources); |
| 893 } | 1953 } |
| 894 List<Source> get launchableServerLibrarySources { | 1954 List<Source> get launchableServerLibrarySources { |
| 895 List<Source> sources = new List<Source>(); | 1955 List<Source> sources = new List<Source>(); |
| 896 { | 1956 { |
| 897 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) { | 1957 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 898 Source source = entry.getKey(); | 1958 Source source = entry.getKey(); |
| 899 SourceInfo info = entry.getValue(); | 1959 SourceEntry sourceEntry = entry.getValue(); |
| 900 if (identical(info.kind, SourceKind.LIBRARY) && !source.isInSystemLibrar
y()) { | 1960 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSyste
mLibrary()) { |
| 901 sources.add(source); | 1961 sources.add(source); |
| 902 } | 1962 } |
| 903 } | 1963 } |
| 904 } | 1964 } |
| 905 return new List.from(sources); | 1965 return new List.from(sources); |
| 906 } | 1966 } |
| 907 List<Source> getLibrariesContaining(Source source) { | 1967 List<Source> getLibrariesContaining(Source source) { |
| 908 { | 1968 { |
| 909 List<Source> librarySources = new List<Source>(); | 1969 List<Source> librarySources = new List<Source>(); |
| 910 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) { | 1970 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 911 if (identical(entry.getValue().kind, SourceKind.LIBRARY)) { | 1971 if (identical(entry.getValue().kind, SourceKind.LIBRARY)) { |
| 912 if (contains(((entry.getValue() as LibraryInfo)).unitSources, source))
{ | 1972 if (contains(((entry.getValue() as DartEntry)).getValue(DartEntry.INCL
UDED_PARTS), source)) { |
| 913 librarySources.add(entry.getKey()); | 1973 librarySources.add(entry.getKey()); |
| 914 } | 1974 } |
| 915 } | 1975 } |
| 916 } | 1976 } |
| 917 if (librarySources.isEmpty) { | 1977 if (librarySources.isEmpty) { |
| 918 return Source.EMPTY_ARRAY; | 1978 return Source.EMPTY_ARRAY; |
| 919 } | 1979 } |
| 920 return new List.from(librarySources); | 1980 return new List.from(librarySources); |
| 921 } | 1981 } |
| 922 } | 1982 } |
| 923 LibraryElement getLibraryElement(Source source) { | 1983 LibraryElement getLibraryElement(Source source) { |
| 924 { | 1984 { |
| 925 SourceInfo info = getSourceInfo(source); | 1985 SourceEntry sourceEntry = getSourceEntry(source); |
| 926 if (info is LibraryInfo) { | 1986 if (sourceEntry is DartEntry) { |
| 927 return ((info as LibraryInfo)).element; | 1987 return ((sourceEntry as DartEntry)).getValue(DartEntry.ELEMENT); |
| 928 } | 1988 } |
| 929 return null; | 1989 return null; |
| 930 } | 1990 } |
| 931 } | 1991 } |
| 932 List<Source> get librarySources => getSources(SourceKind.LIBRARY); | 1992 List<Source> get librarySources => getSources(SourceKind.LIBRARY); |
| 933 LineInfo getLineInfo(Source source) { | 1993 LineInfo getLineInfo(Source source) { |
| 934 { | 1994 { |
| 935 SourceInfo info = getSourceInfo(source); | 1995 SourceEntry sourceEntry = getSourceEntry(source); |
| 936 if (info != null) { | 1996 if (sourceEntry != null) { |
| 937 return info.lineInfo; | 1997 return sourceEntry.getValue(SourceEntry.LINE_INFO); |
| 938 } | 1998 } |
| 939 return null; | 1999 return null; |
| 940 } | 2000 } |
| 941 } | 2001 } |
| 942 Namespace getPublicNamespace(LibraryElement library) { | 2002 Namespace getPublicNamespace(LibraryElement library) { |
| 943 Source source2 = library.definingCompilationUnit.source; | 2003 Source source2 = library.definingCompilationUnit.source; |
| 944 { | 2004 { |
| 945 LibraryInfo libraryInfo = getLibraryInfo(source2); | 2005 DartEntry dartEntry = getDartEntry(source2); |
| 946 if (libraryInfo == null) { | 2006 if (dartEntry == null) { |
| 947 return null; | 2007 return null; |
| 948 } | 2008 } |
| 949 Namespace namespace = libraryInfo.publicNamespace; | 2009 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 950 if (namespace == null) { | 2010 if (namespace == null) { |
| 951 NamespaceBuilder builder = new NamespaceBuilder(); | 2011 NamespaceBuilder builder = new NamespaceBuilder(); |
| 952 namespace = builder.createPublicNamespace(library); | 2012 namespace = builder.createPublicNamespace(library); |
| 953 libraryInfo.publicNamespace = namespace; | 2013 ((dartEntry as DartEntryImpl)).setValue(DartEntry.PUBLIC_NAMESPACE, name
space); |
| 954 } | 2014 } |
| 955 return namespace; | 2015 return namespace; |
| 956 } | 2016 } |
| 957 } | 2017 } |
| 958 Namespace getPublicNamespace2(Source source) { | 2018 Namespace getPublicNamespace2(Source source) { |
| 959 { | 2019 { |
| 960 LibraryInfo libraryInfo = getLibraryInfo(source); | 2020 DartEntry dartEntry = getDartEntry(source); |
| 961 if (libraryInfo == null) { | 2021 if (dartEntry == null) { |
| 962 return null; | 2022 return null; |
| 963 } | 2023 } |
| 964 Namespace namespace = libraryInfo.publicNamespace; | 2024 Namespace namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 965 if (namespace == null) { | 2025 if (namespace == null) { |
| 966 LibraryElement library = computeLibraryElement(source); | 2026 LibraryElement library = computeLibraryElement(source); |
| 967 if (library == null) { | 2027 if (library == null) { |
| 968 return null; | 2028 return null; |
| 969 } | 2029 } |
| 970 NamespaceBuilder builder = new NamespaceBuilder(); | 2030 NamespaceBuilder builder = new NamespaceBuilder(); |
| 971 namespace = builder.createPublicNamespace(library); | 2031 namespace = builder.createPublicNamespace(library); |
| 972 libraryInfo.publicNamespace = namespace; | 2032 ((dartEntry as DartEntryImpl)).setValue(DartEntry.PUBLIC_NAMESPACE, name
space); |
| 973 } | 2033 } |
| 974 return namespace; | 2034 return namespace; |
| 975 } | 2035 } |
| 976 } | 2036 } |
| 977 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { | 2037 CompilationUnit getResolvedCompilationUnit(Source unitSource, LibraryElement l
ibrary) { |
| 978 if (library == null) { | 2038 if (library == null) { |
| 979 return null; | 2039 return null; |
| 980 } | 2040 } |
| 981 return getResolvedCompilationUnit2(unitSource, library.source); | 2041 return getResolvedCompilationUnit2(unitSource, library.source); |
| 982 } | 2042 } |
| 983 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource) { | 2043 CompilationUnit getResolvedCompilationUnit2(Source unitSource, Source libraryS
ource) { |
| 984 { | 2044 { |
| 985 accessed(unitSource); | 2045 accessed(unitSource); |
| 986 CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(unitSourc
e); | 2046 DartEntry dartEntry = getDartEntry(unitSource); |
| 987 if (compilationUnitInfo == null) { | 2047 if (dartEntry == null) { |
| 988 return null; | 2048 return null; |
| 989 } | 2049 } |
| 990 return compilationUnitInfo.resolvedCompilationUnit; | 2050 return dartEntry.getValue2(DartEntry.RESOLVED_UNIT, librarySource); |
| 991 } | 2051 } |
| 992 } | 2052 } |
| 993 SourceFactory get sourceFactory => _sourceFactory; | 2053 SourceFactory get sourceFactory => _sourceFactory; |
| 994 bool isClientLibrary(Source librarySource) { | 2054 bool isClientLibrary(Source librarySource) { |
| 995 SourceInfo sourceInfo = getSourceInfo(librarySource); | 2055 SourceEntry sourceEntry = getSourceEntry(librarySource); |
| 996 if (sourceInfo is LibraryInfo) { | 2056 if (sourceEntry is DartEntry) { |
| 997 LibraryInfo libraryInfo = sourceInfo as LibraryInfo; | 2057 DartEntry dartEntry = sourceEntry as DartEntry; |
| 998 if (libraryInfo.hasInvalidLaunchable() || libraryInfo.hasInvalidClientServ
er()) { | 2058 CacheState isClientState = dartEntry.getState(DartEntry.IS_CLIENT); |
| 2059 CacheState isLaunchableState = dartEntry.getState(DartEntry.IS_LAUNCHABLE)
; |
| 2060 if (identical(isClientState, CacheState.INVALID) || identical(isClientStat
e, CacheState.ERROR) || identical(isLaunchableState, CacheState.INVALID) || iden
tical(isLaunchableState, CacheState.ERROR)) { |
| 999 return false; | 2061 return false; |
| 1000 } | 2062 } |
| 1001 return libraryInfo.isLaunchable() && libraryInfo.isClient(); | 2063 return dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(DartE
ntry.IS_LAUNCHABLE); |
| 1002 } | 2064 } |
| 1003 return false; | 2065 return false; |
| 1004 } | 2066 } |
| 1005 bool isServerLibrary(Source librarySource) { | 2067 bool isServerLibrary(Source librarySource) { |
| 1006 SourceInfo sourceInfo = getSourceInfo(librarySource); | 2068 SourceEntry sourceEntry = getSourceEntry(librarySource); |
| 1007 if (sourceInfo is LibraryInfo) { | 2069 if (sourceEntry is DartEntry) { |
| 1008 LibraryInfo libraryInfo = sourceInfo as LibraryInfo; | 2070 DartEntry dartEntry = sourceEntry as DartEntry; |
| 1009 if (libraryInfo.hasInvalidLaunchable() || libraryInfo.hasInvalidClientServ
er()) { | 2071 CacheState isClientState = dartEntry.getState(DartEntry.IS_CLIENT); |
| 2072 CacheState isLaunchableState = dartEntry.getState(DartEntry.IS_LAUNCHABLE)
; |
| 2073 if (identical(isClientState, CacheState.INVALID) || identical(isClientStat
e, CacheState.ERROR) || identical(isLaunchableState, CacheState.INVALID) || iden
tical(isLaunchableState, CacheState.ERROR)) { |
| 1010 return false; | 2074 return false; |
| 1011 } | 2075 } |
| 1012 return libraryInfo.isLaunchable() && libraryInfo.isServer(); | 2076 return !dartEntry.getValue(DartEntry.IS_CLIENT) && dartEntry.getValue(Dart
Entry.IS_LAUNCHABLE); |
| 1013 } | 2077 } |
| 1014 return false; | 2078 return false; |
| 1015 } | 2079 } |
| 1016 void mergeContext(AnalysisContext context) { | 2080 void mergeContext(AnalysisContext context) { |
| 1017 { | 2081 { |
| 1018 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(((context as Ana
lysisContextImpl))._sourceMap)) { | 2082 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(((context as An
alysisContextImpl))._sourceMap)) { |
| 1019 Source newSource = entry.getKey(); | 2083 Source newSource = entry.getKey(); |
| 1020 SourceInfo existingInfo = getSourceInfo(newSource); | 2084 SourceEntry existingEntry = getSourceEntry(newSource); |
| 1021 if (existingInfo == null) { | 2085 if (existingEntry == null) { |
| 1022 _sourceMap[newSource] = entry.getValue().copy(); | 2086 _sourceMap[newSource] = entry.getValue().writableCopy; |
| 1023 } else { | 2087 } else { |
| 1024 } | 2088 } |
| 1025 } | 2089 } |
| 1026 } | 2090 } |
| 1027 } | 2091 } |
| 1028 CompilationUnit parseCompilationUnit(Source source) { | 2092 CompilationUnit parseCompilationUnit(Source source) { |
| 1029 { | 2093 { |
| 1030 accessed(source); | 2094 accessed(source); |
| 1031 CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source); | 2095 DartEntry dartEntry = getDartEntry(source); |
| 1032 if (compilationUnitInfo == null) { | 2096 if (dartEntry == null) { |
| 1033 return null; | 2097 return null; |
| 1034 } | 2098 } |
| 1035 CompilationUnit unit = compilationUnitInfo.resolvedCompilationUnit; | 2099 CompilationUnit unit = dartEntry.anyParsedCompilationUnit; |
| 1036 if (unit == null) { | 2100 if (unit == null) { |
| 1037 unit = compilationUnitInfo.parsedCompilationUnit; | 2101 unit = internalParseCompilationUnit((dartEntry as DartEntryImpl), source
); |
| 1038 if (unit == null) { | |
| 1039 unit = internalParseCompilationUnit(compilationUnitInfo, source); | |
| 1040 } | |
| 1041 } | 2102 } |
| 1042 return unit; | 2103 return unit; |
| 1043 } | 2104 } |
| 1044 } | 2105 } |
| 1045 HtmlUnit parseHtmlUnit(Source source) { | 2106 HtmlUnit parseHtmlUnit(Source source) { |
| 1046 { | 2107 { |
| 1047 accessed(source); | 2108 accessed(source); |
| 1048 HtmlUnitInfo htmlUnitInfo = getHtmlUnitInfo(source); | 2109 HtmlEntry htmlEntry = getHtmlEntry(source); |
| 1049 if (htmlUnitInfo == null) { | 2110 if (htmlEntry == null) { |
| 1050 return null; | 2111 return null; |
| 1051 } | 2112 } |
| 1052 HtmlUnit unit = htmlUnitInfo.resolvedUnit; | 2113 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 1053 if (unit == null) { | 2114 if (unit == null) { |
| 1054 unit = htmlUnitInfo.parsedUnit; | 2115 unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); |
| 1055 if (unit == null) { | 2116 if (unit == null) { |
| 1056 HtmlParseResult result = new HtmlParser(source).parse(scanHtml(source)
); | 2117 HtmlParseResult result = new HtmlParser(source).parse(scanHtml(source)
); |
| 1057 unit = result.htmlUnit; | 2118 unit = result.htmlUnit; |
| 1058 htmlUnitInfo.lineInfo = new LineInfo(result.lineStarts); | 2119 ((htmlEntry as HtmlEntryImpl)).setValue(SourceEntry.LINE_INFO, new Lin
eInfo(result.lineStarts)); |
| 1059 htmlUnitInfo.parsedUnit = unit; | 2120 ((htmlEntry as HtmlEntryImpl)).setValue(HtmlEntry.PARSED_UNIT, unit); |
| 1060 htmlUnitInfo.librarySources = getLibrarySources2(source, unit); | 2121 ((htmlEntry as HtmlEntryImpl)).setValue(HtmlEntry.REFERENCED_LIBRARIES
, getLibrarySources2(source, unit)); |
| 1061 } | 2122 } |
| 1062 } | 2123 } |
| 1063 return unit; | 2124 return unit; |
| 1064 } | 2125 } |
| 1065 } | 2126 } |
| 1066 List<ChangeNotice> performAnalysisTask() { | 2127 List<ChangeNotice> performAnalysisTask() { |
| 1067 { | 2128 { |
| 1068 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) { | 2129 if (!performSingleAnalysisTask() && _pendingNotices.isEmpty) { |
| 1069 return null; | 2130 return null; |
| 1070 } | 2131 } |
| 1071 if (_pendingNotices.isEmpty) { | 2132 if (_pendingNotices.isEmpty) { |
| 1072 return ChangeNoticeImpl.EMPTY_ARRAY; | 2133 return ChangeNoticeImpl.EMPTY_ARRAY; |
| 1073 } | 2134 } |
| 1074 List<ChangeNotice> notices = new List.from(_pendingNotices.values); | 2135 List<ChangeNotice> notices = new List.from(_pendingNotices.values); |
| 1075 _pendingNotices.clear(); | 2136 _pendingNotices.clear(); |
| 1076 return notices; | 2137 return notices; |
| 1077 } | 2138 } |
| 1078 } | 2139 } |
| 1079 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 2140 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 1080 Source htmlSource = _sourceFactory.forUri("dart:html"); | 2141 Source htmlSource = _sourceFactory.forUri("dart:html"); |
| 1081 { | 2142 { |
| 1082 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap))
{ | 2143 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap))
{ |
| 1083 Source librarySource = entry.getKey(); | 2144 Source librarySource = entry.getKey(); |
| 1084 LibraryElement library = entry.getValue(); | 2145 LibraryElement library = entry.getValue(); |
| 1085 LibraryInfo libraryInfo = getLibraryInfo(librarySource); | 2146 DartEntryImpl dartEntry = getDartEntry(librarySource) as DartEntryImpl; |
| 1086 if (libraryInfo != null) { | 2147 if (dartEntry != null) { |
| 1087 libraryInfo.element = library; | 2148 dartEntry.setValue(DartEntry.ELEMENT, library); |
| 1088 libraryInfo.launchable = library.entryPoint != null; | 2149 dartEntry.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null
); |
| 1089 libraryInfo.client = isClient(library, htmlSource, new Set<LibraryElem
ent>()); | 2150 dartEntry.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource,
new Set<LibraryElement>())); |
| 1090 List<Source> unitSources = new List<Source>(); | 2151 List<Source> unitSources = new List<Source>(); |
| 1091 unitSources.add(librarySource); | 2152 unitSources.add(librarySource); |
| 1092 for (CompilationUnitElement part in library.parts) { | 2153 for (CompilationUnitElement part in library.parts) { |
| 1093 Source partSource = part.source; | 2154 Source partSource = part.source; |
| 1094 unitSources.add(partSource); | 2155 unitSources.add(partSource); |
| 1095 } | 2156 } |
| 1096 libraryInfo.unitSources = new List.from(unitSources); | 2157 dartEntry.setValue(DartEntry.INCLUDED_PARTS, new List.from(unitSources
)); |
| 1097 } | 2158 } |
| 1098 } | 2159 } |
| 1099 } | 2160 } |
| 1100 } | 2161 } |
| 1101 void recordResolutionErrors(Source source, List<AnalysisError> errors, LineInf
o lineInfo2) { | 2162 void recordResolutionErrors(Source source, Source librarySource, List<Analysis
Error> errors, LineInfo lineInfo) { |
| 1102 { | 2163 { |
| 1103 CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source); | 2164 DartEntryImpl dartEntry = getDartEntry(source) as DartEntryImpl; |
| 1104 if (compilationUnitInfo != null) { | 2165 if (dartEntry != null) { |
| 1105 compilationUnitInfo.lineInfo = lineInfo2; | 2166 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 1106 compilationUnitInfo.resolutionErrors = errors; | 2167 dartEntry.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, errors); |
| 1107 } | 2168 } |
| 1108 getNotice(source).setErrors(compilationUnitInfo.allErrors, lineInfo2); | 2169 getNotice(source).setErrors(dartEntry.allErrors, lineInfo); |
| 1109 } | 2170 } |
| 1110 } | 2171 } |
| 1111 void recordResolvedCompilationUnit(Source source, CompilationUnit unit) { | 2172 void recordResolvedCompilationUnit(Source source, Source librarySource, Compil
ationUnit unit) { |
| 1112 { | 2173 { |
| 1113 CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source); | 2174 DartEntryImpl dartEntry = getDartEntry(source) as DartEntryImpl; |
| 1114 if (compilationUnitInfo != null) { | 2175 if (dartEntry != null) { |
| 1115 compilationUnitInfo.resolvedCompilationUnit = unit; | 2176 dartEntry.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit); |
| 1116 compilationUnitInfo.clearParsedUnit(); | 2177 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 1117 getNotice(source).compilationUnit = unit; | 2178 getNotice(source).compilationUnit = unit; |
| 1118 } | 2179 } |
| 1119 } | 2180 } |
| 1120 } | 2181 } |
| 1121 CompilationUnit resolveCompilationUnit(Source source2, LibraryElement library)
{ | 2182 CompilationUnit resolveCompilationUnit(Source source2, LibraryElement library)
{ |
| 1122 if (library == null) { | 2183 if (library == null) { |
| 1123 return null; | 2184 return null; |
| 1124 } | 2185 } |
| 1125 return resolveCompilationUnit2(source2, library.source); | 2186 return resolveCompilationUnit2(source2, library.source); |
| 1126 } | 2187 } |
| 1127 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { | 2188 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { |
| 1128 { | 2189 { |
| 1129 accessed(unitSource); | 2190 accessed(unitSource); |
| 1130 CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(unitSourc
e); | 2191 DartEntry dartEntry = getDartEntry(unitSource); |
| 1131 if (compilationUnitInfo == null) { | 2192 if (dartEntry == null) { |
| 1132 return null; | 2193 return null; |
| 1133 } | 2194 } |
| 1134 CompilationUnit unit = compilationUnitInfo.resolvedCompilationUnit; | 2195 CompilationUnit unit = dartEntry.getValue2(DartEntry.RESOLVED_UNIT, librar
ySource); |
| 1135 if (unit == null) { | 2196 if (unit == null) { |
| 1136 disableCacheRemoval(); | 2197 disableCacheRemoval(); |
| 1137 try { | 2198 try { |
| 1138 LibraryElement libraryElement = computeLibraryElement(librarySource); | 2199 LibraryElement libraryElement = computeLibraryElement(librarySource); |
| 1139 unit = compilationUnitInfo.resolvedCompilationUnit; | 2200 unit = dartEntry.getValue2(DartEntry.RESOLVED_UNIT, librarySource); |
| 1140 if (unit == null && libraryElement != null) { | 2201 if (unit == null && libraryElement != null) { |
| 1141 Source coreLibrarySource = libraryElement.context.sourceFactory.forU
ri(DartSdk.DART_CORE); | 2202 Source coreLibrarySource = libraryElement.context.sourceFactory.forU
ri(DartSdk.DART_CORE); |
| 1142 LibraryElement coreElement = computeLibraryElement(coreLibrarySource
); | 2203 LibraryElement coreElement = computeLibraryElement(coreLibrarySource
); |
| 1143 TypeProvider typeProvider = new TypeProviderImpl(coreElement); | 2204 TypeProvider typeProvider = new TypeProviderImpl(coreElement); |
| 1144 CompilationUnit unitAST = computeResolvableCompilationUnit(unitSourc
e); | 2205 CompilationUnit unitAST = computeResolvableCompilationUnit(unitSourc
e); |
| 1145 new DeclarationResolver().resolve(unitAST, find(libraryElement, unit
Source)); | 2206 new DeclarationResolver().resolve(unitAST, find(libraryElement, unit
Source)); |
| 1146 RecordingErrorListener errorListener = new RecordingErrorListener(); | 2207 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1147 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.co
n2(libraryElement, unitSource, typeProvider, errorListener); | 2208 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor.co
n2(libraryElement, unitSource, typeProvider, errorListener); |
| 1148 unitAST.accept(typeResolverVisitor); | 2209 unitAST.accept(typeResolverVisitor); |
| 1149 ResolverVisitor resolverVisitor = new ResolverVisitor.con2(libraryEl
ement, unitSource, typeProvider, errorListener); | 2210 ResolverVisitor resolverVisitor = new ResolverVisitor.con2(libraryEl
ement, unitSource, typeProvider, errorListener); |
| 1150 unitAST.accept(resolverVisitor); | 2211 unitAST.accept(resolverVisitor); |
| 1151 ErrorReporter errorReporter = new ErrorReporter(errorListener, unitS
ource); | 2212 ErrorReporter errorReporter = new ErrorReporter(errorListener, unitS
ource); |
| 1152 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libra
ryElement, typeProvider); | 2213 ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, libra
ryElement, typeProvider); |
| 1153 unitAST.accept(errorVerifier); | 2214 unitAST.accept(errorVerifier); |
| 1154 ConstantVerifier constantVerifier = new ConstantVerifier(errorReport
er); | 2215 ConstantVerifier constantVerifier = new ConstantVerifier(errorReport
er); |
| 1155 unitAST.accept(constantVerifier); | 2216 unitAST.accept(constantVerifier); |
| 1156 unitAST.resolutionErrors = errorListener.errors; | 2217 unitAST.resolutionErrors = errorListener.errors; |
| 1157 compilationUnitInfo.resolvedCompilationUnit = unitAST; | 2218 ((dartEntry as DartEntryImpl)).setValue2(DartEntry.RESOLVED_UNIT, li
brarySource, unitAST); |
| 1158 unit = unitAST; | 2219 unit = unitAST; |
| 1159 } | 2220 } |
| 1160 } finally { | 2221 } finally { |
| 1161 enableCacheRemoval(); | 2222 enableCacheRemoval(); |
| 1162 } | 2223 } |
| 1163 } | 2224 } |
| 1164 return unit; | 2225 return unit; |
| 1165 } | 2226 } |
| 1166 } | 2227 } |
| 1167 HtmlUnit resolveHtmlUnit(Source unitSource) { | 2228 HtmlUnit resolveHtmlUnit(Source unitSource) { |
| 1168 { | 2229 { |
| 1169 accessed(unitSource); | 2230 accessed(unitSource); |
| 1170 HtmlUnitInfo htmlUnitInfo = getHtmlUnitInfo(unitSource); | 2231 HtmlEntry htmlEntry = getHtmlEntry(unitSource); |
| 1171 if (htmlUnitInfo == null) { | 2232 if (htmlEntry == null) { |
| 1172 return null; | 2233 return null; |
| 1173 } | 2234 } |
| 1174 HtmlUnit unit = htmlUnitInfo.resolvedUnit; | 2235 HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 1175 if (unit == null) { | 2236 if (unit == null) { |
| 1176 disableCacheRemoval(); | 2237 disableCacheRemoval(); |
| 1177 try { | 2238 try { |
| 1178 computeHtmlElement(unitSource); | 2239 computeHtmlElement(unitSource); |
| 1179 unit = htmlUnitInfo.resolvedUnit; | 2240 unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 1180 if (unit == null) { | 2241 if (unit == null) { |
| 1181 unit = parseHtmlUnit(unitSource); | 2242 unit = parseHtmlUnit(unitSource); |
| 1182 } | 2243 } |
| 1183 } finally { | 2244 } finally { |
| 1184 enableCacheRemoval(); | 2245 enableCacheRemoval(); |
| 1185 } | 2246 } |
| 1186 } | 2247 } |
| 1187 return unit; | 2248 return unit; |
| 1188 } | 2249 } |
| 1189 } | 2250 } |
| 1190 void setContents(Source source, String contents) { | 2251 void setContents(Source source, String contents) { |
| 1191 { | 2252 { |
| 1192 _sourceFactory.setContents(source, contents); | 2253 _sourceFactory.setContents(source, contents); |
| 1193 sourceChanged(source); | 2254 sourceChanged(source); |
| 1194 } | 2255 } |
| 1195 } | 2256 } |
| 1196 void set sourceFactory(SourceFactory factory) { | 2257 void set sourceFactory(SourceFactory factory) { |
| 1197 if (identical(_sourceFactory, factory)) { | 2258 if (identical(_sourceFactory, factory)) { |
| 1198 return; | 2259 return; |
| 1199 } else if (factory.context != null) { | 2260 } else if (factory.context != null) { |
| 1200 throw new IllegalStateException("Source factories cannot be shared between
contexts"); | 2261 throw new IllegalStateException("Source factories cannot be shared between
contexts"); |
| 1201 } | 2262 } |
| 1202 { | 2263 { |
| 1203 if (_sourceFactory != null) { | 2264 if (_sourceFactory != null) { |
| 1204 _sourceFactory.context = null; | 2265 _sourceFactory.context = null; |
| 1205 } | 2266 } |
| 1206 factory.context = this; | 2267 factory.context = this; |
| 1207 _sourceFactory = factory; | 2268 _sourceFactory = factory; |
| 1208 for (SourceInfo sourceInfo in _sourceMap.values) { | 2269 for (SourceEntry sourceEntry in _sourceMap.values) { |
| 1209 if (sourceInfo is HtmlUnitInfo) { | 2270 if (sourceEntry is HtmlEntry) { |
| 1210 ((sourceInfo as HtmlUnitInfo)).invalidateResolvedUnit(); | 2271 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, Cac
heState.INVALID); |
| 1211 } else if (sourceInfo is CompilationUnitInfo) { | 2272 } else if (sourceEntry is DartEntry) { |
| 1212 CompilationUnitInfo compilationUnitInfo = sourceInfo as CompilationUni
tInfo; | 2273 ((sourceEntry as DartEntryImpl)).invalidateAllResolutionInformation(); |
| 1213 compilationUnitInfo.invalidateResolvedUnit(); | |
| 1214 compilationUnitInfo.invalidateResolutionErrors(); | |
| 1215 if (sourceInfo is LibraryInfo) { | |
| 1216 LibraryInfo libraryInfo = sourceInfo as LibraryInfo; | |
| 1217 libraryInfo.invalidateElement(); | |
| 1218 libraryInfo.invalidatePublicNamespace(); | |
| 1219 libraryInfo.invalidateLaunchable(); | |
| 1220 libraryInfo.invalidateClientServer(); | |
| 1221 } | |
| 1222 } | 2274 } |
| 1223 } | 2275 } |
| 1224 } | 2276 } |
| 1225 } | 2277 } |
| 1226 Iterable<Source> sourcesToResolve(List<Source> changedSources) { | 2278 Iterable<Source> sourcesToResolve(List<Source> changedSources) { |
| 1227 List<Source> librarySources = new List<Source>(); | 2279 List<Source> librarySources = new List<Source>(); |
| 1228 for (Source source in changedSources) { | 2280 for (Source source in changedSources) { |
| 1229 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { | 2281 if (identical(computeKindOf(source), SourceKind.LIBRARY)) { |
| 1230 librarySources.add(source); | 2282 librarySources.add(source); |
| 1231 } | 2283 } |
| 1232 } | 2284 } |
| 1233 return librarySources; | 2285 return librarySources; |
| 1234 } | 2286 } |
| 1235 /** | 2287 /** |
| 1236 * Record that the given source was just accessed for some unspecified purpose
. | 2288 * Record that the given source was just accessed for some unspecified purpose
. |
| 1237 * <p> | 2289 * <p> |
| 1238 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. | 2290 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. |
| 1239 * @param source the source that was accessed | 2291 * @param source the source that was accessed |
| 1240 */ | 2292 */ |
| 1241 void accessed(Source source) { | 2293 void accessed(Source source) { |
| 1242 if (_recentlyUsed.contains(source)) { | 2294 if (_recentlyUsed.contains(source)) { |
| 1243 _recentlyUsed.remove(source); | 2295 _recentlyUsed.remove(source); |
| 1244 _recentlyUsed.add(source); | 2296 _recentlyUsed.add(source); |
| 1245 return; | 2297 return; |
| 1246 } | 2298 } |
| 1247 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { | 2299 if (_cacheRemovalCount == 0 && _recentlyUsed.length >= _MAX_CACHE_SIZE) { |
| 1248 Source removedSource = _recentlyUsed.removeAt(0); | 2300 Source removedSource = _recentlyUsed.removeAt(0); |
| 1249 SourceInfo sourceInfo = _sourceMap[removedSource]; | 2301 SourceEntry sourceEntry = _sourceMap[removedSource]; |
| 1250 if (sourceInfo is HtmlUnitInfo) { | 2302 if (sourceEntry is HtmlEntry) { |
| 1251 ((sourceInfo as HtmlUnitInfo)).clearParsedUnit(); | 2303 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.PARSED_UNIT, CacheSt
ate.FLUSHED); |
| 1252 ((sourceInfo as HtmlUnitInfo)).clearResolvedUnit(); | 2304 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, Cache
State.FLUSHED); |
| 1253 } else if (sourceInfo is CompilationUnitInfo) { | 2305 } else if (sourceEntry is DartEntry) { |
| 1254 ((sourceInfo as CompilationUnitInfo)).clearParsedUnit(); | 2306 ((sourceEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, CacheSt
ate.FLUSHED); |
| 1255 ((sourceInfo as CompilationUnitInfo)).clearResolvedUnit(); | 2307 for (Source librarySource in getLibrariesContaining(source)) { |
| 2308 ((sourceEntry as DartEntryImpl)).setState2(DartEntry.RESOLVED_UNIT, li
brarySource, CacheState.FLUSHED); |
| 2309 } |
| 1256 } | 2310 } |
| 1257 } | 2311 } |
| 1258 _recentlyUsed.add(source); | 2312 _recentlyUsed.add(source); |
| 1259 } | 2313 } |
| 1260 /** | 2314 /** |
| 1261 * Add all of the sources contained in the given source container to the given
list of sources. | 2315 * Add all of the sources contained in the given source container to the given
list of sources. |
| 1262 * <p> | 2316 * <p> |
| 1263 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. | 2317 * Note: This method must only be invoked while we are synchronized on {@link
#cacheLock}. |
| 1264 * @param sources the list to which sources are to be added | 2318 * @param sources the list to which sources are to be added |
| 1265 * @param container the source container containing the sources to be added to
the list | 2319 * @param container the source container containing the sources to be added to
the list |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1298 } | 2352 } |
| 1299 } | 2353 } |
| 1300 return false; | 2354 return false; |
| 1301 } | 2355 } |
| 1302 /** | 2356 /** |
| 1303 * Create a source information object suitable for the given source. Return th
e source information | 2357 * Create a source information object suitable for the given source. Return th
e source information |
| 1304 * object that was created, or {@code null} if the source should not be tracke
d by this context. | 2358 * object that was created, or {@code null} if the source should not be tracke
d by this context. |
| 1305 * @param source the source for which an information object is being created | 2359 * @param source the source for which an information object is being created |
| 1306 * @return the source information object that was created | 2360 * @return the source information object that was created |
| 1307 */ | 2361 */ |
| 1308 SourceInfo createSourceInfo(Source source) { | 2362 SourceEntry createSourceEntry(Source source) { |
| 1309 String name = source.shortName; | 2363 String name = source.shortName; |
| 1310 if (AnalysisEngine.isHtmlFileName(name)) { | 2364 if (AnalysisEngine.isHtmlFileName(name)) { |
| 1311 HtmlUnitInfo info = new HtmlUnitInfo(); | 2365 HtmlEntry htmlEntry = new HtmlEntryImpl(); |
| 1312 _sourceMap[source] = info; | 2366 _sourceMap[source] = htmlEntry; |
| 1313 return info; | 2367 return htmlEntry; |
| 1314 } else if (AnalysisEngine.isDartFileName(name)) { | 2368 } else if (AnalysisEngine.isDartFileName(name)) { |
| 1315 DartInfo info = DartInfo.pendingInstance; | 2369 DartEntry dartEntry = new DartEntryImpl(); |
| 1316 _sourceMap[source] = info; | 2370 _sourceMap[source] = dartEntry; |
| 1317 return info; | 2371 return dartEntry; |
| 1318 } | 2372 } |
| 1319 return null; | 2373 return null; |
| 1320 } | 2374 } |
| 1321 /** | 2375 /** |
| 1322 * Disable flushing information from the cache until {@link #enableCacheRemova
l()} has been | 2376 * Disable flushing information from the cache until {@link #enableCacheRemova
l()} has been |
| 1323 * called. | 2377 * called. |
| 1324 */ | 2378 */ |
| 1325 void disableCacheRemoval() { | 2379 void disableCacheRemoval() { |
| 1326 _cacheRemovalCount++; | 2380 _cacheRemovalCount++; |
| 1327 } | 2381 } |
| 1328 /** | 2382 /** |
| 1329 * Re-enable flushing information from the cache. | 2383 * Re-enable flushing information from the cache. |
| 1330 */ | 2384 */ |
| 1331 void enableCacheRemoval() { | 2385 void enableCacheRemoval() { |
| 1332 if (_cacheRemovalCount > 0) { | 2386 if (_cacheRemovalCount > 0) { |
| 1333 _cacheRemovalCount--; | 2387 _cacheRemovalCount--; |
| 1334 } | 2388 } |
| 1335 if (_cacheRemovalCount == 0) { | 2389 if (_cacheRemovalCount == 0) { |
| 1336 while (_recentlyUsed.length >= _MAX_CACHE_SIZE) { | 2390 while (_recentlyUsed.length >= _MAX_CACHE_SIZE) { |
| 1337 Source removedSource = _recentlyUsed.removeAt(0); | 2391 Source removedSource = _recentlyUsed.removeAt(0); |
| 1338 SourceInfo sourceInfo = _sourceMap[removedSource]; | 2392 SourceEntry sourceEntry = _sourceMap[removedSource]; |
| 1339 if (sourceInfo is HtmlUnitInfo) { | 2393 if (sourceEntry is HtmlEntry) { |
| 1340 ((sourceInfo as HtmlUnitInfo)).clearParsedUnit(); | 2394 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.PARSED_UNIT, Cache
State.FLUSHED); |
| 1341 ((sourceInfo as HtmlUnitInfo)).clearResolvedUnit(); | 2395 ((sourceEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, Cac
heState.FLUSHED); |
| 1342 } else if (sourceInfo is CompilationUnitInfo) { | 2396 } else if (sourceEntry is DartEntry) { |
| 1343 ((sourceInfo as CompilationUnitInfo)).clearParsedUnit(); | 2397 ((sourceEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, Cache
State.FLUSHED); |
| 1344 ((sourceInfo as CompilationUnitInfo)).clearResolvedUnit(); | 2398 for (Source librarySource in getLibrariesContaining(removedSource)) { |
| 2399 ((sourceEntry as DartEntryImpl)).setState2(DartEntry.RESOLVED_UNIT,
librarySource, CacheState.FLUSHED); |
| 2400 } |
| 1345 } | 2401 } |
| 1346 } | 2402 } |
| 1347 } | 2403 } |
| 1348 } | 2404 } |
| 1349 /** | 2405 /** |
| 1350 * Search the compilation units that are part of the given library and return
the element | 2406 * Search the compilation units that are part of the given library and return
the element |
| 1351 * representing the compilation unit with the given source. Return {@code null
} if there is no | 2407 * representing the compilation unit with the given source. Return {@code null
} if there is no |
| 1352 * such compilation unit. | 2408 * such compilation unit. |
| 1353 * @param libraryElement the element representing the library being searched t
hrough | 2409 * @param libraryElement the element representing the library being searched t
hrough |
| 1354 * @param unitSource the source for the compilation unit whose element is to b
e returned | 2410 * @param unitSource the source for the compilation unit whose element is to b
e returned |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1370 * Return the compilation unit information associated with the given source, o
r {@code null} if | 2426 * Return the compilation unit information associated with the given source, o
r {@code null} if |
| 1371 * the source is not known to this context. This method should be used to acce
ss the compilation | 2427 * the source is not known to this context. This method should be used to acce
ss the compilation |
| 1372 * unit information rather than accessing the compilation unit map directly be
cause sources in the | 2428 * unit information rather than accessing the compilation unit map directly be
cause sources in the |
| 1373 * SDK are implicitly part of every analysis context and are therefore only ad
ded to the map when | 2429 * SDK are implicitly part of every analysis context and are therefore only ad
ded to the map when |
| 1374 * first accessed. | 2430 * first accessed. |
| 1375 * <p> | 2431 * <p> |
| 1376 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2432 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 1377 * @param source the source for which information is being sought | 2433 * @param source the source for which information is being sought |
| 1378 * @return the compilation unit information associated with the given source | 2434 * @return the compilation unit information associated with the given source |
| 1379 */ | 2435 */ |
| 1380 CompilationUnitInfo getCompilationUnitInfo(Source source) { | 2436 DartEntry getDartEntry(Source source) { |
| 1381 SourceInfo sourceInfo = getSourceInfo(source); | 2437 SourceEntry sourceEntry = getSourceEntry(source); |
| 1382 if (sourceInfo == null) { | 2438 if (sourceEntry == null) { |
| 1383 sourceInfo = new CompilationUnitInfo(); | 2439 sourceEntry = new DartEntryImpl(); |
| 1384 _sourceMap[source] = sourceInfo; | 2440 _sourceMap[source] = sourceEntry; |
| 1385 return sourceInfo as CompilationUnitInfo; | 2441 return sourceEntry as DartEntry; |
| 1386 } else if (sourceInfo is CompilationUnitInfo) { | 2442 } else if (sourceEntry is DartEntry) { |
| 1387 return sourceInfo as CompilationUnitInfo; | 2443 return sourceEntry as DartEntry; |
| 1388 } else if (identical(sourceInfo, DartInfo.pendingInstance)) { | |
| 1389 sourceInfo = internalComputeKindOf(source); | |
| 1390 if (sourceInfo is CompilationUnitInfo) { | |
| 1391 return sourceInfo as CompilationUnitInfo; | |
| 1392 } | |
| 1393 } | 2444 } |
| 1394 return null; | 2445 return null; |
| 1395 } | 2446 } |
| 1396 /** | 2447 /** |
| 1397 * Return the HTML unit information associated with the given source, or {@cod
e null} if the | 2448 * Return the HTML unit information associated with the given source, or {@cod
e null} if the |
| 1398 * source is not known to this context. This method should be used to access t
he HTML unit | 2449 * source is not known to this context. This method should be used to access t
he HTML unit |
| 1399 * information rather than accessing the HTML unit map directly because source
s in the SDK are | 2450 * information rather than accessing the HTML unit map directly because source
s in the SDK are |
| 1400 * implicitly part of every analysis context and are therefore only added to t
he map when first | 2451 * implicitly part of every analysis context and are therefore only added to t
he map when first |
| 1401 * accessed. | 2452 * accessed. |
| 1402 * <p> | 2453 * <p> |
| 1403 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2454 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 1404 * @param source the source for which information is being sought | 2455 * @param source the source for which information is being sought |
| 1405 * @return the HTML unit information associated with the given source | 2456 * @return the HTML unit information associated with the given source |
| 1406 */ | 2457 */ |
| 1407 HtmlUnitInfo getHtmlUnitInfo(Source source) { | 2458 HtmlEntry getHtmlEntry(Source source) { |
| 1408 SourceInfo sourceInfo = getSourceInfo(source); | 2459 SourceEntry sourceEntry = getSourceEntry(source); |
| 1409 if (sourceInfo == null) { | 2460 if (sourceEntry == null) { |
| 1410 sourceInfo = new HtmlUnitInfo(); | 2461 sourceEntry = new HtmlEntryImpl(); |
| 1411 _sourceMap[source] = sourceInfo; | 2462 _sourceMap[source] = sourceEntry; |
| 1412 return sourceInfo as HtmlUnitInfo; | 2463 return sourceEntry as HtmlEntry; |
| 1413 } else if (sourceInfo is HtmlUnitInfo) { | 2464 } else if (sourceEntry is HtmlEntry) { |
| 1414 return sourceInfo as HtmlUnitInfo; | 2465 return sourceEntry as HtmlEntry; |
| 1415 } | 2466 } |
| 1416 return null; | 2467 return null; |
| 1417 } | 2468 } |
| 1418 /** | |
| 1419 * Return the library information associated with the given source, or {@code
null} if the source | |
| 1420 * is not known to this context. This method should be used to access the libr
ary information | |
| 1421 * rather than accessing the library map directly because sources in the SDK a
re implicitly part | |
| 1422 * of every analysis context and are therefore only added to the map when firs
t accessed. | |
| 1423 * <p> | |
| 1424 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | |
| 1425 * @param source the source for which information is being sought | |
| 1426 * @return the library information associated with the given source | |
| 1427 */ | |
| 1428 LibraryInfo getLibraryInfo(Source source) { | |
| 1429 SourceInfo sourceInfo = getSourceInfo(source); | |
| 1430 if (sourceInfo == null) { | |
| 1431 sourceInfo = new LibraryInfo(); | |
| 1432 _sourceMap[source] = sourceInfo; | |
| 1433 return sourceInfo as LibraryInfo; | |
| 1434 } else if (sourceInfo is LibraryInfo) { | |
| 1435 return sourceInfo as LibraryInfo; | |
| 1436 } else if (identical(sourceInfo, DartInfo.pendingInstance)) { | |
| 1437 sourceInfo = internalComputeKindOf(source); | |
| 1438 if (sourceInfo is LibraryInfo) { | |
| 1439 return sourceInfo as LibraryInfo; | |
| 1440 } | |
| 1441 } | |
| 1442 return null; | |
| 1443 } | |
| 1444 /** | 2469 /** |
| 1445 * Return the sources of libraries that are referenced in the specified HTML f
ile. | 2470 * Return the sources of libraries that are referenced in the specified HTML f
ile. |
| 1446 * @param htmlSource the source of the HTML file being analyzed | 2471 * @param htmlSource the source of the HTML file being analyzed |
| 1447 * @param htmlUnit the AST for the HTML file being analyzed | 2472 * @param htmlUnit the AST for the HTML file being analyzed |
| 1448 * @return the sources of libraries that are referenced in the HTML file | 2473 * @return the sources of libraries that are referenced in the HTML file |
| 1449 */ | 2474 */ |
| 1450 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) { | 2475 List<Source> getLibrarySources2(Source htmlSource, HtmlUnit htmlUnit) { |
| 1451 List<Source> libraries = new List<Source>(); | 2476 List<Source> libraries = new List<Source>(); |
| 1452 htmlUnit.accept(new RecursiveXmlVisitor_6(this, htmlSource, libraries)); | 2477 htmlUnit.accept(new RecursiveXmlVisitor_6(this, htmlSource, libraries)); |
| 1453 if (libraries.isEmpty) { | 2478 if (libraries.isEmpty) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1471 /** | 2496 /** |
| 1472 * Return the source information associated with the given source, or {@code n
ull} if the source | 2497 * Return the source information associated with the given source, or {@code n
ull} if the source |
| 1473 * is not known to this context. This method should be used to access the sour
ce information | 2498 * is not known to this context. This method should be used to access the sour
ce information |
| 1474 * rather than accessing the source map directly because sources in the SDK ar
e implicitly part of | 2499 * rather than accessing the source map directly because sources in the SDK ar
e implicitly part of |
| 1475 * every analysis context and are therefore only added to the map when first a
ccessed. | 2500 * every analysis context and are therefore only added to the map when first a
ccessed. |
| 1476 * <p> | 2501 * <p> |
| 1477 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2502 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 1478 * @param source the source for which information is being sought | 2503 * @param source the source for which information is being sought |
| 1479 * @return the source information associated with the given source | 2504 * @return the source information associated with the given source |
| 1480 */ | 2505 */ |
| 1481 SourceInfo getSourceInfo(Source source) { | 2506 SourceEntry getSourceEntry(Source source) { |
| 1482 SourceInfo sourceInfo = _sourceMap[source]; | 2507 SourceEntry sourceEntry = _sourceMap[source]; |
| 1483 if (sourceInfo == null) { | 2508 if (sourceEntry == null) { |
| 1484 sourceInfo = createSourceInfo(source); | 2509 sourceEntry = createSourceEntry(source); |
| 1485 } | 2510 } |
| 1486 return sourceInfo; | 2511 return sourceEntry; |
| 1487 } | 2512 } |
| 1488 /** | 2513 /** |
| 1489 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 2514 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
| 1490 * @param kind the kind of sources to be returned | 2515 * @param kind the kind of sources to be returned |
| 1491 * @return all of the sources known to this context that have the given kind | 2516 * @return all of the sources known to this context that have the given kind |
| 1492 */ | 2517 */ |
| 1493 List<Source> getSources(SourceKind kind2) { | 2518 List<Source> getSources(SourceKind kind2) { |
| 1494 List<Source> sources = new List<Source>(); | 2519 List<Source> sources = new List<Source>(); |
| 1495 { | 2520 { |
| 1496 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) { | 2521 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 1497 if (identical(entry.getValue().kind, kind2)) { | 2522 if (identical(entry.getValue().kind, kind2)) { |
| 1498 sources.add(entry.getKey()); | 2523 sources.add(entry.getKey()); |
| 1499 } | 2524 } |
| 1500 } | 2525 } |
| 1501 } | 2526 } |
| 1502 return new List.from(sources); | 2527 return new List.from(sources); |
| 1503 } | 2528 } |
| 1504 /** | 2529 /** |
| 1505 * Return {@code true} if the given compilation unit has a part-of directive b
ut no library | 2530 * Return {@code true} if the given compilation unit has a part-of directive b
ut no library |
| 1506 * directive. | 2531 * directive. |
| 1507 * @param unit the compilation unit being tested | 2532 * @param unit the compilation unit being tested |
| 1508 * @return {@code true} if the compilation unit has a part-of directive | 2533 * @return {@code true} if the compilation unit has a part-of directive |
| 1509 */ | 2534 */ |
| 1510 bool hasPartOfDirective(CompilationUnit unit) { | 2535 bool hasPartOfDirective(CompilationUnit unit) { |
| 1511 bool hasPartOf = false; | 2536 bool hasPartOf = false; |
| 1512 for (Directive directive in unit.directives) { | 2537 for (Directive directive in unit.directives) { |
| 1513 if (directive is PartOfDirective) { | 2538 if (directive is PartOfDirective) { |
| 1514 hasPartOf = true; | 2539 hasPartOf = true; |
| 1515 } else if (directive is LibraryDirective) { | 2540 } else if (directive is LibraryDirective) { |
| 1516 return false; | 2541 return false; |
| 1517 } | 2542 } |
| 1518 } | 2543 } |
| 1519 return hasPartOf; | 2544 return hasPartOf; |
| 1520 } | 2545 } |
| 1521 /** | 2546 /** |
| 1522 * Compute the kind of the given source. This method should only be invoked wh
en the kind is not | 2547 * Compute the kind of the given source. This method should only be invoked wh
en the kind is not |
| 1523 * already known. In such a case the source is currently being represented by
a {@link DartInfo}. | 2548 * already known. |
| 1524 * After this method has run the source will be represented by a new informati
on object that is | |
| 1525 * appropriate to the computed kind of the source. | |
| 1526 * @param source the source for which a kind is to be computed | 2549 * @param source the source for which a kind is to be computed |
| 1527 * @return the new source info that was created to represent the source | 2550 * @return the new source info that was created to represent the source |
| 1528 */ | 2551 */ |
| 1529 SourceInfo internalComputeKindOf(Source source) { | 2552 DartEntry internalComputeKindOf(Source source) { |
| 1530 try { | 2553 try { |
| 1531 accessed(source); | 2554 accessed(source); |
| 1532 RecordingErrorListener errorListener = new RecordingErrorListener(); | 2555 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1533 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList
ener); | 2556 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorList
ener); |
| 1534 Parser parser = new Parser(source, errorListener); | 2557 Parser parser = new Parser(source, errorListener); |
| 1535 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); | 2558 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); |
| 1536 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); | 2559 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); |
| 1537 List<AnalysisError> errors = errorListener.getErrors2(source); | 2560 List<AnalysisError> errors = errorListener.getErrors2(source); |
| 1538 unit.parsingErrors = errors; | 2561 unit.parsingErrors = errors; |
| 1539 unit.lineInfo = lineInfo; | 2562 unit.lineInfo = lineInfo; |
| 1540 CompilationUnitInfo sourceInfo; | 2563 DartEntryImpl dartEntry = _sourceMap[source] as DartEntryImpl; |
| 1541 if (hasPartOfDirective(unit)) { | 2564 if (hasPartOfDirective(unit)) { |
| 1542 sourceInfo = new CompilationUnitInfo(); | 2565 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
| 1543 } else { | 2566 } else { |
| 1544 sourceInfo = new LibraryInfo(); | 2567 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 1545 } | 2568 } |
| 1546 sourceInfo.lineInfo = lineInfo; | 2569 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 1547 sourceInfo.parsedCompilationUnit = unit; | 2570 dartEntry.setValue(DartEntry.PARSED_UNIT, unit); |
| 1548 sourceInfo.parseErrors = errors; | 2571 dartEntry.setValue(DartEntry.PARSE_ERRORS, errors); |
| 1549 _sourceMap[source] = sourceInfo; | 2572 return dartEntry; |
| 1550 return sourceInfo; | |
| 1551 } on AnalysisException catch (exception) { | 2573 } on AnalysisException catch (exception) { |
| 1552 DartInfo sourceInfo = DartInfo.errorInstance; | 2574 DartEntryImpl dartEntry = _sourceMap[source] as DartEntryImpl; |
| 1553 _sourceMap[source] = sourceInfo; | 2575 dartEntry.setState(DartEntry.SOURCE_KIND, CacheState.ERROR); |
| 1554 return sourceInfo; | 2576 dartEntry.setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
| 2577 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.ERROR); |
| 2578 dartEntry.setState(DartEntry.PARSE_ERRORS, CacheState.ERROR); |
| 2579 return dartEntry; |
| 1555 } | 2580 } |
| 1556 } | 2581 } |
| 1557 CompilationUnit internalParseCompilationUnit(CompilationUnitInfo compilationUn
itInfo, Source source) { | 2582 CompilationUnit internalParseCompilationUnit(DartEntryImpl dartEntry, Source s
ource) { |
| 1558 accessed(source); | 2583 accessed(source); |
| 1559 RecordingErrorListener errorListener = new RecordingErrorListener(); | 2584 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 1560 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorListen
er); | 2585 AnalysisContextImpl_ScanResult scanResult = internalScan(source, errorListen
er); |
| 1561 Parser parser = new Parser(source, errorListener); | 2586 Parser parser = new Parser(source, errorListener); |
| 1562 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); | 2587 CompilationUnit unit = parser.parseCompilationUnit(scanResult._token); |
| 1563 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); | 2588 LineInfo lineInfo = new LineInfo(scanResult._lineStarts); |
| 1564 List<AnalysisError> errors = errorListener.getErrors2(source); | 2589 List<AnalysisError> errors = errorListener.getErrors2(source); |
| 1565 unit.parsingErrors = errors; | 2590 unit.parsingErrors = errors; |
| 1566 unit.lineInfo = lineInfo; | 2591 unit.lineInfo = lineInfo; |
| 1567 compilationUnitInfo.lineInfo = lineInfo; | 2592 if (identical(dartEntry.getState(DartEntry.SOURCE_KIND), CacheState.INVALID)
) { |
| 1568 compilationUnitInfo.parsedCompilationUnit = unit; | 2593 if (hasPartOfDirective(unit)) { |
| 1569 compilationUnitInfo.parseErrors = errors; | 2594 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
| 2595 } else { |
| 2596 dartEntry.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 2597 } |
| 2598 } |
| 2599 dartEntry.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 2600 dartEntry.setValue(DartEntry.PARSED_UNIT, unit); |
| 2601 dartEntry.setValue(DartEntry.PARSE_ERRORS, errors); |
| 1570 return unit; | 2602 return unit; |
| 1571 } | 2603 } |
| 1572 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen
er errorListener) { | 2604 AnalysisContextImpl_ScanResult internalScan(Source source, AnalysisErrorListen
er errorListener) { |
| 1573 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult()
; | 2605 AnalysisContextImpl_ScanResult result = new AnalysisContextImpl_ScanResult()
; |
| 1574 Source_ContentReceiver receiver = new Source_ContentReceiver_7(source, error
Listener, result); | 2606 Source_ContentReceiver receiver = new Source_ContentReceiver_7(source, error
Listener, result); |
| 1575 try { | 2607 try { |
| 1576 source.getContents(receiver); | 2608 source.getContents(receiver); |
| 1577 } catch (exception) { | 2609 } catch (exception) { |
| 1578 throw new AnalysisException.con3(exception); | 2610 throw new AnalysisException.con3(exception); |
| 1579 } | 2611 } |
| 1580 return result; | 2612 return result; |
| 1581 } | 2613 } |
| 1582 /** | 2614 /** |
| 1583 * In response to a change to at least one of the compilation units in the giv
en library, | 2615 * In response to a change to at least one of the compilation units in the giv
en library, |
| 1584 * invalidate any results that are dependent on the result of resolving that l
ibrary. | 2616 * invalidate any results that are dependent on the result of resolving that l
ibrary. |
| 1585 * @param librarySource the source of the library being invalidated | 2617 * @param librarySource the source of the library being invalidated |
| 1586 * @param libraryInfo the information for the library being invalidated | 2618 * @param libraryEntry the cache entry for the library being invalidated |
| 1587 */ | 2619 */ |
| 1588 void invalidateLibraryResolution(Source librarySource, LibraryInfo libraryInfo
) { | 2620 void invalidateLibraryResolution(Source librarySource, DartEntryImpl libraryEn
try) { |
| 1589 if (libraryInfo != null) { | 2621 if (libraryEntry != null) { |
| 1590 libraryInfo.invalidateElement(); | 2622 for (Source unitSource in libraryEntry.getValue(DartEntry.INCLUDED_PARTS))
{ |
| 1591 libraryInfo.invalidateLaunchable(); | 2623 DartEntryImpl partEntry = getDartEntry(unitSource) as DartEntryImpl; |
| 1592 libraryInfo.invalidatePublicNamespace(); | 2624 partEntry.invalidateAllResolutionInformation(); |
| 1593 libraryInfo.invalidateResolutionErrors(); | |
| 1594 libraryInfo.invalidateResolvedUnit(); | |
| 1595 for (Source unitSource in libraryInfo.unitSources) { | |
| 1596 CompilationUnitInfo partInfo = getCompilationUnitInfo(unitSource); | |
| 1597 partInfo.invalidateResolutionErrors(); | |
| 1598 partInfo.invalidateResolvedUnit(); | |
| 1599 } | 2625 } |
| 1600 libraryInfo.invalidateUnitSources(); | 2626 libraryEntry.invalidateAllResolutionInformation(); |
| 2627 libraryEntry.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); |
| 1601 } | 2628 } |
| 1602 } | 2629 } |
| 1603 /** | 2630 /** |
| 1604 * Return {@code true} if this library is, or depends on, dart:html. | 2631 * Return {@code true} if this library is, or depends on, dart:html. |
| 1605 * @param library the library being tested | 2632 * @param library the library being tested |
| 1606 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent | 2633 * @param visitedLibraries a collection of the libraries that have been visite
d, used to prevent |
| 1607 * infinite recursion | 2634 * infinite recursion |
| 1608 * @return {@code true} if this library is, or depends on, dart:html | 2635 * @return {@code true} if this library is, or depends on, dart:html |
| 1609 */ | 2636 */ |
| 1610 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v
isitedLibraries) { | 2637 bool isClient(LibraryElement library, Source htmlSource, Set<LibraryElement> v
isitedLibraries) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1627 } | 2654 } |
| 1628 return false; | 2655 return false; |
| 1629 } | 2656 } |
| 1630 /** | 2657 /** |
| 1631 * Perform a single analysis task. | 2658 * Perform a single analysis task. |
| 1632 * <p> | 2659 * <p> |
| 1633 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2660 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 1634 * @return {@code true} if work was done, implying that there might be more wo
rk to be done | 2661 * @return {@code true} if work was done, implying that there might be more wo
rk to be done |
| 1635 */ | 2662 */ |
| 1636 bool performSingleAnalysisTask() { | 2663 bool performSingleAnalysisTask() { |
| 1637 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) { | 2664 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 1638 SourceInfo sourceInfo = entry.getValue(); | 2665 SourceEntry sourceEntry = entry.getValue(); |
| 1639 if (identical(sourceInfo, DartInfo.pendingInstance)) { | 2666 if (sourceEntry is DartEntry) { |
| 1640 internalComputeKindOf(entry.getKey()); | 2667 DartEntry dartEntry = sourceEntry as DartEntry; |
| 1641 return true; | 2668 CacheState parsedUnitState = dartEntry.getState(DartEntry.PARSED_UNIT); |
| 1642 } | 2669 if (identical(parsedUnitState, CacheState.INVALID)) { |
| 1643 } | |
| 1644 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) { | |
| 1645 SourceInfo sourceInfo = entry.getValue(); | |
| 1646 if (sourceInfo is CompilationUnitInfo) { | |
| 1647 CompilationUnitInfo unitInfo = sourceInfo as CompilationUnitInfo; | |
| 1648 if (unitInfo.hasInvalidParsedUnit()) { | |
| 1649 try { | 2670 try { |
| 1650 parseCompilationUnit(entry.getKey()); | 2671 parseCompilationUnit(entry.getKey()); |
| 1651 } on AnalysisException catch (exception) { | 2672 } on AnalysisException catch (exception) { |
| 1652 unitInfo.parsedCompilationUnit = null; | 2673 ((dartEntry as DartEntryImpl)).setState(DartEntry.PARSED_UNIT, Cache
State.ERROR); |
| 1653 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); | 2674 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); |
| 1654 } | 2675 } |
| 1655 return true; | 2676 return true; |
| 1656 } | 2677 } |
| 1657 } else if (sourceInfo is HtmlUnitInfo) { | 2678 } else if (sourceEntry is HtmlEntry) { |
| 1658 HtmlUnitInfo unitInfo = sourceInfo as HtmlUnitInfo; | 2679 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 1659 if (unitInfo.hasInvalidParsedUnit()) { | 2680 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); |
| 2681 if (identical(parsedUnitState, CacheState.INVALID)) { |
| 1660 try { | 2682 try { |
| 1661 parseHtmlUnit(entry.getKey()); | 2683 parseHtmlUnit(entry.getKey()); |
| 1662 } on AnalysisException catch (exception) { | 2684 } on AnalysisException catch (exception) { |
| 1663 unitInfo.parsedUnit = null; | 2685 ((htmlEntry as HtmlEntryImpl)).setState(HtmlEntry.PARSED_UNIT, Cache
State.ERROR); |
| 1664 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); | 2686 AnalysisEngine.instance.logger.logError2("Could not parse ${entry.ge
tKey().fullName}", exception); |
| 1665 } | 2687 } |
| 1666 return true; | 2688 return true; |
| 1667 } | 2689 } |
| 1668 } | 2690 } |
| 1669 } | 2691 } |
| 1670 for (MapEntry<Source, SourceInfo> entry in getMapEntrySet(_sourceMap)) { | 2692 for (MapEntry<Source, SourceEntry> entry in getMapEntrySet(_sourceMap)) { |
| 1671 SourceInfo sourceInfo = entry.getValue(); | 2693 SourceEntry sourceEntry = entry.getValue(); |
| 1672 if (sourceInfo is LibraryInfo) { | 2694 if (sourceEntry is DartEntry && identical(sourceEntry.kind, SourceKind.LIB
RARY)) { |
| 1673 LibraryInfo libraryInfo = sourceInfo as LibraryInfo; | 2695 DartEntry dartEntry = sourceEntry as DartEntry; |
| 1674 if (libraryInfo.hasInvalidElement()) { | 2696 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); |
| 2697 if (identical(elementState, CacheState.INVALID)) { |
| 1675 try { | 2698 try { |
| 1676 computeLibraryElement(entry.getKey()); | 2699 computeLibraryElement(entry.getKey()); |
| 1677 } on AnalysisException catch (exception) { | 2700 } on AnalysisException catch (exception) { |
| 1678 libraryInfo.element = null; | 2701 ((dartEntry as DartEntryImpl)).setState(DartEntry.ELEMENT, CacheStat
e.ERROR); |
| 1679 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); | 2702 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); |
| 1680 } | 2703 } |
| 1681 return true; | 2704 return true; |
| 1682 } | 2705 } |
| 1683 } else if (sourceInfo is HtmlUnitInfo) { | 2706 } else if (sourceEntry is HtmlEntry) { |
| 1684 HtmlUnitInfo unitInfo = sourceInfo as HtmlUnitInfo; | 2707 HtmlEntry htmlEntry = sourceEntry as HtmlEntry; |
| 1685 if (unitInfo.hasInvalidResolvedUnit()) { | 2708 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNI
T); |
| 2709 if (identical(resolvedUnitState, CacheState.INVALID)) { |
| 1686 try { | 2710 try { |
| 1687 resolveHtmlUnit(entry.getKey()); | 2711 resolveHtmlUnit(entry.getKey()); |
| 1688 } on AnalysisException catch (exception) { | 2712 } on AnalysisException catch (exception) { |
| 1689 unitInfo.resolvedUnit = null; | 2713 ((htmlEntry as HtmlEntryImpl)).setState(HtmlEntry.RESOLVED_UNIT, Cac
heState.ERROR); |
| 1690 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); | 2714 AnalysisEngine.instance.logger.logError2("Could not resolve ${entry.
getKey().fullName}", exception); |
| 1691 } | 2715 } |
| 1692 return true; | 2716 return true; |
| 1693 } | 2717 } |
| 1694 } | 2718 } |
| 1695 } | 2719 } |
| 1696 return false; | 2720 return false; |
| 1697 } | 2721 } |
| 1698 HtmlScanResult scanHtml(Source source) { | 2722 HtmlScanResult scanHtml(Source source) { |
| 1699 HtmlScanner scanner = new HtmlScanner(source); | 2723 HtmlScanner scanner = new HtmlScanner(source); |
| 1700 try { | 2724 try { |
| 1701 source.getContents(scanner); | 2725 source.getContents(scanner); |
| 1702 } catch (exception) { | 2726 } catch (exception) { |
| 1703 throw new AnalysisException.con3(exception); | 2727 throw new AnalysisException.con3(exception); |
| 1704 } | 2728 } |
| 1705 return scanner.result; | 2729 return scanner.result; |
| 1706 } | 2730 } |
| 1707 /** | 2731 /** |
| 2732 * Create an entry for the newly added source. Return {@code true} if the new
source is a Dart |
| 2733 * file. |
| 2734 * <p> |
| 1708 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2735 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 1709 * @param source the source that has been added | 2736 * @param source the source that has been added |
| 2737 * @return {@code true} if the new source is a Dart file |
| 1710 */ | 2738 */ |
| 1711 void sourceAvailable(Source source) { | 2739 bool sourceAvailable(Source source) { |
| 1712 SourceInfo existingInfo = _sourceMap[source]; | 2740 SourceEntry sourceEntry = _sourceMap[source]; |
| 1713 if (existingInfo == null) { | 2741 if (sourceEntry == null) { |
| 1714 createSourceInfo(source); | 2742 sourceEntry = createSourceEntry(source); |
| 1715 } | 2743 } |
| 2744 return sourceEntry is DartEntry; |
| 1716 } | 2745 } |
| 1717 /** | 2746 /** |
| 1718 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2747 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 1719 * @param source the source that has been changed | 2748 * @param source the source that has been changed |
| 1720 */ | 2749 */ |
| 1721 void sourceChanged(Source source) { | 2750 void sourceChanged(Source source) { |
| 1722 SourceInfo sourceInfo = _sourceMap[source]; | 2751 SourceEntry sourceEntry = _sourceMap[source]; |
| 1723 if (sourceInfo is HtmlUnitInfo) { | 2752 if (sourceEntry is HtmlEntry) { |
| 1724 HtmlUnitInfo htmlUnitInfo = sourceInfo as HtmlUnitInfo; | 2753 HtmlEntryImpl htmlEntry = sourceEntry as HtmlEntryImpl; |
| 1725 htmlUnitInfo.invalidateElement(); | 2754 htmlEntry.setState(HtmlEntry.ELEMENT, CacheState.INVALID); |
| 1726 htmlUnitInfo.invalidateLineInfo(); | 2755 htmlEntry.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 1727 htmlUnitInfo.invalidateParsedUnit(); | 2756 htmlEntry.setState(HtmlEntry.PARSED_UNIT, CacheState.INVALID); |
| 1728 htmlUnitInfo.invalidateResolvedUnit(); | 2757 htmlEntry.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.INVALID); |
| 1729 } else if (sourceInfo is LibraryInfo) { | 2758 htmlEntry.setState(HtmlEntry.RESOLVED_UNIT, CacheState.INVALID); |
| 1730 LibraryInfo libraryInfo = sourceInfo as LibraryInfo; | 2759 } else if (sourceEntry is DartEntry) { |
| 1731 invalidateLibraryResolution(source, libraryInfo); | 2760 DartEntryImpl dartEntry = sourceEntry as DartEntryImpl; |
| 1732 _sourceMap[source] = DartInfo.pendingInstance; | 2761 List<Source> containingLibraries = getLibrariesContaining(source); |
| 1733 } else if (sourceInfo is CompilationUnitInfo) { | 2762 invalidateLibraryResolution(source, dartEntry); |
| 1734 for (Source librarySource in getLibrariesContaining(source)) { | 2763 dartEntry.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); |
| 1735 LibraryInfo libraryInfo = getLibraryInfo(librarySource); | 2764 dartEntry.setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 1736 invalidateLibraryResolution(librarySource, libraryInfo); | 2765 dartEntry.setState(DartEntry.PARSE_ERRORS, CacheState.INVALID); |
| 2766 dartEntry.setState(DartEntry.PARSED_UNIT, CacheState.INVALID); |
| 2767 dartEntry.setState(DartEntry.SOURCE_KIND, CacheState.INVALID); |
| 2768 for (Source librarySource in containingLibraries) { |
| 2769 DartEntryImpl libraryEntry = getDartEntry(librarySource) as DartEntryImp
l; |
| 2770 invalidateLibraryResolution(librarySource, libraryEntry); |
| 1737 } | 2771 } |
| 1738 _sourceMap[source] = DartInfo.pendingInstance; | |
| 1739 } | 2772 } |
| 1740 } | 2773 } |
| 1741 /** | 2774 /** |
| 1742 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. | 2775 * <b>Note:</b> This method must only be invoked while we are synchronized on
{@link #cacheLock}. |
| 1743 * @param source the source that has been deleted | 2776 * @param source the source that has been deleted |
| 1744 */ | 2777 */ |
| 1745 void sourceRemoved(Source source) { | 2778 void sourceRemoved(Source source) { |
| 1746 CompilationUnitInfo compilationUnitInfo = getCompilationUnitInfo(source); | 2779 DartEntry dartEntry = getDartEntry(source); |
| 1747 if (compilationUnitInfo != null) { | 2780 if (dartEntry != null) { |
| 1748 for (Source librarySource in getLibrariesContaining(source)) { | 2781 for (Source librarySource in getLibrariesContaining(source)) { |
| 1749 LibraryInfo libraryInfo = getLibraryInfo(librarySource); | 2782 DartEntryImpl libraryEntry = getDartEntry(librarySource) as DartEntryImp
l; |
| 1750 invalidateLibraryResolution(librarySource, libraryInfo); | 2783 invalidateLibraryResolution(librarySource, libraryEntry); |
| 1751 } | 2784 } |
| 1752 } | 2785 } |
| 1753 _sourceMap.remove(source); | 2786 _sourceMap.remove(source); |
| 1754 } | 2787 } |
| 1755 } | 2788 } |
| 1756 /** | 2789 /** |
| 1757 * Instances of the class {@code ScanResult} represent the results of scanning a
source. | 2790 * Instances of the class {@code ScanResult} represent the results of scanning a
source. |
| 1758 */ | 2791 */ |
| 1759 class AnalysisContextImpl_ScanResult { | 2792 class AnalysisContextImpl_ScanResult { |
| 1760 /** | 2793 /** |
| 1761 * The time at which the contents of the source were last set. | 2794 * The time at which the contents of the source were last set. |
| 1762 */ | 2795 */ |
| 1763 int _modificationTime = 0; | 2796 int _modificationTime = 0; |
| 1764 /** | 2797 /** |
| 1765 * The first token in the token stream. | 2798 * The first token in the token stream. |
| 1766 */ | 2799 */ |
| 1767 Token _token; | 2800 Token _token; |
| 1768 /** | 2801 /** |
| 1769 * The line start information that was produced. | 2802 * The line start information that was produced. |
| 1770 */ | 2803 */ |
| 1771 List<int> _lineStarts; | 2804 List<int> _lineStarts; |
| 1772 /** | 2805 /** |
| 1773 * Initialize a newly created result object to be empty. | 2806 * Initialize a newly created result object to be empty. |
| 1774 */ | 2807 */ |
| 1775 AnalysisContextImpl_ScanResult() : super() { | 2808 AnalysisContextImpl_ScanResult() : super() { |
| 1776 } | 2809 } |
| 1777 } | 2810 } |
| 2811 class Source_ContentReceiver_5 implements Source_ContentReceiver { |
| 2812 List<CharSequence> contentHolder; |
| 2813 Source_ContentReceiver_5(this.contentHolder); |
| 2814 void accept(CharBuffer contents, int modificationTime) { |
| 2815 contentHolder[0] = contents; |
| 2816 } |
| 2817 void accept2(String contents, int modificationTime) { |
| 2818 contentHolder[0] = new CharSequence(contents); |
| 2819 } |
| 2820 } |
| 1778 class RecursiveXmlVisitor_6 extends RecursiveXmlVisitor<Object> { | 2821 class RecursiveXmlVisitor_6 extends RecursiveXmlVisitor<Object> { |
| 1779 final AnalysisContextImpl AnalysisContextImpl_this; | 2822 final AnalysisContextImpl AnalysisContextImpl_this; |
| 1780 Source htmlSource; | 2823 Source htmlSource; |
| 1781 List<Source> libraries; | 2824 List<Source> libraries; |
| 1782 RecursiveXmlVisitor_6(this.AnalysisContextImpl_this, this.htmlSource, this.lib
raries) : super(); | 2825 RecursiveXmlVisitor_6(this.AnalysisContextImpl_this, this.htmlSource, this.lib
raries) : super(); |
| 1783 Object visitXmlTagNode(XmlTagNode node) { | 2826 Object visitXmlTagNode(XmlTagNode node) { |
| 1784 if (javaStringEqualsIgnoreCase(node.tag.lexeme, AnalysisContextImpl._TAG_SCR
IPT)) { | 2827 if (javaStringEqualsIgnoreCase(node.tag.lexeme, AnalysisContextImpl._TAG_SCR
IPT)) { |
| 1785 for (XmlAttributeNode attribute in node.attributes) { | 2828 for (XmlAttributeNode attribute in node.attributes) { |
| 1786 if (javaStringEqualsIgnoreCase(attribute.name.lexeme, AnalysisContextImp
l._ATTRIBUTE_SRC)) { | 2829 if (javaStringEqualsIgnoreCase(attribute.name.lexeme, AnalysisContextImp
l._ATTRIBUTE_SRC)) { |
| 1787 try { | 2830 try { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1852 * errors. | 2895 * errors. |
| 1853 * @return the line information associated with the errors | 2896 * @return the line information associated with the errors |
| 1854 */ | 2897 */ |
| 1855 LineInfo get lineInfo => _lineInfo; | 2898 LineInfo get lineInfo => _lineInfo; |
| 1856 } | 2899 } |
| 1857 /** | 2900 /** |
| 1858 * The enumeration {@code CacheState} defines the possible states of cached data
. | 2901 * The enumeration {@code CacheState} defines the possible states of cached data
. |
| 1859 */ | 2902 */ |
| 1860 class CacheState implements Comparable<CacheState> { | 2903 class CacheState implements Comparable<CacheState> { |
| 1861 /** | 2904 /** |
| 1862 * A state representing the fact that the data was up-to-date but flushed from
the cache in order | 2905 * The data is not in the cache and the last time an attempt was made to compu
te the data an |
| 1863 * to control memory usage. | 2906 * exception occurred, making it pointless to attempt. |
| 2907 * <p> |
| 2908 * Valid Transitions: |
| 2909 * <ul> |
| 2910 * <li>{@link #INVALID} if a source was modified that might cause the data to
be computable</li> |
| 2911 * </ul> |
| 1864 */ | 2912 */ |
| 1865 static final CacheState FLUSHED = new CacheState('FLUSHED', 0); | 2913 static final CacheState ERROR = new CacheState('ERROR', 0); |
| 1866 /** | 2914 /** |
| 1867 * A state representing the fact that the data was removed from the cache beca
use it was invalid | 2915 * The data is not in the cache because it was flushed from the cache in order
to control memory |
| 1868 * and needs to be recomputed. | 2916 * usage. If the data is recomputed, results do not need to be reported. |
| 2917 * <p> |
| 2918 * Valid Transitions: |
| 2919 * <ul> |
| 2920 * <li>{@link #IN_PROCESS} if the data is being recomputed</li> |
| 2921 * <li>{@link #INVALID} if a source was modified that causes the data to need
to be recomputed</li> |
| 2922 * </ul> |
| 1869 */ | 2923 */ |
| 1870 static final CacheState INVALID = new CacheState('INVALID', 1); | 2924 static final CacheState FLUSHED = new CacheState('FLUSHED', 1); |
| 1871 /** | 2925 /** |
| 1872 * A state representing the fact that the data is in the cache and valid. | 2926 * The data might or might not be in the cache but is in the process of being
recomputed. |
| 2927 * <p> |
| 2928 * Valid Transitions: |
| 2929 * <ul> |
| 2930 * <li>{@link #ERROR} if an exception occurred while trying to compute the dat
a</li> |
| 2931 * <li>{@link #VALID} if the data was successfully computed and stored in the
cache</li> |
| 2932 * </ul> |
| 1873 */ | 2933 */ |
| 1874 static final CacheState VALID = new CacheState('VALID', 2); | 2934 static final CacheState IN_PROCESS = new CacheState('IN_PROCESS', 2); |
| 1875 static final List<CacheState> values = [FLUSHED, INVALID, VALID]; | 2935 /** |
| 2936 * The data is not in the cache and needs to be recomputed so that results can
be reported. |
| 2937 * <p> |
| 2938 * Valid Transitions: |
| 2939 * <ul> |
| 2940 * <li>{@link #IN_PROCESS} if an attempt is being made to recompute the data</
li> |
| 2941 * </ul> |
| 2942 */ |
| 2943 static final CacheState INVALID = new CacheState('INVALID', 3); |
| 2944 /** |
| 2945 * The data is in the cache and up-to-date. |
| 2946 * <p> |
| 2947 * Valid Transitions: |
| 2948 * <ul> |
| 2949 * <li>{@link #FLUSHED} if the data is removed in order to manage memory usage
</li> |
| 2950 * <li>{@link #INVALID} if a source was modified in such a way as to invalidat
e the previous data</li> |
| 2951 * </ul> |
| 2952 */ |
| 2953 static final CacheState VALID = new CacheState('VALID', 4); |
| 2954 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V
ALID]; |
| 1876 final String __name; | 2955 final String __name; |
| 1877 final int __ordinal; | 2956 final int __ordinal; |
| 1878 int get ordinal => __ordinal; | 2957 int get ordinal => __ordinal; |
| 1879 CacheState(this.__name, this.__ordinal) { | 2958 CacheState(this.__name, this.__ordinal) { |
| 1880 } | 2959 } |
| 1881 int compareTo(CacheState other) => __ordinal - other.__ordinal; | 2960 int compareTo(CacheState other) => __ordinal - other.__ordinal; |
| 1882 String toString() => __name; | 2961 String toString() => __name; |
| 1883 } | 2962 } |
| 1884 /** | 2963 /** |
| 1885 * Instances of the class {@code ChangeNoticeImpl} represent a change to the ana
lysis results | 2964 * Instances of the class {@code ChangeNoticeImpl} represent a change to the ana
lysis results |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 * information to the given line information. | 3030 * information to the given line information. |
| 1952 * @param errors the errors that changed as a result of the analysis | 3031 * @param errors the errors that changed as a result of the analysis |
| 1953 * @param lineInfo the line information associated with the source | 3032 * @param lineInfo the line information associated with the source |
| 1954 */ | 3033 */ |
| 1955 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) { | 3034 void setErrors(List<AnalysisError> errors2, LineInfo lineInfo2) { |
| 1956 this._errors = errors2; | 3035 this._errors = errors2; |
| 1957 this._lineInfo = lineInfo2; | 3036 this._lineInfo = lineInfo2; |
| 1958 } | 3037 } |
| 1959 } | 3038 } |
| 1960 /** | 3039 /** |
| 1961 * Instances of the class {@code CompilationUnitInfo} maintain the information c
ached by an analysis | |
| 1962 * context about an individual compilation unit. | |
| 1963 * @coverage dart.engine | |
| 1964 */ | |
| 1965 class CompilationUnitInfo extends SourceInfo { | |
| 1966 /** | |
| 1967 * The state of the cached parsed compilation unit. | |
| 1968 */ | |
| 1969 CacheState _parsedUnitState = CacheState.INVALID; | |
| 1970 /** | |
| 1971 * The parsed compilation unit, or {@code null} if the parsed compilation unit
is not currently | |
| 1972 * cached. | |
| 1973 */ | |
| 1974 CompilationUnit _parsedUnit; | |
| 1975 /** | |
| 1976 * The state of the cached resolved compilation unit. | |
| 1977 */ | |
| 1978 CacheState _resolvedUnitState = CacheState.INVALID; | |
| 1979 /** | |
| 1980 * The resolved compilation unit, or {@code null} if the resolved compilation
unit is not | |
| 1981 * currently cached. | |
| 1982 */ | |
| 1983 CompilationUnit _resolvedUnit; | |
| 1984 /** | |
| 1985 * The state of the cached parse errors. | |
| 1986 */ | |
| 1987 CacheState _parseErrorsState = CacheState.INVALID; | |
| 1988 /** | |
| 1989 * The errors produced while scanning and parsing the compilation unit, or {@c
ode null} if the | |
| 1990 * errors are not currently cached. | |
| 1991 */ | |
| 1992 List<AnalysisError> _parseErrors; | |
| 1993 /** | |
| 1994 * The state of the cached resolution errors. | |
| 1995 */ | |
| 1996 CacheState _resolutionErrorsState = CacheState.INVALID; | |
| 1997 /** | |
| 1998 * The errors produced while resolving the compilation unit, or {@code null} i
f the errors are not | |
| 1999 * currently cached. | |
| 2000 */ | |
| 2001 List<AnalysisError> _resolutionErrors; | |
| 2002 /** | |
| 2003 * Initialize a newly created information holder to be empty. | |
| 2004 */ | |
| 2005 CompilationUnitInfo() : super() { | |
| 2006 } | |
| 2007 /** | |
| 2008 * Remove the parsed compilation unit from the cache. | |
| 2009 */ | |
| 2010 void clearParsedUnit() { | |
| 2011 _parsedUnit = null; | |
| 2012 _parsedUnitState = CacheState.FLUSHED; | |
| 2013 } | |
| 2014 /** | |
| 2015 * Remove the parse errors from the cache. | |
| 2016 */ | |
| 2017 void clearParseErrors() { | |
| 2018 _parseErrors = null; | |
| 2019 _parseErrorsState = CacheState.FLUSHED; | |
| 2020 } | |
| 2021 /** | |
| 2022 * Remove the resolution errors from the cache. | |
| 2023 */ | |
| 2024 void clearResolutionErrors() { | |
| 2025 _resolutionErrors = null; | |
| 2026 _resolutionErrorsState = CacheState.FLUSHED; | |
| 2027 } | |
| 2028 /** | |
| 2029 * Remove the resolved compilation unit from the cache. | |
| 2030 */ | |
| 2031 void clearResolvedUnit() { | |
| 2032 _resolvedUnit = null; | |
| 2033 _resolvedUnitState = CacheState.FLUSHED; | |
| 2034 } | |
| 2035 CompilationUnitInfo copy() { | |
| 2036 CompilationUnitInfo copy = new CompilationUnitInfo(); | |
| 2037 copy.copyFrom(this); | |
| 2038 return copy; | |
| 2039 } | |
| 2040 /** | |
| 2041 * Return all of the errors associated with the compilation unit. | |
| 2042 * @return all of the errors associated with the compilation unit | |
| 2043 */ | |
| 2044 List<AnalysisError> get allErrors { | |
| 2045 if (_parseErrors == null) { | |
| 2046 if (_resolutionErrors == null) { | |
| 2047 return null; | |
| 2048 } | |
| 2049 return _resolutionErrors; | |
| 2050 } else if (_resolutionErrors == null) { | |
| 2051 return _parseErrors; | |
| 2052 } | |
| 2053 int parseCount = _parseErrors.length; | |
| 2054 int resolutionCount = _resolutionErrors.length; | |
| 2055 List<AnalysisError> errors = new List<AnalysisError>(parseCount + resolution
Count); | |
| 2056 JavaSystem.arraycopy(_parseErrors, 0, errors, 0, parseCount); | |
| 2057 JavaSystem.arraycopy(_resolutionErrors, 0, errors, parseCount, resolutionCou
nt); | |
| 2058 return errors; | |
| 2059 } | |
| 2060 SourceKind get kind => SourceKind.PART; | |
| 2061 /** | |
| 2062 * Return the parsed compilation unit, or {@code null} if the parsed compilati
on unit is not | |
| 2063 * currently cached. | |
| 2064 * @return the parsed compilation unit | |
| 2065 */ | |
| 2066 CompilationUnit get parsedCompilationUnit => _parsedUnit; | |
| 2067 /** | |
| 2068 * Return the errors produced while scanning and parsing the compilation unit,
or {@code null} if | |
| 2069 * the errors are not currently cached. | |
| 2070 * @return the errors produced while scanning and parsing the compilation unit | |
| 2071 */ | |
| 2072 List<AnalysisError> get parseErrors => _parseErrors; | |
| 2073 /** | |
| 2074 * Return the errors produced while resolving the compilation unit, or {@code
null} if the errors | |
| 2075 * are not currently cached. | |
| 2076 * @return the errors produced while resolving the compilation unit | |
| 2077 */ | |
| 2078 List<AnalysisError> get resolutionErrors => _resolutionErrors; | |
| 2079 /** | |
| 2080 * Return the resolved compilation unit, or {@code null} if the resolved compi
lation unit is not | |
| 2081 * currently cached. | |
| 2082 * @return the resolved compilation unit | |
| 2083 */ | |
| 2084 CompilationUnit get resolvedCompilationUnit => _resolvedUnit; | |
| 2085 /** | |
| 2086 * Return {@code true} if the parsed compilation unit needs to be recomputed. | |
| 2087 * @return {@code true} if the parsed compilation unit needs to be recomputed | |
| 2088 */ | |
| 2089 bool hasInvalidParsedUnit() => identical(_parsedUnitState, CacheState.INVALID)
; | |
| 2090 /** | |
| 2091 * Return {@code true} if the parse errors needs to be recomputed. | |
| 2092 * @return {@code true} if the parse errors needs to be recomputed | |
| 2093 */ | |
| 2094 bool hasInvalidParseErrors() => identical(_parseErrorsState, CacheState.INVALI
D); | |
| 2095 /** | |
| 2096 * Return {@code true} if the resolution errors needs to be recomputed. | |
| 2097 * @return {@code true} if the resolution errors needs to be recomputed | |
| 2098 */ | |
| 2099 bool hasInvalidResolutionErrors() => identical(_resolutionErrorsState, CacheSt
ate.INVALID); | |
| 2100 /** | |
| 2101 * Return {@code true} if the resolved compilation unit needs to be recomputed
. | |
| 2102 * @return {@code true} if the resolved compilation unit needs to be recompute
d | |
| 2103 */ | |
| 2104 bool hasInvalidResolvedUnit() => identical(_resolvedUnitState, CacheState.INVA
LID); | |
| 2105 /** | |
| 2106 * Mark the parsed compilation unit as needing to be recomputed. | |
| 2107 */ | |
| 2108 void invalidateParsedUnit() { | |
| 2109 _parsedUnitState = CacheState.INVALID; | |
| 2110 _parsedUnit = null; | |
| 2111 } | |
| 2112 /** | |
| 2113 * Mark the parse errors as needing to be recomputed. | |
| 2114 */ | |
| 2115 void invalidateParseErrors() { | |
| 2116 _parseErrorsState = CacheState.INVALID; | |
| 2117 _parseErrors = null; | |
| 2118 } | |
| 2119 /** | |
| 2120 * Mark the resolution errors as needing to be recomputed. | |
| 2121 */ | |
| 2122 void invalidateResolutionErrors() { | |
| 2123 _resolutionErrorsState = CacheState.INVALID; | |
| 2124 _resolutionErrors = null; | |
| 2125 } | |
| 2126 /** | |
| 2127 * Mark the resolved compilation unit as needing to be recomputed. | |
| 2128 */ | |
| 2129 void invalidateResolvedUnit() { | |
| 2130 _resolvedUnitState = CacheState.INVALID; | |
| 2131 _resolvedUnit = null; | |
| 2132 } | |
| 2133 /** | |
| 2134 * Set the parsed compilation unit to the given compilation unit. | |
| 2135 * <p> | |
| 2136 * <b>Note:</b> Do not use this method to clear or invalidate the parsed compi
lation unit. Use | |
| 2137 * either {@link #clear} or {@link #invalidate}. | |
| 2138 * @param unit the parsed compilation unit | |
| 2139 */ | |
| 2140 void set parsedCompilationUnit(CompilationUnit unit) { | |
| 2141 _parsedUnit = unit; | |
| 2142 _parsedUnitState = CacheState.VALID; | |
| 2143 } | |
| 2144 /** | |
| 2145 * Set the errors produced while scanning and parsing the compilation unit to
the given errors. | |
| 2146 * <p> | |
| 2147 * <b>Note:</b> Do not use this method to clear or invalidate the parse errors
. Use either{@link #clear} or {@link #invalidate}. | |
| 2148 * @param errors the errors produced while scanning and parsing the compilatio
n unit | |
| 2149 */ | |
| 2150 void set parseErrors(List<AnalysisError> errors) { | |
| 2151 _parseErrors = errors; | |
| 2152 _parseErrorsState = CacheState.VALID; | |
| 2153 } | |
| 2154 /** | |
| 2155 * Set the errors produced while resolving the compilation unit to the given e
rrors. | |
| 2156 * <p> | |
| 2157 * <b>Note:</b> Do not use this method to clear or invalidate the resolution e
rrors. Use either{@link #clear} or {@link #invalidate}. | |
| 2158 * @param errors the errors produced while resolving the compilation unit | |
| 2159 */ | |
| 2160 void set resolutionErrors(List<AnalysisError> errors) { | |
| 2161 _resolutionErrors = errors; | |
| 2162 _resolutionErrorsState = CacheState.VALID; | |
| 2163 } | |
| 2164 /** | |
| 2165 * Set the resolved compilation unit to the given compilation unit. | |
| 2166 * <p> | |
| 2167 * <b>Note:</b> Do not use this method to clear or invalidate the resolved com
pilation unit. Use | |
| 2168 * either {@link #clear} or {@link #invalidate}. | |
| 2169 * @param unit the resolved compilation unit | |
| 2170 */ | |
| 2171 void set resolvedCompilationUnit(CompilationUnit unit) { | |
| 2172 _resolvedUnit = unit; | |
| 2173 _resolvedUnitState = CacheState.VALID; | |
| 2174 } | |
| 2175 void copyFrom(SourceInfo info) { | |
| 2176 super.copyFrom(info); | |
| 2177 } | |
| 2178 } | |
| 2179 /** | |
| 2180 * Instances of the class {@code DartInfo} acts as a placeholder for Dart compil
ation units that | |
| 2181 * have not yet had their kind computed. | |
| 2182 * @coverage dart.engine | |
| 2183 */ | |
| 2184 class DartInfo extends SourceInfo { | |
| 2185 /** | |
| 2186 * The instance of this class used to represent a compilation unit for which a
n attempt was made | |
| 2187 * to compute the kind but the kind could not be computed. | |
| 2188 */ | |
| 2189 static DartInfo _ErrorInstance = new DartInfo(); | |
| 2190 /** | |
| 2191 * The instance of this class used to represent a compilation unit for which n
o attempt has been | |
| 2192 * made to compute the kind. | |
| 2193 */ | |
| 2194 static DartInfo _PendingInstance = new DartInfo(); | |
| 2195 /** | |
| 2196 * Return an instance of this class representing a compilation unit for which
an attempt was made | |
| 2197 * to compute the kind but the kind could not be computed. | |
| 2198 * @return an instance of this class used to indicate that the computation of
the kind resulted in | |
| 2199 * an error and there is no point trying again | |
| 2200 */ | |
| 2201 static DartInfo get errorInstance => _ErrorInstance; | |
| 2202 /** | |
| 2203 * Return an instance of this class representing a compilation unit for which
no attempt has been | |
| 2204 * made to compute the kind. | |
| 2205 * @return an instance of this class used to indicate that the computation of
the kind is pending | |
| 2206 */ | |
| 2207 static DartInfo get pendingInstance => _PendingInstance; | |
| 2208 /** | |
| 2209 * Prevent the creation of instances of this class. | |
| 2210 */ | |
| 2211 DartInfo() : super() { | |
| 2212 } | |
| 2213 DartInfo copy() => this; | |
| 2214 SourceKind get kind => SourceKind.UNKNOWN; | |
| 2215 } | |
| 2216 /** | |
| 2217 * Instances of the class {@code DelegatingAnalysisContextImpl} extend {@link An
alysisContextImplanalysis context} to delegate sources to the appropriate analys
is context. For instance, if the | 3040 * Instances of the class {@code DelegatingAnalysisContextImpl} extend {@link An
alysisContextImplanalysis context} to delegate sources to the appropriate analys
is context. For instance, if the |
| 2218 * source is in a system library then the analysis context from the {@link DartS
dk} is used. | 3041 * source is in a system library then the analysis context from the {@link DartS
dk} is used. |
| 2219 * @coverage dart.engine | 3042 * @coverage dart.engine |
| 2220 */ | 3043 */ |
| 2221 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { | 3044 class DelegatingAnalysisContextImpl extends AnalysisContextImpl { |
| 2222 /** | 3045 /** |
| 2223 * This references the {@link InternalAnalysisContext} held onto by the {@link
DartSdk} which is | 3046 * This references the {@link InternalAnalysisContext} held onto by the {@link
DartSdk} which is |
| 2224 * used (instead of this {@link AnalysisContext}) for SDK sources. This field
is set when | 3047 * used (instead of this {@link AnalysisContext}) for SDK sources. This field
is set when |
| 2225 * #setSourceFactory(SourceFactory) is called, and references the analysis con
text in the{@link DartUriResolver} in the {@link SourceFactory}, this analysis c
ontext assumes that there | 3048 * #setSourceFactory(SourceFactory) is called, and references the analysis con
text in the{@link DartUriResolver} in the {@link SourceFactory}, this analysis c
ontext assumes that there |
| 2226 * will be such a resolver. | 3049 * will be such a resolver. |
| 2227 */ | 3050 */ |
| 2228 InternalAnalysisContext _sdkAnalysisContext; | 3051 InternalAnalysisContext _sdkAnalysisContext; |
| 2229 /** | 3052 /** |
| 2230 * Initialize a newly created delegating analysis context. | 3053 * Initialize a newly created delegating analysis context. |
| 2231 */ | 3054 */ |
| 2232 DelegatingAnalysisContextImpl() : super() { | 3055 DelegatingAnalysisContextImpl() : super() { |
| 2233 } | 3056 } |
| 2234 void addSourceInfo(Source source, SourceInfo info) { | 3057 void addSourceInfo(Source source, SourceEntry info) { |
| 2235 if (source.isInSystemLibrary()) { | 3058 if (source.isInSystemLibrary()) { |
| 2236 _sdkAnalysisContext.addSourceInfo(source, info); | 3059 _sdkAnalysisContext.addSourceInfo(source, info); |
| 2237 } else { | 3060 } else { |
| 2238 super.addSourceInfo(source, info); | 3061 super.addSourceInfo(source, info); |
| 2239 } | 3062 } |
| 2240 } | 3063 } |
| 2241 List<AnalysisError> computeErrors(Source source) { | 3064 List<AnalysisError> computeErrors(Source source) { |
| 2242 if (source.isInSystemLibrary()) { | 3065 if (source.isInSystemLibrary()) { |
| 2243 return _sdkAnalysisContext.computeErrors(source); | 3066 return _sdkAnalysisContext.computeErrors(source); |
| 2244 } else { | 3067 } else { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2391 if (elementMap.isEmpty) { | 3214 if (elementMap.isEmpty) { |
| 2392 return; | 3215 return; |
| 2393 } | 3216 } |
| 2394 Source source = new JavaIterator(elementMap.keys.toSet()).next(); | 3217 Source source = new JavaIterator(elementMap.keys.toSet()).next(); |
| 2395 if (source.isInSystemLibrary()) { | 3218 if (source.isInSystemLibrary()) { |
| 2396 _sdkAnalysisContext.recordLibraryElements(elementMap); | 3219 _sdkAnalysisContext.recordLibraryElements(elementMap); |
| 2397 } else { | 3220 } else { |
| 2398 super.recordLibraryElements(elementMap); | 3221 super.recordLibraryElements(elementMap); |
| 2399 } | 3222 } |
| 2400 } | 3223 } |
| 2401 void recordResolutionErrors(Source source, List<AnalysisError> errors, LineInf
o lineInfo) { | 3224 void recordResolutionErrors(Source source, Source librarySource, List<Analysis
Error> errors, LineInfo lineInfo) { |
| 2402 if (source.isInSystemLibrary()) { | 3225 if (source.isInSystemLibrary()) { |
| 2403 _sdkAnalysisContext.recordResolutionErrors(source, errors, lineInfo); | 3226 _sdkAnalysisContext.recordResolutionErrors(source, librarySource, errors,
lineInfo); |
| 2404 } else { | 3227 } else { |
| 2405 super.recordResolutionErrors(source, errors, lineInfo); | 3228 super.recordResolutionErrors(source, librarySource, errors, lineInfo); |
| 2406 } | 3229 } |
| 2407 } | 3230 } |
| 2408 void recordResolvedCompilationUnit(Source source, CompilationUnit unit) { | 3231 void recordResolvedCompilationUnit(Source source, Source librarySource, Compil
ationUnit unit) { |
| 2409 if (source.isInSystemLibrary()) { | 3232 if (source.isInSystemLibrary()) { |
| 2410 _sdkAnalysisContext.recordResolvedCompilationUnit(source, unit); | 3233 _sdkAnalysisContext.recordResolvedCompilationUnit(source, librarySource, u
nit); |
| 2411 } else { | 3234 } else { |
| 2412 super.recordResolvedCompilationUnit(source, unit); | 3235 super.recordResolvedCompilationUnit(source, librarySource, unit); |
| 2413 } | 3236 } |
| 2414 } | 3237 } |
| 2415 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library)
{ | 3238 CompilationUnit resolveCompilationUnit(Source source, LibraryElement library)
{ |
| 2416 if (source.isInSystemLibrary()) { | 3239 if (source.isInSystemLibrary()) { |
| 2417 return _sdkAnalysisContext.resolveCompilationUnit(source, library); | 3240 return _sdkAnalysisContext.resolveCompilationUnit(source, library); |
| 2418 } else { | 3241 } else { |
| 2419 return super.resolveCompilationUnit(source, library); | 3242 return super.resolveCompilationUnit(source, library); |
| 2420 } | 3243 } |
| 2421 } | 3244 } |
| 2422 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { | 3245 CompilationUnit resolveCompilationUnit2(Source unitSource, Source librarySourc
e) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2438 _sdkAnalysisContext.setContents(source, contents); | 3261 _sdkAnalysisContext.setContents(source, contents); |
| 2439 } else { | 3262 } else { |
| 2440 super.setContents(source, contents); | 3263 super.setContents(source, contents); |
| 2441 } | 3264 } |
| 2442 } | 3265 } |
| 2443 void set sourceFactory(SourceFactory factory) { | 3266 void set sourceFactory(SourceFactory factory) { |
| 2444 super.sourceFactory = factory; | 3267 super.sourceFactory = factory; |
| 2445 DartSdk sdk = factory.dartSdk; | 3268 DartSdk sdk = factory.dartSdk; |
| 2446 if (sdk != null) { | 3269 if (sdk != null) { |
| 2447 _sdkAnalysisContext = sdk.context as InternalAnalysisContext; | 3270 _sdkAnalysisContext = sdk.context as InternalAnalysisContext; |
| 3271 if (_sdkAnalysisContext is DelegatingAnalysisContextImpl) { |
| 3272 _sdkAnalysisContext = null; |
| 3273 throw new IllegalStateException("The context provided by an SDK cannot i
tself be a delegating analysis context"); |
| 3274 } |
| 2448 } else { | 3275 } else { |
| 2449 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal
ysisContextImpls must have a DartSdk associated with the provided SourceFactory.
"); | 3276 throw new IllegalStateException("SourceFactorys provided to DelegatingAnal
ysisContextImpls must have a DartSdk associated with the provided SourceFactory.
"); |
| 2450 } | 3277 } |
| 2451 } | 3278 } |
| 2452 } | 3279 } |
| 2453 /** | 3280 /** |
| 2454 * Instances of the class {@code HtmlUnitInfo} maintain the information cached b
y an analysis | |
| 2455 * context about an individual HTML file. | |
| 2456 * @coverage dart.engine | |
| 2457 */ | |
| 2458 class HtmlUnitInfo extends SourceInfo { | |
| 2459 /** | |
| 2460 * The state of the cached parsed (but not resolved) HTML unit. | |
| 2461 */ | |
| 2462 CacheState _parsedUnitState = CacheState.INVALID; | |
| 2463 /** | |
| 2464 * The parsed HTML unit, or {@code null} if the parsed HTML unit is not curren
tly cached. | |
| 2465 */ | |
| 2466 HtmlUnit _parsedUnit; | |
| 2467 /** | |
| 2468 * The state of the cached parsed and resolved HTML unit. | |
| 2469 */ | |
| 2470 CacheState _resolvedUnitState = CacheState.INVALID; | |
| 2471 /** | |
| 2472 * The resolved HTML unit, or {@code null} if the resolved HTML unit is not cu
rrently cached. | |
| 2473 */ | |
| 2474 HtmlUnit _resolvedUnit; | |
| 2475 /** | |
| 2476 * The state of the cached HTML element. | |
| 2477 */ | |
| 2478 CacheState _elementState = CacheState.INVALID; | |
| 2479 /** | |
| 2480 * The element representing the HTML file, or {@code null} if the element is n
ot currently cached. | |
| 2481 */ | |
| 2482 HtmlElement _element; | |
| 2483 /** | |
| 2484 * The state of the cached library sources. | |
| 2485 */ | |
| 2486 CacheState _librarySourcesState = CacheState.INVALID; | |
| 2487 /** | |
| 2488 * The sources of libraries referenced by this HTML file. | |
| 2489 */ | |
| 2490 List<Source> _librarySources = Source.EMPTY_ARRAY; | |
| 2491 /** | |
| 2492 * Initialize a newly created information holder to be empty. | |
| 2493 */ | |
| 2494 HtmlUnitInfo() : super() { | |
| 2495 } | |
| 2496 /** | |
| 2497 * Remove the parsed HTML unit from the cache. | |
| 2498 */ | |
| 2499 void clearParsedUnit() { | |
| 2500 _parsedUnit = null; | |
| 2501 _parsedUnitState = CacheState.FLUSHED; | |
| 2502 } | |
| 2503 /** | |
| 2504 * Remove the resolved HTML unit from the cache. | |
| 2505 */ | |
| 2506 void clearResolvedUnit() { | |
| 2507 _resolvedUnit = null; | |
| 2508 _resolvedUnitState = CacheState.FLUSHED; | |
| 2509 } | |
| 2510 HtmlUnitInfo copy() { | |
| 2511 HtmlUnitInfo copy = new HtmlUnitInfo(); | |
| 2512 copy.copyFrom(this); | |
| 2513 return copy; | |
| 2514 } | |
| 2515 /** | |
| 2516 * Return the element representing the HTML file, or {@code null} if the eleme
nt is not currently | |
| 2517 * cached. | |
| 2518 * @return the element representing the HTML file | |
| 2519 */ | |
| 2520 HtmlElement get element => _element; | |
| 2521 SourceKind get kind => SourceKind.HTML; | |
| 2522 /** | |
| 2523 * Return the sources of libraries referenced by this HTML file. | |
| 2524 * @return the sources of libraries referenced by this HTML file | |
| 2525 */ | |
| 2526 List<Source> get librarySources => _librarySources; | |
| 2527 /** | |
| 2528 * Return the parsed HTML unit, or {@code null} if the parsed HTML unit is not
currently cached. | |
| 2529 * @return the parsed HTML unit | |
| 2530 */ | |
| 2531 HtmlUnit get parsedUnit => _parsedUnit; | |
| 2532 /** | |
| 2533 * Return the resolved HTML unit, or {@code null} if the resolved HTML unit is
not currently | |
| 2534 * cached. | |
| 2535 * @return the resolved HTML unit | |
| 2536 */ | |
| 2537 HtmlUnit get resolvedUnit => _resolvedUnit; | |
| 2538 /** | |
| 2539 * Return {@code true} if the HTML element needs to be recomputed. | |
| 2540 * @return {@code true} if the HTML element needs to be recomputed | |
| 2541 */ | |
| 2542 bool hasInvalidElement() => identical(_elementState, CacheState.INVALID); | |
| 2543 /** | |
| 2544 * Return {@code true} if the parsed HTML unit needs to be recomputed. | |
| 2545 * @return {@code true} if the parsed HTML unit needs to be recomputed | |
| 2546 */ | |
| 2547 bool hasInvalidParsedUnit() => identical(_parsedUnitState, CacheState.INVALID)
; | |
| 2548 /** | |
| 2549 * Return {@code true} if the resolved HTML unit needs to be recomputed. | |
| 2550 * @return {@code true} if the resolved HTML unit needs to be recomputed | |
| 2551 */ | |
| 2552 bool hasInvalidResolvedUnit() => identical(_resolvedUnitState, CacheState.INVA
LID); | |
| 2553 /** | |
| 2554 * Mark the HTML element as needing to be recomputed. | |
| 2555 */ | |
| 2556 void invalidateElement() { | |
| 2557 _elementState = CacheState.INVALID; | |
| 2558 _element = null; | |
| 2559 } | |
| 2560 /** | |
| 2561 * Mark the library sources as needing to be recomputed. | |
| 2562 */ | |
| 2563 void invalidateLibrarySources() { | |
| 2564 _librarySourcesState = CacheState.INVALID; | |
| 2565 _librarySources = Source.EMPTY_ARRAY; | |
| 2566 } | |
| 2567 /** | |
| 2568 * Mark the parsed HTML unit as needing to be recomputed. | |
| 2569 */ | |
| 2570 void invalidateParsedUnit() { | |
| 2571 _parsedUnitState = CacheState.INVALID; | |
| 2572 _parsedUnit = null; | |
| 2573 } | |
| 2574 /** | |
| 2575 * Mark the resolved HTML unit as needing to be recomputed. | |
| 2576 */ | |
| 2577 void invalidateResolvedUnit() { | |
| 2578 invalidateElement(); | |
| 2579 _resolvedUnitState = CacheState.INVALID; | |
| 2580 _resolvedUnit = null; | |
| 2581 } | |
| 2582 /** | |
| 2583 * Set the element representing the HTML file to the given element. | |
| 2584 * <p> | |
| 2585 * <b>Note:</b> Do not use this method to clear or invalidate the element. Use
either{@link #clearElement()} or {@link #invalidateElement()}. | |
| 2586 * @param element the element representing the HTML file | |
| 2587 */ | |
| 2588 void set element(HtmlElement element2) { | |
| 2589 this._element = element2; | |
| 2590 _elementState = CacheState.VALID; | |
| 2591 } | |
| 2592 /** | |
| 2593 * Set the sources of libraries referenced by this HTML file to the given sour
ces. | |
| 2594 * @param sources the sources of libraries referenced by this HTML file | |
| 2595 */ | |
| 2596 void set librarySources(List<Source> sources) { | |
| 2597 _librarySources = sources; | |
| 2598 _librarySourcesState = CacheState.VALID; | |
| 2599 } | |
| 2600 /** | |
| 2601 * Set the parsed HTML unit to the given HTML unit. | |
| 2602 * <p> | |
| 2603 * <b>Note:</b> Do not use this method to clear or invalidate the HTML unit. U
se either{@link #clearParsedUnit()} or {@link #invalidateParsedUnit()}. | |
| 2604 * @param unit the result of parsing the source as an HTML unit | |
| 2605 */ | |
| 2606 void set parsedUnit(HtmlUnit unit) { | |
| 2607 _parsedUnit = unit; | |
| 2608 _parsedUnitState = CacheState.VALID; | |
| 2609 } | |
| 2610 /** | |
| 2611 * Set the resolved HTML unit to the given HTML unit. | |
| 2612 * <p> | |
| 2613 * <b>Note:</b> Do not use this method to clear or invalidate the HTML unit. U
se either{@link #clearResolvedUnit()} or {@link #invalidateResolvedUnit()}. | |
| 2614 * @param unit the result of resolving the source as an HTML unit | |
| 2615 */ | |
| 2616 void set resolvedUnit(HtmlUnit unit) { | |
| 2617 _resolvedUnit = unit; | |
| 2618 _resolvedUnitState = CacheState.VALID; | |
| 2619 } | |
| 2620 void copyFrom(SourceInfo info) { | |
| 2621 super.copyFrom(info); | |
| 2622 } | |
| 2623 } | |
| 2624 /** | |
| 2625 * Instances of the class {@code InstrumentedAnalysisContextImpl} implement an{@
link AnalysisContext analysis context} by recording instrumentation data and del
egating to | 3281 * Instances of the class {@code InstrumentedAnalysisContextImpl} implement an{@
link AnalysisContext analysis context} by recording instrumentation data and del
egating to |
| 2626 * another analysis context to do the non-instrumentation work. | 3282 * another analysis context to do the non-instrumentation work. |
| 2627 * @coverage dart.engine | 3283 * @coverage dart.engine |
| 2628 */ | 3284 */ |
| 2629 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { | 3285 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { |
| 2630 /** | 3286 /** |
| 2631 * Record an exception that was thrown during analysis. | 3287 * Record an exception that was thrown during analysis. |
| 2632 * @param instrumentation the instrumentation builder being used to record the
exception | 3288 * @param instrumentation the instrumentation builder being used to record the
exception |
| 2633 * @param exception the exception being reported | 3289 * @param exception the exception being reported |
| 2634 */ | 3290 */ |
| 2635 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { | 3291 static void recordAnalysisException(InstrumentationBuilder instrumentation, An
alysisException exception) { |
| 2636 instrumentation.record(exception); | 3292 instrumentation.record(exception); |
| 2637 } | 3293 } |
| 2638 /** | 3294 /** |
| 2639 * The unique identifier used to identify this analysis context in the instrum
entation data. | 3295 * The unique identifier used to identify this analysis context in the instrum
entation data. |
| 2640 */ | 3296 */ |
| 2641 String _contextId = UUID.randomUUID().toString(); | 3297 String _contextId = UUID.randomUUID().toString(); |
| 2642 /** | 3298 /** |
| 2643 * The analysis context to which all of the non-instrumentation work is delega
ted. | 3299 * The analysis context to which all of the non-instrumentation work is delega
ted. |
| 2644 */ | 3300 */ |
| 2645 InternalAnalysisContext _basis; | 3301 InternalAnalysisContext _basis; |
| 2646 /** | 3302 /** |
| 2647 * Create a new {@link InstrumentedAnalysisContextImpl} which wraps a new{@lin
k AnalysisContextImpl} as the basis context. | 3303 * Create a new {@link InstrumentedAnalysisContextImpl} which wraps a new{@lin
k AnalysisContextImpl} as the basis context. |
| 2648 */ | 3304 */ |
| 2649 InstrumentedAnalysisContextImpl() { | 3305 InstrumentedAnalysisContextImpl() { |
| 2650 _jtd_constructor_175_impl(); | 3306 _jtd_constructor_178_impl(); |
| 2651 } | 3307 } |
| 2652 _jtd_constructor_175_impl() { | 3308 _jtd_constructor_178_impl() { |
| 2653 _jtd_constructor_176_impl(new AnalysisContextImpl()); | 3309 _jtd_constructor_179_impl(new AnalysisContextImpl()); |
| 2654 } | 3310 } |
| 2655 /** | 3311 /** |
| 2656 * Create a new {@link InstrumentedAnalysisContextImpl} with a specified basis
context, aka the | 3312 * Create a new {@link InstrumentedAnalysisContextImpl} with a specified basis
context, aka the |
| 2657 * context to wrap and instrument. | 3313 * context to wrap and instrument. |
| 2658 * @param context some {@link InstrumentedAnalysisContext} to wrap and instrum
ent | 3314 * @param context some {@link InstrumentedAnalysisContext} to wrap and instrum
ent |
| 2659 */ | 3315 */ |
| 2660 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { | 3316 InstrumentedAnalysisContextImpl.con1(InternalAnalysisContext context) { |
| 2661 _jtd_constructor_176_impl(context); | 3317 _jtd_constructor_179_impl(context); |
| 2662 } | 3318 } |
| 2663 _jtd_constructor_176_impl(InternalAnalysisContext context) { | 3319 _jtd_constructor_179_impl(InternalAnalysisContext context) { |
| 2664 _basis = context; | 3320 _basis = context; |
| 2665 } | 3321 } |
| 2666 void addSourceInfo(Source source, SourceInfo info) { | 3322 void addSourceInfo(Source source, SourceEntry info) { |
| 2667 _basis.addSourceInfo(source, info); | 3323 _basis.addSourceInfo(source, info); |
| 2668 } | 3324 } |
| 2669 void applyChanges(ChangeSet changeSet) { | 3325 void applyChanges(ChangeSet changeSet) { |
| 2670 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
applyChanges"); | 3326 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
applyChanges"); |
| 2671 try { | 3327 try { |
| 2672 instrumentation.metric3("contextId", _contextId); | 3328 instrumentation.metric3("contextId", _contextId); |
| 2673 _basis.applyChanges(changeSet); | 3329 _basis.applyChanges(changeSet); |
| 2674 } finally { | 3330 } finally { |
| 2675 instrumentation.log(); | 3331 instrumentation.log(); |
| 2676 } | 3332 } |
| 2677 } | 3333 } |
| 3334 String computeDocumentationComment(Element element) { |
| 3335 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeDocumentationComment"); |
| 3336 try { |
| 3337 instrumentation.metric3("contextId", _contextId); |
| 3338 return _basis.computeDocumentationComment(element); |
| 3339 } finally { |
| 3340 instrumentation.log(); |
| 3341 } |
| 3342 } |
| 2678 List<AnalysisError> computeErrors(Source source) { | 3343 List<AnalysisError> computeErrors(Source source) { |
| 2679 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeErrors"); | 3344 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
computeErrors"); |
| 2680 try { | 3345 try { |
| 2681 instrumentation.metric3("contextId", _contextId); | 3346 instrumentation.metric3("contextId", _contextId); |
| 2682 List<AnalysisError> errors = _basis.computeErrors(source); | 3347 List<AnalysisError> errors = _basis.computeErrors(source); |
| 2683 instrumentation.metric2("Errors-count", errors.length); | 3348 instrumentation.metric2("Errors-count", errors.length); |
| 2684 return errors; | 3349 return errors; |
| 2685 } finally { | 3350 } finally { |
| 2686 instrumentation.log(); | 3351 instrumentation.log(); |
| 2687 } | 3352 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2976 instrumentation.metric2("ChangeNotice-count", ret.length); | 3641 instrumentation.metric2("ChangeNotice-count", ret.length); |
| 2977 } | 3642 } |
| 2978 return ret; | 3643 return ret; |
| 2979 } finally { | 3644 } finally { |
| 2980 instrumentation.log(); | 3645 instrumentation.log(); |
| 2981 } | 3646 } |
| 2982 } | 3647 } |
| 2983 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 3648 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 2984 _basis.recordLibraryElements(elementMap); | 3649 _basis.recordLibraryElements(elementMap); |
| 2985 } | 3650 } |
| 2986 void recordResolutionErrors(Source source, List<AnalysisError> errors, LineInf
o lineInfo) { | 3651 void recordResolutionErrors(Source source, Source librarySource, List<Analysis
Error> errors, LineInfo lineInfo) { |
| 2987 _basis.recordResolutionErrors(source, errors, lineInfo); | 3652 _basis.recordResolutionErrors(source, librarySource, errors, lineInfo); |
| 2988 } | 3653 } |
| 2989 void recordResolvedCompilationUnit(Source source, CompilationUnit unit) { | 3654 void recordResolvedCompilationUnit(Source source, Source librarySource, Compil
ationUnit unit) { |
| 2990 _basis.recordResolvedCompilationUnit(source, unit); | 3655 _basis.recordResolvedCompilationUnit(source, librarySource, unit); |
| 2991 } | 3656 } |
| 2992 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { | 3657 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { |
| 2993 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); | 3658 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
resolveCompilationUnit"); |
| 2994 try { | 3659 try { |
| 2995 instrumentation.metric3("contextId", _contextId); | 3660 instrumentation.metric3("contextId", _contextId); |
| 2996 return _basis.resolveCompilationUnit(unitSource, library); | 3661 return _basis.resolveCompilationUnit(unitSource, library); |
| 2997 } on AnalysisException catch (e) { | 3662 } on AnalysisException catch (e) { |
| 2998 recordAnalysisException(instrumentation, e); | 3663 recordAnalysisException(instrumentation, e); |
| 2999 throw e; | 3664 throw e; |
| 3000 } finally { | 3665 } finally { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3056 /** | 3721 /** |
| 3057 * The interface {@code InternalAnalysisContext} defines additional behavior for
an analysis context | 3722 * The interface {@code InternalAnalysisContext} defines additional behavior for
an analysis context |
| 3058 * that is required by internal users of the context. | 3723 * that is required by internal users of the context. |
| 3059 */ | 3724 */ |
| 3060 abstract class InternalAnalysisContext implements AnalysisContext { | 3725 abstract class InternalAnalysisContext implements AnalysisContext { |
| 3061 /** | 3726 /** |
| 3062 * Add the given source with the given information to this context. | 3727 * Add the given source with the given information to this context. |
| 3063 * @param source the source to be added | 3728 * @param source the source to be added |
| 3064 * @param info the information about the source | 3729 * @param info the information about the source |
| 3065 */ | 3730 */ |
| 3066 void addSourceInfo(Source source, SourceInfo info); | 3731 void addSourceInfo(Source source, SourceEntry info); |
| 3067 /** | 3732 /** |
| 3068 * Return an AST structure corresponding to the given source, but ensure that
the structure has | 3733 * Return an AST structure corresponding to the given source, but ensure that
the structure has |
| 3069 * not already been resolved and will not be resolved by any other threads or
in any other | 3734 * not already been resolved and will not be resolved by any other threads or
in any other |
| 3070 * library. | 3735 * library. |
| 3071 * @param source the compilation unit for which an AST structure should be ret
urned | 3736 * @param source the compilation unit for which an AST structure should be ret
urned |
| 3072 * @return the AST structure representing the content of the source | 3737 * @return the AST structure representing the content of the source |
| 3073 * @throws AnalysisException if the analysis could not be performed | 3738 * @throws AnalysisException if the analysis could not be performed |
| 3074 */ | 3739 */ |
| 3075 CompilationUnit computeResolvableCompilationUnit(Source source); | 3740 CompilationUnit computeResolvableCompilationUnit(Source source); |
| 3076 /** | 3741 /** |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3101 * Given a table mapping the source for the libraries represented by the corre
sponding elements to | 3766 * Given a table mapping the source for the libraries represented by the corre
sponding elements to |
| 3102 * the elements representing the libraries, record those mappings. | 3767 * the elements representing the libraries, record those mappings. |
| 3103 * @param elementMap a table mapping the source for the libraries represented
by the elements to | 3768 * @param elementMap a table mapping the source for the libraries represented
by the elements to |
| 3104 * the elements representing the libraries | 3769 * the elements representing the libraries |
| 3105 */ | 3770 */ |
| 3106 void recordLibraryElements(Map<Source, LibraryElement> elementMap); | 3771 void recordLibraryElements(Map<Source, LibraryElement> elementMap); |
| 3107 /** | 3772 /** |
| 3108 * Give the resolution errors and line info associated with the given source,
add the information | 3773 * Give the resolution errors and line info associated with the given source,
add the information |
| 3109 * to the cache. | 3774 * to the cache. |
| 3110 * @param source the source with which the information is associated | 3775 * @param source the source with which the information is associated |
| 3776 * @param librarySource the source of the defining compilation unit of the lib
rary in which the |
| 3777 * source was resolved |
| 3111 * @param errors the resolution errors associated with the source | 3778 * @param errors the resolution errors associated with the source |
| 3112 * @param lineInfo the line information associated with the source | 3779 * @param lineInfo the line information associated with the source |
| 3113 */ | 3780 */ |
| 3114 void recordResolutionErrors(Source source, List<AnalysisError> errors, LineInf
o lineInfo); | 3781 void recordResolutionErrors(Source source, Source librarySource, List<Analysis
Error> errors, LineInfo lineInfo); |
| 3115 /** | 3782 /** |
| 3116 * Give the resolved compilation unit associated with the given source, add th
e unit to the cache. | 3783 * Give the resolved compilation unit associated with the given source, add th
e unit to the cache. |
| 3117 * @param source the source with which the unit is associated | 3784 * @param source the source with which the unit is associated |
| 3785 * @param librarySource the source of the defining compilation unit of the lib
rary in which the |
| 3786 * source was resolved |
| 3118 * @param unit the compilation unit associated with the source | 3787 * @param unit the compilation unit associated with the source |
| 3119 */ | 3788 */ |
| 3120 void recordResolvedCompilationUnit(Source source, CompilationUnit unit); | 3789 void recordResolvedCompilationUnit(Source source, Source librarySource, Compil
ationUnit unit); |
| 3121 } | |
| 3122 /** | |
| 3123 * Instances of the class {@code LibraryInfo} maintain the information cached by
an analysis context | |
| 3124 * about an individual library. | |
| 3125 * @coverage dart.engine | |
| 3126 */ | |
| 3127 class LibraryInfo extends CompilationUnitInfo { | |
| 3128 /** | |
| 3129 * Mask indicating that this library is launchable: that the file has a main m
ethod. | |
| 3130 */ | |
| 3131 static int _LAUNCHABLE = 1 << 1; | |
| 3132 /** | |
| 3133 * Mask indicating that the library is client code: that the library depends o
n the html library. | |
| 3134 * If the library is not "client code", then it is referenced as "server code"
. | |
| 3135 */ | |
| 3136 static int _CLIENT_CODE = 1 << 2; | |
| 3137 /** | |
| 3138 * The state of the cached library element. | |
| 3139 */ | |
| 3140 CacheState _elementState = CacheState.INVALID; | |
| 3141 /** | |
| 3142 * The element representing the library, or {@code null} if the element is not
currently cached. | |
| 3143 */ | |
| 3144 LibraryElement _element; | |
| 3145 /** | |
| 3146 * The state of the cached unit sources. | |
| 3147 */ | |
| 3148 CacheState _unitSourcesState = CacheState.INVALID; | |
| 3149 /** | |
| 3150 * The sources of the compilation units that compose the library, including bo
th the defining | |
| 3151 * compilation unit and any parts. | |
| 3152 */ | |
| 3153 List<Source> _unitSources = Source.EMPTY_ARRAY; | |
| 3154 /** | |
| 3155 * The state of the cached public namespace. | |
| 3156 */ | |
| 3157 CacheState _publicNamespaceState = CacheState.INVALID; | |
| 3158 /** | |
| 3159 * The public namespace of the library, or {@code null} if the namespace is no
t currently cached. | |
| 3160 */ | |
| 3161 Namespace _publicNamespace; | |
| 3162 /** | |
| 3163 * The state of the cached client/ server flag. | |
| 3164 */ | |
| 3165 CacheState _clientServerState = CacheState.INVALID; | |
| 3166 /** | |
| 3167 * The state of the cached launchable flag. | |
| 3168 */ | |
| 3169 CacheState _launchableState = CacheState.INVALID; | |
| 3170 /** | |
| 3171 * An integer holding bit masks such as {@link #LAUNCHABLE} and {@link #CLIENT
_CODE}. | |
| 3172 */ | |
| 3173 int _bitmask = 0; | |
| 3174 /** | |
| 3175 * Initialize a newly created information holder to be empty. | |
| 3176 */ | |
| 3177 LibraryInfo() : super() { | |
| 3178 } | |
| 3179 /** | |
| 3180 * Remove the library element from the cache. | |
| 3181 */ | |
| 3182 void clearElement() { | |
| 3183 _element = null; | |
| 3184 _elementState = CacheState.FLUSHED; | |
| 3185 } | |
| 3186 /** | |
| 3187 * Remove the public namespace from the cache. | |
| 3188 */ | |
| 3189 void clearPublicNamespace() { | |
| 3190 _publicNamespace = null; | |
| 3191 _publicNamespaceState = CacheState.FLUSHED; | |
| 3192 } | |
| 3193 LibraryInfo copy() { | |
| 3194 LibraryInfo copy = new LibraryInfo(); | |
| 3195 copy.copyFrom(this); | |
| 3196 return copy; | |
| 3197 } | |
| 3198 /** | |
| 3199 * Return the element representing the library, or {@code null} if the element
is not currently | |
| 3200 * cached. | |
| 3201 * @return the element representing the library | |
| 3202 */ | |
| 3203 LibraryElement get element => _element; | |
| 3204 SourceKind get kind => SourceKind.LIBRARY; | |
| 3205 /** | |
| 3206 * Return the public namespace of the library, or {@code null} if the namespac
e is not currently | |
| 3207 * cached. | |
| 3208 * @return the public namespace of the library | |
| 3209 */ | |
| 3210 Namespace get publicNamespace => _publicNamespace; | |
| 3211 /** | |
| 3212 * Return the sources of the compilation units that compose the library, inclu
ding both the | |
| 3213 * defining compilation unit and any parts. | |
| 3214 * @return the sources of the compilation units that compose the library | |
| 3215 */ | |
| 3216 List<Source> get unitSources => _unitSources; | |
| 3217 /** | |
| 3218 * Return {@code true} if the client/ server flag needs to be recomputed. | |
| 3219 * @return {@code true} if the client/ server flag needs to be recomputed | |
| 3220 */ | |
| 3221 bool hasInvalidClientServer() => identical(_clientServerState, CacheState.INVA
LID); | |
| 3222 /** | |
| 3223 * Return {@code true} if the library element needs to be recomputed. | |
| 3224 * @return {@code true} if the library element needs to be recomputed | |
| 3225 */ | |
| 3226 bool hasInvalidElement() => identical(_elementState, CacheState.INVALID); | |
| 3227 /** | |
| 3228 * Return {@code true} if the launchable flag needs to be recomputed. | |
| 3229 * @return {@code true} if the launchable flag needs to be recomputed | |
| 3230 */ | |
| 3231 bool hasInvalidLaunchable() => identical(_launchableState, CacheState.INVALID)
; | |
| 3232 /** | |
| 3233 * Return {@code true} if the public namespace needs to be recomputed. | |
| 3234 * @return {@code true} if the public namespace needs to be recomputed | |
| 3235 */ | |
| 3236 bool hasInvalidPublicNamespace() => identical(_publicNamespaceState, CacheStat
e.INVALID); | |
| 3237 /** | |
| 3238 * Mark the client/ server flag as needing to be recomputed. | |
| 3239 */ | |
| 3240 void invalidateClientServer() { | |
| 3241 _clientServerState = CacheState.INVALID; | |
| 3242 _bitmask &= ~_CLIENT_CODE; | |
| 3243 } | |
| 3244 /** | |
| 3245 * Mark the library element as needing to be recomputed. | |
| 3246 */ | |
| 3247 void invalidateElement() { | |
| 3248 _elementState = CacheState.INVALID; | |
| 3249 _element = null; | |
| 3250 } | |
| 3251 /** | |
| 3252 * Mark the launchable flag as needing to be recomputed. | |
| 3253 */ | |
| 3254 void invalidateLaunchable() { | |
| 3255 _launchableState = CacheState.INVALID; | |
| 3256 _bitmask &= ~_LAUNCHABLE; | |
| 3257 } | |
| 3258 /** | |
| 3259 * Mark the public namespace as needing to be recomputed. | |
| 3260 */ | |
| 3261 void invalidatePublicNamespace() { | |
| 3262 _publicNamespaceState = CacheState.INVALID; | |
| 3263 _publicNamespace = null; | |
| 3264 } | |
| 3265 /** | |
| 3266 * Mark the compilation unit sources as needing to be recomputed. | |
| 3267 */ | |
| 3268 void invalidateUnitSources() { | |
| 3269 _unitSourcesState = CacheState.INVALID; | |
| 3270 _unitSources = Source.EMPTY_ARRAY; | |
| 3271 } | |
| 3272 /** | |
| 3273 * Return {@code true} if this library is client based code: the library depen
ds on the html | |
| 3274 * library. | |
| 3275 * @return {@code true} if this library is client based code: the library depe
nds on the html | |
| 3276 * library | |
| 3277 */ | |
| 3278 bool isClient() => (_bitmask & _CLIENT_CODE) != 0; | |
| 3279 /** | |
| 3280 * Return {@code true} if this library is launchable: the file includes a main
method. | |
| 3281 * @return {@code true} if this library is launchable: the file includes a mai
n method | |
| 3282 */ | |
| 3283 bool isLaunchable() => (_bitmask & _LAUNCHABLE) != 0; | |
| 3284 /** | |
| 3285 * Return {@code true} if this library is server based code: the library does
not depends on the | |
| 3286 * html library. | |
| 3287 * @return {@code true} if this library is server based code: the library does
not depends on the | |
| 3288 * html library | |
| 3289 */ | |
| 3290 bool isServer() => (_bitmask & _CLIENT_CODE) == 0; | |
| 3291 /** | |
| 3292 * Sets the value of the client/ server flag. | |
| 3293 * <p> | |
| 3294 * <b>Note:</b> Do not use this method to invalidate the flag, use{@link #inva
lidateClientServer()}. | |
| 3295 * @param isClient the new value of the client flag | |
| 3296 */ | |
| 3297 void set client(bool isClient) { | |
| 3298 if (isClient) { | |
| 3299 _bitmask |= _CLIENT_CODE; | |
| 3300 } else { | |
| 3301 _bitmask &= ~_CLIENT_CODE; | |
| 3302 } | |
| 3303 _clientServerState = CacheState.VALID; | |
| 3304 } | |
| 3305 /** | |
| 3306 * Set the element representing the library to the given element. | |
| 3307 * <p> | |
| 3308 * <b>Note:</b> Do not use this method to clear or invalidate the element. Use
either{@link #clearElement()} or {@link #invalidateElement()}. | |
| 3309 * @param element the element representing the library | |
| 3310 */ | |
| 3311 void set element(LibraryElement element2) { | |
| 3312 this._element = element2; | |
| 3313 _elementState = CacheState.VALID; | |
| 3314 } | |
| 3315 /** | |
| 3316 * Sets the value of the launchable flag. | |
| 3317 * <p> | |
| 3318 * <b>Note:</b> Do not use this method to invalidate the flag, use {@link #inv
alidateLaunchable()}. | |
| 3319 * @param isClient the new value of the client flag | |
| 3320 */ | |
| 3321 void set launchable(bool launchable2) { | |
| 3322 if (launchable2) { | |
| 3323 _bitmask |= _LAUNCHABLE; | |
| 3324 } else { | |
| 3325 _bitmask &= ~_LAUNCHABLE; | |
| 3326 } | |
| 3327 _launchableState = CacheState.VALID; | |
| 3328 } | |
| 3329 /** | |
| 3330 * Set the public namespace of the library to the given namespace. | |
| 3331 * <p> | |
| 3332 * <b>Note:</b> Do not use this method to clear or invalidate the element. Use
either{@link #clearPublicNamespace()} or {@link #invalidatePublicNamespace()}. | |
| 3333 * @param namespace the public namespace of the library | |
| 3334 */ | |
| 3335 void set publicNamespace(Namespace namespace) { | |
| 3336 _publicNamespace = namespace; | |
| 3337 _publicNamespaceState = CacheState.VALID; | |
| 3338 } | |
| 3339 /** | |
| 3340 * Set the sources of the compilation units that compose the library to the gi
ven sources. | |
| 3341 * @param sources the sources of the compilation units that compose the librar
y | |
| 3342 */ | |
| 3343 void set unitSources(List<Source> sources) { | |
| 3344 _unitSourcesState = CacheState.VALID; | |
| 3345 _unitSources = sources; | |
| 3346 } | |
| 3347 void copyFrom(SourceInfo info) { | |
| 3348 super.copyFrom(info); | |
| 3349 } | |
| 3350 } | 3790 } |
| 3351 /** | 3791 /** |
| 3352 * Instances of the class {@code RecordingErrorListener} implement an error list
ener that will | 3792 * Instances of the class {@code RecordingErrorListener} implement an error list
ener that will |
| 3353 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors | 3793 * record the errors that are reported to it in a way that is appropriate for ca
ching those errors |
| 3354 * within an analysis context. | 3794 * within an analysis context. |
| 3355 * @coverage dart.engine | 3795 * @coverage dart.engine |
| 3356 */ | 3796 */ |
| 3357 class RecordingErrorListener implements AnalysisErrorListener { | 3797 class RecordingErrorListener implements AnalysisErrorListener { |
| 3358 /** | 3798 /** |
| 3359 * A HashMap of lists containing the errors that were collected, keyed by each
{@link Source}. | 3799 * A HashMap of lists containing the errors that were collected, keyed by each
{@link Source}. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3463 Object visitSimpleIdentifier(SimpleIdentifier node) { | 3903 Object visitSimpleIdentifier(SimpleIdentifier node) { |
| 3464 node.element = null; | 3904 node.element = null; |
| 3465 return super.visitSimpleIdentifier(node); | 3905 return super.visitSimpleIdentifier(node); |
| 3466 } | 3906 } |
| 3467 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { | 3907 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { |
| 3468 node.element = null; | 3908 node.element = null; |
| 3469 return super.visitSuperConstructorInvocation(node); | 3909 return super.visitSuperConstructorInvocation(node); |
| 3470 } | 3910 } |
| 3471 } | 3911 } |
| 3472 /** | 3912 /** |
| 3473 * Instances of the class {@code SourceInfo} maintain the information cached by
an analysis context | |
| 3474 * about an individual source. | |
| 3475 * @coverage dart.engine | |
| 3476 */ | |
| 3477 abstract class SourceInfo { | |
| 3478 /** | |
| 3479 * The state of the cached line information. | |
| 3480 */ | |
| 3481 CacheState _lineInfoState = CacheState.INVALID; | |
| 3482 /** | |
| 3483 * The line information computed for the source, or {@code null} if the line i
nformation is not | |
| 3484 * currently cached. | |
| 3485 */ | |
| 3486 LineInfo _lineInfo; | |
| 3487 /** | |
| 3488 * Initialize a newly created information holder to be empty. | |
| 3489 */ | |
| 3490 SourceInfo() : super() { | |
| 3491 } | |
| 3492 /** | |
| 3493 * Remove the line information from the cache. | |
| 3494 */ | |
| 3495 void clearLineInfo() { | |
| 3496 _lineInfo = null; | |
| 3497 _lineInfoState = CacheState.FLUSHED; | |
| 3498 } | |
| 3499 /** | |
| 3500 * Return a copy of this information holder. | |
| 3501 * @return a copy of this information holder | |
| 3502 */ | |
| 3503 SourceInfo copy(); | |
| 3504 /** | |
| 3505 * Return the kind of the source, or {@code null} if the kind is not currently
cached. | |
| 3506 * @return the kind of the source | |
| 3507 */ | |
| 3508 SourceKind get kind; | |
| 3509 /** | |
| 3510 * Return the line information computed for the source, or {@code null} if the
line information is | |
| 3511 * not currently cached. | |
| 3512 * @return the line information computed for the source | |
| 3513 */ | |
| 3514 LineInfo get lineInfo => _lineInfo; | |
| 3515 /** | |
| 3516 * Return {@code true} if the line information needs to be recomputed. | |
| 3517 * @return {@code true} if the line information needs to be recomputed | |
| 3518 */ | |
| 3519 bool hasInvalidLineInfo() => identical(_lineInfoState, CacheState.INVALID); | |
| 3520 /** | |
| 3521 * Mark the line information as needing to be recomputed. | |
| 3522 */ | |
| 3523 void invalidateLineInfo() { | |
| 3524 _lineInfoState = CacheState.INVALID; | |
| 3525 _lineInfo = null; | |
| 3526 } | |
| 3527 /** | |
| 3528 * Set the line information for the source to the given line information. | |
| 3529 * <p> | |
| 3530 * <b>Note:</b> Do not use this method to clear or invalidate the element. Use
either{@link #clearLineInfo()} or {@link #invalidateLineInfo()}. | |
| 3531 * @param info the line information for the source | |
| 3532 */ | |
| 3533 void set lineInfo(LineInfo info) { | |
| 3534 _lineInfo = info; | |
| 3535 _lineInfoState = CacheState.VALID; | |
| 3536 } | |
| 3537 /** | |
| 3538 * Copy the information from the given information holder. | |
| 3539 * @param info the information holder from which information will be copied | |
| 3540 */ | |
| 3541 void copyFrom(SourceInfo info) { | |
| 3542 _lineInfoState = info._lineInfoState; | |
| 3543 _lineInfo = info._lineInfo; | |
| 3544 } | |
| 3545 } | |
| 3546 /** | |
| 3547 * The interface {@code Logger} defines the behavior of objects that can be used
to receive | 3913 * The interface {@code Logger} defines the behavior of objects that can be used
to receive |
| 3548 * information about errors within the analysis engine. Implementations usually
write this | 3914 * information about errors within the analysis engine. Implementations usually
write this |
| 3549 * information to a file, but can also record the information for later use (suc
h as during testing) | 3915 * information to a file, but can also record the information for later use (suc
h as during testing) |
| 3550 * or even ignore the information. | 3916 * or even ignore the information. |
| 3551 * @coverage dart.engine.utilities | 3917 * @coverage dart.engine.utilities |
| 3552 */ | 3918 */ |
| 3553 abstract class Logger { | 3919 abstract class Logger { |
| 3554 static Logger NULL = new Logger_NullLogger(); | 3920 static Logger NULL = new Logger_NullLogger(); |
| 3555 /** | 3921 /** |
| 3556 * Log the given message as an error. | 3922 * Log the given message as an error. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3589 } | 3955 } |
| 3590 void logError2(String message, Exception exception) { | 3956 void logError2(String message, Exception exception) { |
| 3591 } | 3957 } |
| 3592 void logError3(Exception exception) { | 3958 void logError3(Exception exception) { |
| 3593 } | 3959 } |
| 3594 void logInformation(String message) { | 3960 void logInformation(String message) { |
| 3595 } | 3961 } |
| 3596 void logInformation2(String message, Exception exception) { | 3962 void logInformation2(String message, Exception exception) { |
| 3597 } | 3963 } |
| 3598 } | 3964 } |
| OLD | NEW |