| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine; | 8 library engine; |
| 9 | 9 |
| 10 import 'dart:collection'; | 10 import 'dart:collection'; |
| (...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 // } | 1429 // } |
| 1430 } | 1430 } |
| 1431 } | 1431 } |
| 1432 return new List.from(sources); | 1432 return new List.from(sources); |
| 1433 } | 1433 } |
| 1434 | 1434 |
| 1435 @override | 1435 @override |
| 1436 List<Source> getLibrariesContaining(Source source) { | 1436 List<Source> getLibrariesContaining(Source source) { |
| 1437 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); | 1437 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); |
| 1438 if (sourceEntry is DartEntry) { | 1438 if (sourceEntry is DartEntry) { |
| 1439 return sourceEntry.getValue(DartEntry.CONTAINING_LIBRARIES); | 1439 return sourceEntry.containingLibraries; |
| 1440 } | 1440 } |
| 1441 return Source.EMPTY_ARRAY; | 1441 return Source.EMPTY_ARRAY; |
| 1442 } | 1442 } |
| 1443 | 1443 |
| 1444 @override | 1444 @override |
| 1445 List<Source> getLibrariesDependingOn(Source librarySource) { | 1445 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 1446 List<Source> dependentLibraries = new List<Source>(); | 1446 List<Source> dependentLibraries = new List<Source>(); |
| 1447 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); | 1447 MapIterator<Source, SourceEntry> iterator = _cache.iterator(); |
| 1448 while (iterator.moveNext()) { | 1448 while (iterator.moveNext()) { |
| 1449 SourceEntry sourceEntry = iterator.value; | 1449 SourceEntry sourceEntry = iterator.value; |
| (...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3169 } | 3169 } |
| 3170 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); | 3170 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); |
| 3171 if (kind == SourceKind.UNKNOWN) { | 3171 if (kind == SourceKind.UNKNOWN) { |
| 3172 return _createParseDartTask(source, dartEntry); | 3172 return _createParseDartTask(source, dartEntry); |
| 3173 } else if (kind == SourceKind.LIBRARY) { | 3173 } else if (kind == SourceKind.LIBRARY) { |
| 3174 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); | 3174 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); |
| 3175 if (elementState == CacheState.INVALID) { | 3175 if (elementState == CacheState.INVALID) { |
| 3176 return _createResolveDartLibraryTask(source, dartEntry); | 3176 return _createResolveDartLibraryTask(source, dartEntry); |
| 3177 } | 3177 } |
| 3178 } | 3178 } |
| 3179 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING
_LIBRARIES); | 3179 List<Source> librariesContaining = dartEntry.containingLibraries; |
| 3180 for (Source librarySource in librariesContaining) { | 3180 for (Source librarySource in librariesContaining) { |
| 3181 SourceEntry librarySourceEntry = _cache.get(librarySource); | 3181 SourceEntry librarySourceEntry = _cache.get(librarySource); |
| 3182 if (librarySourceEntry is DartEntry) { | 3182 if (librarySourceEntry is DartEntry) { |
| 3183 DartEntry libraryEntry = librarySourceEntry; | 3183 DartEntry libraryEntry = librarySourceEntry; |
| 3184 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); | 3184 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); |
| 3185 if (elementState == CacheState.INVALID || (isPriority && elementState
== CacheState.FLUSHED)) { | 3185 if (elementState == CacheState.INVALID || (isPriority && elementState
== CacheState.FLUSHED)) { |
| 3186 //return createResolveDartLibraryTask(librarySource, (DartEntry) lib
raryEntry); | 3186 //return createResolveDartLibraryTask(librarySource, (DartEntry) lib
raryEntry); |
| 3187 libraryEntry.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); | 3187 libraryEntry.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); |
| 3188 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); | 3188 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); |
| 3189 } | 3189 } |
| (...skipping 4112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7302 * * [INVALID] if a source was modified in such a way as to invalidate the pre
vious data | 7302 * * [INVALID] if a source was modified in such a way as to invalidate the pre
vious data |
| 7303 */ | 7303 */ |
| 7304 static const CacheState VALID = const CacheState('VALID', 4); | 7304 static const CacheState VALID = const CacheState('VALID', 4); |
| 7305 | 7305 |
| 7306 static const List<CacheState> values = const [ERROR, FLUSHED, IN_PROCESS, INVA
LID, VALID]; | 7306 static const List<CacheState> values = const [ERROR, FLUSHED, IN_PROCESS, INVA
LID, VALID]; |
| 7307 | 7307 |
| 7308 const CacheState(String name, int ordinal) : super(name, ordinal); | 7308 const CacheState(String name, int ordinal) : super(name, ordinal); |
| 7309 } | 7309 } |
| 7310 | 7310 |
| 7311 /** | 7311 /** |
| 7312 * A `CachedResult` is a single analysis result that is stored in a |
| 7313 * [SourceEntry]. |
| 7314 */ |
| 7315 class CachedResult<E> { |
| 7316 /** |
| 7317 * The state of the cached value. |
| 7318 */ |
| 7319 CacheState state; |
| 7320 |
| 7321 /** |
| 7322 * The value being cached, or `null` if there is no value (for example, when |
| 7323 * the [state] is [CacheState.INVALID]. |
| 7324 */ |
| 7325 E value; |
| 7326 |
| 7327 /** |
| 7328 * Initialize a newly created result holder to represent the value of data |
| 7329 * described by the given [descriptor]. |
| 7330 */ |
| 7331 CachedResult(DataDescriptor descriptor) { |
| 7332 state = CacheState.INVALID; |
| 7333 value = descriptor.defaultValue; |
| 7334 } |
| 7335 } |
| 7336 |
| 7337 /** |
| 7312 * The interface `ChangeNotice` defines the behavior of objects that represent a
change to the | 7338 * The interface `ChangeNotice` defines the behavior of objects that represent a
change to the |
| 7313 * analysis results associated with a given source. | 7339 * analysis results associated with a given source. |
| 7314 */ | 7340 */ |
| 7315 abstract class ChangeNotice implements AnalysisErrorInfo { | 7341 abstract class ChangeNotice implements AnalysisErrorInfo { |
| 7316 /** | 7342 /** |
| 7317 * Return the fully resolved AST that changed as a result of the analysis, or
`null` if the | 7343 * Return the fully resolved AST that changed as a result of the analysis, or
`null` if the |
| 7318 * AST was not changed. | 7344 * AST was not changed. |
| 7319 * | 7345 * |
| 7320 * @return the fully resolved AST that changed as a result of the analysis | 7346 * @return the fully resolved AST that changed as a result of the analysis |
| 7321 */ | 7347 */ |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7720 } | 7746 } |
| 7721 } | 7747 } |
| 7722 | 7748 |
| 7723 | 7749 |
| 7724 /** | 7750 /** |
| 7725 * A `DartEntry` maintains the information cached by an analysis context about | 7751 * A `DartEntry` maintains the information cached by an analysis context about |
| 7726 * an individual Dart file. | 7752 * an individual Dart file. |
| 7727 */ | 7753 */ |
| 7728 class DartEntry extends SourceEntry { | 7754 class DartEntry extends SourceEntry { |
| 7729 /** | 7755 /** |
| 7730 * The state of the cached token stream. | |
| 7731 */ | |
| 7732 CacheState _tokenStreamState = CacheState.INVALID; | |
| 7733 | |
| 7734 /** | |
| 7735 * The head of the token stream, or `null` if the token stream is not | |
| 7736 * currently cached. | |
| 7737 */ | |
| 7738 Token _tokenStream; | |
| 7739 | |
| 7740 /** | |
| 7741 * The state of the cached scan errors. | |
| 7742 */ | |
| 7743 CacheState _scanErrorsState = CacheState.INVALID; | |
| 7744 | |
| 7745 /** | |
| 7746 * The errors produced while scanning the compilation unit, or an empty array | |
| 7747 * if the errors are not currently cached. | |
| 7748 */ | |
| 7749 List<AnalysisError> _scanErrors = AnalysisError.NO_ERRORS; | |
| 7750 | |
| 7751 /** | |
| 7752 * The state of the cached source kind. | |
| 7753 */ | |
| 7754 CacheState _sourceKindState = CacheState.INVALID; | |
| 7755 | |
| 7756 /** | |
| 7757 * The kind of this source. | |
| 7758 */ | |
| 7759 SourceKind _sourceKind = SourceKind.UNKNOWN; | |
| 7760 | |
| 7761 /** | |
| 7762 * The state of the cached parsed compilation unit. | |
| 7763 */ | |
| 7764 CacheState _parsedUnitState = CacheState.INVALID; | |
| 7765 | |
| 7766 /** | |
| 7767 * A flag indicating whether the parsed AST structure has been accessed since | |
| 7768 * it was set. This is used to determine whether the structure needs to be | |
| 7769 * copied before it is resolved. | |
| 7770 */ | |
| 7771 bool _parsedUnitAccessed = false; | |
| 7772 | |
| 7773 /** | |
| 7774 * The parsed compilation unit, or `null` if the parsed compilation unit is | |
| 7775 * not currently cached. | |
| 7776 */ | |
| 7777 CompilationUnit _parsedUnit; | |
| 7778 | |
| 7779 /** | |
| 7780 * The state of the cached parse errors. | |
| 7781 */ | |
| 7782 CacheState _parseErrorsState = CacheState.INVALID; | |
| 7783 | |
| 7784 /** | |
| 7785 * The errors produced while parsing the compilation unit, or an empty array | |
| 7786 * if the errors are not currently cached. | |
| 7787 */ | |
| 7788 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; | |
| 7789 | |
| 7790 /** | |
| 7791 * The state of the cached list of imported libraries. | |
| 7792 */ | |
| 7793 CacheState _importedLibrariesState = CacheState.INVALID; | |
| 7794 | |
| 7795 /** | |
| 7796 * The list of libraries imported by the library, or an empty array if the | |
| 7797 * list is not currently cached. The list will be empty if the Dart file is a | |
| 7798 * part rather than a library. | |
| 7799 */ | |
| 7800 List<Source> _importedLibraries = Source.EMPTY_ARRAY; | |
| 7801 | |
| 7802 /** | |
| 7803 * The state of the cached list of exported libraries. | |
| 7804 */ | |
| 7805 CacheState _exportedLibrariesState = CacheState.INVALID; | |
| 7806 | |
| 7807 /** | |
| 7808 * The list of libraries exported by the library, or an empty array if the | |
| 7809 * list is not currently cached. The list will be empty if the Dart file is a | |
| 7810 * part rather than a library. | |
| 7811 */ | |
| 7812 List<Source> _exportedLibraries = Source.EMPTY_ARRAY; | |
| 7813 | |
| 7814 /** | |
| 7815 * The state of the cached list of included parts. | |
| 7816 */ | |
| 7817 CacheState _includedPartsState = CacheState.INVALID; | |
| 7818 | |
| 7819 /** | |
| 7820 * The list of parts included in the library, or an empty array if the list is | |
| 7821 * not currently cached. The list will be empty if the Dart file is a part | |
| 7822 * rather than a library. | |
| 7823 */ | |
| 7824 List<Source> _includedParts = Source.EMPTY_ARRAY; | |
| 7825 | |
| 7826 /** | |
| 7827 * The list of libraries that contain this compilation unit. The list will be | 7756 * The list of libraries that contain this compilation unit. The list will be |
| 7828 * empty if there are no known libraries that contain this compilation unit. | 7757 * empty if there are no known libraries that contain this compilation unit. |
| 7829 */ | 7758 */ |
| 7830 List<Source> _containingLibraries = new List<Source>(); | 7759 List<Source> _containingLibraries = new List<Source>(); |
| 7831 | 7760 |
| 7832 /** | 7761 /** |
| 7833 * The information known as a result of resolving this compilation unit as | 7762 * The information known as a result of resolving this compilation unit as |
| 7834 * part of the library that contains this unit. This field will never be | 7763 * part of the library that contains this unit. This field will never be |
| 7835 * `null`. | 7764 * `null`. |
| 7836 */ | 7765 */ |
| 7837 ResolutionState _resolutionState | 7766 ResolutionState _resolutionState |
| 7838 = new ResolutionState(); | 7767 = new ResolutionState(); |
| 7839 | 7768 |
| 7840 /** | 7769 /** |
| 7841 * The state of the cached library element. | |
| 7842 */ | |
| 7843 CacheState _elementState = CacheState.INVALID; | |
| 7844 | |
| 7845 /** | |
| 7846 * The element representing the library, or `null` if the element is not | |
| 7847 * currently cached. | |
| 7848 */ | |
| 7849 LibraryElement _element; | |
| 7850 | |
| 7851 /** | |
| 7852 * The state of the cached public namespace. | |
| 7853 */ | |
| 7854 CacheState _publicNamespaceState = CacheState.INVALID; | |
| 7855 | |
| 7856 /** | |
| 7857 * The public namespace of the library, or `null` if the namespace is not | |
| 7858 * currently cached. | |
| 7859 */ | |
| 7860 Namespace _publicNamespace; | |
| 7861 | |
| 7862 /** | |
| 7863 * The state of the cached client/ server flag. | |
| 7864 */ | |
| 7865 CacheState _clientServerState = CacheState.INVALID; | |
| 7866 | |
| 7867 /** | |
| 7868 * The state of the cached launchable flag. | |
| 7869 */ | |
| 7870 CacheState _launchableState = CacheState.INVALID; | |
| 7871 | |
| 7872 /** | |
| 7873 * The error produced while performing Angular resolution, or an empty array | |
| 7874 * if there are no errors if the error are not currently cached. | |
| 7875 */ | |
| 7876 List<AnalysisError> _angularErrors = AnalysisError.NO_ERRORS; | |
| 7877 | |
| 7878 /** | |
| 7879 * The data descriptor representing the errors reported during Angular | 7770 * The data descriptor representing the errors reported during Angular |
| 7880 * resolution. | 7771 * resolution. |
| 7881 */ | 7772 */ |
| 7882 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS | 7773 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS |
| 7883 = new DataDescriptor<List<AnalysisError>>("DartEntry.ANGULAR_ERRORS"); | 7774 = new DataDescriptor<List<AnalysisError>>("DartEntry.ANGULAR_ERRORS", Anal
ysisError.NO_ERRORS); |
| 7775 |
| 7776 /** |
| 7777 * The data descriptor representing the errors resulting from building the |
| 7778 * element model. |
| 7779 */ |
| 7780 static final DataDescriptor<List<AnalysisError>> BUILD_ELEMENT_ERRORS |
| 7781 = new DataDescriptor<List<AnalysisError>>("DartEntry.BUILD_ELEMENT_ERRORS"
, AnalysisError.NO_ERRORS); |
| 7782 |
| 7783 /** |
| 7784 * The data descriptor representing the AST structure after the element model |
| 7785 * has been built (and declarations are resolved) but before other resolution |
| 7786 * has been performed. |
| 7787 */ |
| 7788 static final DataDescriptor<CompilationUnit> BUILT_UNIT |
| 7789 = new DataDescriptor<CompilationUnit>("DartEntry.BUILT_UNIT"); |
| 7884 | 7790 |
| 7885 /** | 7791 /** |
| 7886 * The data descriptor representing the list of libraries that contain this | 7792 * The data descriptor representing the list of libraries that contain this |
| 7887 * compilation unit. | 7793 * compilation unit. |
| 7888 */ | 7794 */ |
| 7889 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES | 7795 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES |
| 7890 = new DataDescriptor<List<Source>>("DartEntry.CONTAINING_LIBRARIES"); | 7796 = new DataDescriptor<List<Source>>("DartEntry.CONTAINING_LIBRARIES", Sourc
e.EMPTY_ARRAY); |
| 7891 | 7797 |
| 7892 /** | 7798 /** |
| 7893 * The data descriptor representing the library element for the library. This | 7799 * The data descriptor representing the library element for the library. This |
| 7894 * data is only available for Dart files that are the defining compilation | 7800 * data is only available for Dart files that are the defining compilation |
| 7895 * unit of a library. | 7801 * unit of a library. |
| 7896 */ | 7802 */ |
| 7897 static final DataDescriptor<LibraryElement> ELEMENT | 7803 static final DataDescriptor<LibraryElement> ELEMENT |
| 7898 = new DataDescriptor<LibraryElement>("DartEntry.ELEMENT"); | 7804 = new DataDescriptor<LibraryElement>("DartEntry.ELEMENT"); |
| 7899 | 7805 |
| 7900 /** | 7806 /** |
| 7901 * The data descriptor representing the list of exported libraries. This data | 7807 * The data descriptor representing the list of exported libraries. This data |
| 7902 * is only available for Dart files that are the defining compilation unit of | 7808 * is only available for Dart files that are the defining compilation unit of |
| 7903 * a library. | 7809 * a library. |
| 7904 */ | 7810 */ |
| 7905 static final DataDescriptor<List<Source>> EXPORTED_LIBRARIES | 7811 static final DataDescriptor<List<Source>> EXPORTED_LIBRARIES |
| 7906 = new DataDescriptor<List<Source>>("DartEntry.EXPORTED_LIBRARIES"); | 7812 = new DataDescriptor<List<Source>>("DartEntry.EXPORTED_LIBRARIES", Source.
EMPTY_ARRAY); |
| 7907 | 7813 |
| 7908 /** | 7814 /** |
| 7909 * The data descriptor representing the hints resulting from auditing the | 7815 * The data descriptor representing the hints resulting from auditing the |
| 7910 * source. | 7816 * source. |
| 7911 */ | 7817 */ |
| 7912 static final DataDescriptor<List<AnalysisError>> HINTS | 7818 static final DataDescriptor<List<AnalysisError>> HINTS |
| 7913 = new DataDescriptor<List<AnalysisError>>("DartEntry.HINTS"); | 7819 = new DataDescriptor<List<AnalysisError>>("DartEntry.HINTS", AnalysisError
.NO_ERRORS); |
| 7914 | 7820 |
| 7915 /** | 7821 /** |
| 7916 * The data descriptor representing the list of imported libraries. This data | 7822 * The data descriptor representing the list of imported libraries. This data |
| 7917 * is only available for Dart files that are the defining compilation unit of | 7823 * is only available for Dart files that are the defining compilation unit of |
| 7918 * a library. | 7824 * a library. |
| 7919 */ | 7825 */ |
| 7920 static final DataDescriptor<List<Source>> IMPORTED_LIBRARIES | 7826 static final DataDescriptor<List<Source>> IMPORTED_LIBRARIES |
| 7921 = new DataDescriptor<List<Source>>("DartEntry.IMPORTED_LIBRARIES"); | 7827 = new DataDescriptor<List<Source>>("DartEntry.IMPORTED_LIBRARIES", Source.
EMPTY_ARRAY); |
| 7922 | 7828 |
| 7923 /** | 7829 /** |
| 7924 * The data descriptor representing the list of included parts. This data is | 7830 * The data descriptor representing the list of included parts. This data is |
| 7925 * only available for Dart files that are the defining compilation unit of a | 7831 * only available for Dart files that are the defining compilation unit of a |
| 7926 * library. | 7832 * library. |
| 7927 */ | 7833 */ |
| 7928 static final DataDescriptor<List<Source>> INCLUDED_PARTS | 7834 static final DataDescriptor<List<Source>> INCLUDED_PARTS |
| 7929 = new DataDescriptor<List<Source>>("DartEntry.INCLUDED_PARTS"); | 7835 = new DataDescriptor<List<Source>>("DartEntry.INCLUDED_PARTS", Source.EMPT
Y_ARRAY); |
| 7930 | 7836 |
| 7931 /** | 7837 /** |
| 7932 * The data descriptor representing the client flag. This data is only | 7838 * The data descriptor representing the client flag. This data is only |
| 7933 * available for Dart files that are the defining compilation unit of a | 7839 * available for Dart files that are the defining compilation unit of a |
| 7934 * library. | 7840 * library. |
| 7935 */ | 7841 */ |
| 7936 static final DataDescriptor<bool> IS_CLIENT | 7842 static final DataDescriptor<bool> IS_CLIENT |
| 7937 = new DataDescriptor<bool>("DartEntry.IS_CLIENT"); | 7843 = new DataDescriptor<bool>("DartEntry.IS_CLIENT", false); |
| 7938 | 7844 |
| 7939 /** | 7845 /** |
| 7940 * The data descriptor representing the launchable flag. This data is only | 7846 * The data descriptor representing the launchable flag. This data is only |
| 7941 * available for Dart files that are the defining compilation unit of a | 7847 * available for Dart files that are the defining compilation unit of a |
| 7942 * library. | 7848 * library. |
| 7943 */ | 7849 */ |
| 7944 static final DataDescriptor<bool> IS_LAUNCHABLE | 7850 static final DataDescriptor<bool> IS_LAUNCHABLE |
| 7945 = new DataDescriptor<bool>("DartEntry.IS_LAUNCHABLE"); | 7851 = new DataDescriptor<bool>("DartEntry.IS_LAUNCHABLE", false); |
| 7946 | 7852 |
| 7947 /** | 7853 /** |
| 7948 * The data descriptor representing the errors resulting from parsing the | 7854 * The data descriptor representing the errors resulting from parsing the |
| 7949 * source. | 7855 * source. |
| 7950 */ | 7856 */ |
| 7951 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS | 7857 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS |
| 7952 = new DataDescriptor<List<AnalysisError>>("DartEntry.PARSE_ERRORS"); | 7858 = new DataDescriptor<List<AnalysisError>>("DartEntry.PARSE_ERRORS", Analys
isError.NO_ERRORS); |
| 7953 | 7859 |
| 7954 /** | 7860 /** |
| 7955 * The data descriptor representing the parsed AST structure. | 7861 * The data descriptor representing the parsed AST structure. |
| 7956 */ | 7862 */ |
| 7957 static final DataDescriptor<CompilationUnit> PARSED_UNIT | 7863 static final DataDescriptor<CompilationUnit> PARSED_UNIT |
| 7958 = new DataDescriptor<CompilationUnit>("DartEntry.PARSED_UNIT"); | 7864 = new DataDescriptor<CompilationUnit>("DartEntry.PARSED_UNIT"); |
| 7959 | 7865 |
| 7960 /** | 7866 /** |
| 7961 * The data descriptor representing the public namespace of the library. This | 7867 * The data descriptor representing the public namespace of the library. This |
| 7962 * data is only available for Dart files that are the defining compilation | 7868 * data is only available for Dart files that are the defining compilation |
| 7963 * unit of a library. | 7869 * unit of a library. |
| 7964 */ | 7870 */ |
| 7965 static final DataDescriptor<Namespace> PUBLIC_NAMESPACE | 7871 static final DataDescriptor<Namespace> PUBLIC_NAMESPACE |
| 7966 = new DataDescriptor<Namespace>("DartEntry.PUBLIC_NAMESPACE"); | 7872 = new DataDescriptor<Namespace>("DartEntry.PUBLIC_NAMESPACE"); |
| 7967 | 7873 |
| 7968 /** | 7874 /** |
| 7969 * The data descriptor representing the errors resulting from resolving the | 7875 * The data descriptor representing the errors resulting from resolving the |
| 7970 * source. | 7876 * source. |
| 7971 */ | 7877 */ |
| 7972 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS | 7878 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS |
| 7973 = new DataDescriptor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS"); | 7879 = new DataDescriptor<List<AnalysisError>>("DartEntry.RESOLUTION_ERRORS", A
nalysisError.NO_ERRORS); |
| 7974 | 7880 |
| 7975 /** | 7881 /** |
| 7976 * The data descriptor representing the resolved AST structure. | 7882 * The data descriptor representing the resolved AST structure. |
| 7977 */ | 7883 */ |
| 7978 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT | 7884 static final DataDescriptor<CompilationUnit> RESOLVED_UNIT |
| 7979 = new DataDescriptor<CompilationUnit>("DartEntry.RESOLVED_UNIT"); | 7885 = new DataDescriptor<CompilationUnit>("DartEntry.RESOLVED_UNIT"); |
| 7980 | 7886 |
| 7981 /** | 7887 /** |
| 7982 * The data descriptor representing the token stream. | 7888 * The data descriptor representing the token stream. |
| 7983 */ | 7889 */ |
| 7984 static final DataDescriptor<List<AnalysisError>> SCAN_ERRORS | 7890 static final DataDescriptor<List<AnalysisError>> SCAN_ERRORS |
| 7985 = new DataDescriptor<List<AnalysisError>>("DartEntry.SCAN_ERRORS"); | 7891 = new DataDescriptor<List<AnalysisError>>("DartEntry.SCAN_ERRORS", Analysi
sError.NO_ERRORS); |
| 7986 | 7892 |
| 7987 /** | 7893 /** |
| 7988 * The data descriptor representing the source kind. | 7894 * The data descriptor representing the source kind. |
| 7989 */ | 7895 */ |
| 7990 static final DataDescriptor<SourceKind> SOURCE_KIND | 7896 static final DataDescriptor<SourceKind> SOURCE_KIND |
| 7991 = new DataDescriptor<SourceKind>("DartEntry.SOURCE_KIND"); | 7897 = new DataDescriptor<SourceKind>("DartEntry.SOURCE_KIND", SourceKind.UNKNO
WN); |
| 7992 | 7898 |
| 7993 /** | 7899 /** |
| 7994 * The data descriptor representing the token stream. | 7900 * The data descriptor representing the token stream. |
| 7995 */ | 7901 */ |
| 7996 static final DataDescriptor<Token> TOKEN_STREAM | 7902 static final DataDescriptor<Token> TOKEN_STREAM |
| 7997 = new DataDescriptor<Token>("DartEntry.TOKEN_STREAM"); | 7903 = new DataDescriptor<Token>("DartEntry.TOKEN_STREAM"); |
| 7998 | 7904 |
| 7999 /** | 7905 /** |
| 8000 * The data descriptor representing the errors resulting from verifying the | 7906 * The data descriptor representing the errors resulting from verifying the |
| 8001 * source. | 7907 * source. |
| 8002 */ | 7908 */ |
| 8003 static final DataDescriptor<List<AnalysisError>> VERIFICATION_ERRORS | 7909 static final DataDescriptor<List<AnalysisError>> VERIFICATION_ERRORS |
| 8004 = new DataDescriptor<List<AnalysisError>>("DartEntry.VERIFICATION_ERRORS")
; | 7910 = new DataDescriptor<List<AnalysisError>>("DartEntry.VERIFICATION_ERRORS",
AnalysisError.NO_ERRORS); |
| 8005 | |
| 8006 /** | |
| 8007 * The index of the flag indicating whether this library is launchable | |
| 8008 * (whether the file has a main method). | |
| 8009 */ | |
| 8010 static int _LAUNCHABLE_INDEX = 1; | |
| 8011 | |
| 8012 /** | |
| 8013 * The index of the flag indicating whether the library is client code | |
| 8014 * (whether the library depends on the html library). If the library is not | |
| 8015 * "client code", then it is referred to as "server code". | |
| 8016 */ | |
| 8017 static int _CLIENT_CODE_INDEX = 2; | |
| 8018 | 7911 |
| 8019 /** | 7912 /** |
| 8020 * Add the given [librarySource] to the list of libraries that contain this | 7913 * Add the given [librarySource] to the list of libraries that contain this |
| 8021 * part. This method should only be invoked on entries that represent a part. | 7914 * part. This method should only be invoked on entries that represent a part. |
| 8022 */ | 7915 */ |
| 8023 void addContainingLibrary(Source librarySource) { | 7916 void addContainingLibrary(Source librarySource) { |
| 8024 _containingLibraries.add(librarySource); | 7917 _containingLibraries.add(librarySource); |
| 8025 } | 7918 } |
| 8026 | 7919 |
| 8027 /** | 7920 /** |
| 8028 * Flush any AST structures being maintained by this entry. | 7921 * Flush any AST structures being maintained by this entry. |
| 8029 */ | 7922 */ |
| 8030 void flushAstStructures() { | 7923 void flushAstStructures() { |
| 8031 if (_tokenStreamState == CacheState.VALID) { | 7924 _flush(TOKEN_STREAM); |
| 8032 _tokenStreamState = CacheState.FLUSHED; | 7925 _flush(PARSED_UNIT); |
| 8033 _tokenStream = null; | |
| 8034 } | |
| 8035 if (_parsedUnitState == CacheState.VALID) { | |
| 8036 _parsedUnitState = CacheState.FLUSHED; | |
| 8037 _parsedUnitAccessed = false; | |
| 8038 _parsedUnit = null; | |
| 8039 } | |
| 8040 _resolutionState.flushAstStructures(); | 7926 _resolutionState.flushAstStructures(); |
| 8041 } | 7927 } |
| 8042 | 7928 |
| 8043 /** | 7929 /** |
| 8044 * Return all of the errors associated with the compilation unit that are | 7930 * Return all of the errors associated with the compilation unit that are |
| 8045 * currently cached. | 7931 * currently cached. |
| 8046 */ | 7932 */ |
| 8047 List<AnalysisError> get allErrors { | 7933 List<AnalysisError> get allErrors { |
| 8048 List<AnalysisError> errors = new List<AnalysisError>(); | 7934 List<AnalysisError> errors = new List<AnalysisError>(); |
| 8049 ListUtilities.addAll(errors, _scanErrors); | 7935 errors.addAll(getValue(SCAN_ERRORS)); |
| 8050 ListUtilities.addAll(errors, _parseErrors); | 7936 errors.addAll(getValue(PARSE_ERRORS)); |
| 8051 ResolutionState state = _resolutionState; | 7937 ResolutionState state = _resolutionState; |
| 8052 while (state != null) { | 7938 while (state != null) { |
| 8053 ListUtilities.addAll(errors, state._buildElementErrors); | 7939 errors.addAll(state.getValue(BUILD_ELEMENT_ERRORS)); |
| 8054 ListUtilities.addAll(errors, state._resolutionErrors); | 7940 errors.addAll(state.getValue(RESOLUTION_ERRORS)); |
| 8055 ListUtilities.addAll(errors, state._verificationErrors); | 7941 errors.addAll(state.getValue(VERIFICATION_ERRORS)); |
| 8056 ListUtilities.addAll(errors, state._hints); | 7942 errors.addAll(state.getValue(HINTS)); |
| 8057 state = state._nextState; | 7943 state = state._nextState; |
| 8058 } | 7944 } |
| 8059 ListUtilities.addAll(errors, _angularErrors); | 7945 errors.addAll(getValue(ANGULAR_ERRORS)); |
| 8060 if (errors.length == 0) { | 7946 if (errors.length == 0) { |
| 8061 return AnalysisError.NO_ERRORS; | 7947 return AnalysisError.NO_ERRORS; |
| 8062 } | 7948 } |
| 8063 return new List.from(errors); | 7949 return new List.from(errors); |
| 8064 } | 7950 } |
| 8065 | 7951 |
| 8066 /** | 7952 /** |
| 8067 * Return a valid parsed compilation unit, either an unresolved AST structure | 7953 * Return a valid parsed compilation unit, either an unresolved AST structure |
| 8068 * or the result of resolving the AST structure in the context of some library
, | 7954 * or the result of resolving the AST structure in the context of some library
, |
| 8069 * or `null` if there is no parsed compilation unit available. | 7955 * or `null` if there is no parsed compilation unit available. |
| 8070 */ | 7956 */ |
| 8071 CompilationUnit get anyParsedCompilationUnit { | 7957 CompilationUnit get anyParsedCompilationUnit { |
| 8072 if (_parsedUnitState == CacheState.VALID) { | 7958 if (getState(PARSED_UNIT) == CacheState.VALID) { |
| 8073 _parsedUnitAccessed = true; | 7959 return getValue(PARSED_UNIT); |
| 8074 return _parsedUnit; | |
| 8075 } | 7960 } |
| 8076 ResolutionState state = _resolutionState; | 7961 ResolutionState state = _resolutionState; |
| 8077 while (state != null) { | 7962 while (state != null) { |
| 8078 if (state._builtUnitState == CacheState.VALID) { | 7963 if (state.getState(BUILT_UNIT) == CacheState.VALID) { |
| 8079 return state._builtUnit; | 7964 return state.getValue(BUILT_UNIT); |
| 8080 } | 7965 } |
| 8081 state = state._nextState; | 7966 state = state._nextState; |
| 8082 } | 7967 } |
| 8083 ; | 7968 ; |
| 8084 return anyResolvedCompilationUnit; | 7969 return anyResolvedCompilationUnit; |
| 8085 } | 7970 } |
| 8086 | 7971 |
| 8087 /** | 7972 /** |
| 8088 * Return the result of resolving the compilation unit as part of any library, | 7973 * Return the result of resolving the compilation unit as part of any library, |
| 8089 * or `null` if there is no cached resolved compilation unit. | 7974 * or `null` if there is no cached resolved compilation unit. |
| 8090 */ | 7975 */ |
| 8091 CompilationUnit get anyResolvedCompilationUnit { | 7976 CompilationUnit get anyResolvedCompilationUnit { |
| 8092 ResolutionState state = _resolutionState; | 7977 ResolutionState state = _resolutionState; |
| 8093 while (state != null) { | 7978 while (state != null) { |
| 8094 if (state._resolvedUnitState == CacheState.VALID) { | 7979 if (state.getState(RESOLVED_UNIT) == CacheState.VALID) { |
| 8095 return state._resolvedUnit; | 7980 return state.getValue(RESOLVED_UNIT); |
| 8096 } | 7981 } |
| 8097 state = state._nextState; | 7982 state = state._nextState; |
| 8098 } | 7983 } |
| 8099 ; | |
| 8100 return null; | 7984 return null; |
| 8101 } | 7985 } |
| 8102 | 7986 |
| 8103 /** | 7987 /** |
| 8104 * The libraries that are known to contain this part. | 7988 * The libraries that are known to contain this part. |
| 8105 */ | 7989 */ |
| 8106 List<Source> get containingLibraries => _containingLibraries; | 7990 List<Source> get containingLibraries => _containingLibraries; |
| 8107 | 7991 |
| 8108 @override | 7992 @override |
| 8109 SourceKind get kind => _sourceKind; | 7993 SourceKind get kind => getValue(SOURCE_KIND); |
| 8110 | 7994 |
| 8111 /** | 7995 /** |
| 8112 * The library sources containing the receiver's source. | 7996 * The library sources containing the receiver's source. |
| 8113 */ | 7997 */ |
| 8114 List<Source> get librariesContaining { | 7998 List<Source> get librariesContaining { |
| 8115 ResolutionState state = _resolutionState; | 7999 ResolutionState state = _resolutionState; |
| 8116 List<Source> result = new List<Source>(); | 8000 List<Source> result = new List<Source>(); |
| 8117 while (state != null) { | 8001 while (state != null) { |
| 8118 if (state._librarySource != null) { | 8002 if (state._librarySource != null) { |
| 8119 result.add(state._librarySource); | 8003 result.add(state._librarySource); |
| 8120 } | 8004 } |
| 8121 state = state._nextState; | 8005 state = state._nextState; |
| 8122 } | 8006 } |
| 8123 return new List.from(result); | 8007 return new List.from(result); |
| 8124 } | 8008 } |
| 8125 | 8009 |
| 8126 /** | 8010 /** |
| 8127 * A compilation unit that has not been accessed by any other client and can | 8011 * A compilation unit that has not been accessed by any other client and can |
| 8128 * therefore safely be modified by the reconciler, or `null` if the source has | 8012 * therefore safely be modified by the reconciler, or `null` if the source has |
| 8129 * not been parsed. | 8013 * not been parsed. |
| 8130 */ | 8014 */ |
| 8131 CompilationUnit get resolvableCompilationUnit { | 8015 CompilationUnit get resolvableCompilationUnit { |
| 8132 if (_parsedUnitState == CacheState.VALID) { | 8016 if (getState(PARSED_UNIT) == CacheState.VALID) { |
| 8133 if (_parsedUnitAccessed) { | 8017 CompilationUnit unit = getValue(PARSED_UNIT); |
| 8134 return _parsedUnit.accept(new AstCloner()) as CompilationUnit; | 8018 setState(PARSED_UNIT, CacheState.FLUSHED); |
| 8135 } | |
| 8136 CompilationUnit unit = _parsedUnit; | |
| 8137 _parsedUnitState = CacheState.FLUSHED; | |
| 8138 _parsedUnitAccessed = false; | |
| 8139 _parsedUnit = null; | |
| 8140 return unit; | 8019 return unit; |
| 8141 } | 8020 } |
| 8142 ResolutionState state = _resolutionState; | 8021 ResolutionState state = _resolutionState; |
| 8143 while (state != null) { | 8022 while (state != null) { |
| 8144 if (state._builtUnitState == CacheState.VALID) { | 8023 if (state.getState(BUILT_UNIT) == CacheState.VALID) { |
| 8145 // TODO(brianwilkerson) We're cloning the structure to remove any | 8024 // TODO(brianwilkerson) We're cloning the structure to remove any |
| 8146 // previous resolution data, but I'm not sure that's necessary. | 8025 // previous resolution data, but I'm not sure that's necessary. |
| 8147 return state._builtUnit.accept(new AstCloner()) as CompilationUnit; | 8026 return state.getValue(BUILT_UNIT).accept(new AstCloner()) as Compilation
Unit; |
| 8148 } | 8027 } |
| 8149 if (state._resolvedUnitState == CacheState.VALID) { | 8028 if (state.getState(RESOLVED_UNIT) == CacheState.VALID) { |
| 8150 return state._resolvedUnit.accept(new AstCloner()) as CompilationUnit; | 8029 return state.getValue(RESOLVED_UNIT).accept(new AstCloner()) as Compilat
ionUnit; |
| 8151 } | 8030 } |
| 8152 state = state._nextState; | 8031 state = state._nextState; |
| 8153 } | 8032 } |
| 8154 ; | |
| 8155 return null; | 8033 return null; |
| 8156 } | 8034 } |
| 8157 | 8035 |
| 8158 @override | |
| 8159 CacheState getState(DataDescriptor descriptor) { | |
| 8160 if (identical(descriptor, DartEntry.ELEMENT)) { | |
| 8161 return _elementState; | |
| 8162 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | |
| 8163 return _exportedLibrariesState; | |
| 8164 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | |
| 8165 return _importedLibrariesState; | |
| 8166 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | |
| 8167 return _includedPartsState; | |
| 8168 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | |
| 8169 return _clientServerState; | |
| 8170 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | |
| 8171 return _launchableState; | |
| 8172 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | |
| 8173 return _parseErrorsState; | |
| 8174 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | |
| 8175 return _parsedUnitState; | |
| 8176 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | |
| 8177 return _publicNamespaceState; | |
| 8178 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { | |
| 8179 return _scanErrorsState; | |
| 8180 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | |
| 8181 return _sourceKindState; | |
| 8182 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { | |
| 8183 return _tokenStreamState; | |
| 8184 } else { | |
| 8185 return super.getState(descriptor); | |
| 8186 } | |
| 8187 } | |
| 8188 | |
| 8189 /** | 8036 /** |
| 8190 * Return the state of the data represented by the given [descriptor] in the | 8037 * Return the state of the data represented by the given [descriptor] in the |
| 8191 * context of the given [librarySource]. | 8038 * context of the given [librarySource]. |
| 8192 */ | 8039 */ |
| 8193 CacheState getStateInLibrary(DataDescriptor descriptor, Source librarySource)
{ | 8040 CacheState getStateInLibrary(DataDescriptor descriptor, Source librarySource)
{ |
| 8041 if (!_isValidLibraryDescriptor(descriptor)) { |
| 8042 throw new ArgumentError("Invalid descriptor: $descriptor"); |
| 8043 } |
| 8194 ResolutionState state = _resolutionState; | 8044 ResolutionState state = _resolutionState; |
| 8195 while (state != null) { | 8045 while (state != null) { |
| 8196 if (librarySource == state._librarySource) { | 8046 if (librarySource == state._librarySource) { |
| 8197 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 8047 return state.getState(descriptor); |
| 8198 return state._resolutionErrorsState; | |
| 8199 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | |
| 8200 return state._resolvedUnitState; | |
| 8201 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { | |
| 8202 return state._verificationErrorsState; | |
| 8203 } else if (identical(descriptor, DartEntry.HINTS)) { | |
| 8204 return state._hintsState; | |
| 8205 } else { | |
| 8206 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); | |
| 8207 } | |
| 8208 } | 8048 } |
| 8209 state = state._nextState; | 8049 state = state._nextState; |
| 8210 } | 8050 } |
| 8211 ; | 8051 return CacheState.INVALID; |
| 8212 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) | |
| 8213 || identical(descriptor, DartEntry.RESOLVED_UNIT) | |
| 8214 || identical(descriptor, DartEntry.VERIFICATION_ERRORS) | |
| 8215 || identical(descriptor, DartEntry.HINTS)) { | |
| 8216 return CacheState.INVALID; | |
| 8217 } else { | |
| 8218 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | |
| 8219 } | |
| 8220 } | |
| 8221 | |
| 8222 @override | |
| 8223 Object getValue(DataDescriptor descriptor) { | |
| 8224 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) { | |
| 8225 return _angularErrors; | |
| 8226 } else if (identical(descriptor, DartEntry.CONTAINING_LIBRARIES)) { | |
| 8227 return new List.from(_containingLibraries); | |
| 8228 } else if (identical(descriptor, DartEntry.ELEMENT)) { | |
| 8229 return _element; | |
| 8230 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | |
| 8231 return _exportedLibraries; | |
| 8232 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | |
| 8233 return _importedLibraries; | |
| 8234 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | |
| 8235 return _includedParts; | |
| 8236 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | |
| 8237 return getFlag(_CLIENT_CODE_INDEX); | |
| 8238 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | |
| 8239 return getFlag(_LAUNCHABLE_INDEX); | |
| 8240 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | |
| 8241 return _parseErrors; | |
| 8242 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | |
| 8243 _parsedUnitAccessed = true; | |
| 8244 return _parsedUnit; | |
| 8245 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | |
| 8246 return _publicNamespace; | |
| 8247 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { | |
| 8248 return _scanErrors; | |
| 8249 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | |
| 8250 return _sourceKind; | |
| 8251 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { | |
| 8252 return _tokenStream; | |
| 8253 } | |
| 8254 return super.getValue(descriptor); | |
| 8255 } | 8052 } |
| 8256 | 8053 |
| 8257 /** | 8054 /** |
| 8258 * Return the value of the data represented by the given [descriptor] in the | 8055 * Return the value of the data represented by the given [descriptor] in the |
| 8259 * context of the given [librarySource], or `null` if the data represented by | 8056 * context of the given [librarySource], or `null` if the data represented by |
| 8260 * the descriptor is not in the cache. | 8057 * the descriptor is not in the cache. |
| 8261 */ | 8058 */ |
| 8262 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource) { | 8059 Object getValueInLibrary(DataDescriptor descriptor, Source librarySource) { |
| 8060 if (!_isValidLibraryDescriptor(descriptor)) { |
| 8061 throw new ArgumentError("Invalid descriptor: $descriptor"); |
| 8062 } |
| 8263 ResolutionState state = _resolutionState; | 8063 ResolutionState state = _resolutionState; |
| 8264 while (state != null) { | 8064 while (state != null) { |
| 8265 if (librarySource == state._librarySource) { | 8065 if (librarySource == state._librarySource) { |
| 8266 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 8066 return state.getValue(descriptor); |
| 8267 return state._resolutionErrors; | |
| 8268 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | |
| 8269 return state._resolvedUnit; | |
| 8270 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { | |
| 8271 return state._verificationErrors; | |
| 8272 } else if (identical(descriptor, DartEntry.HINTS)) { | |
| 8273 return state._hints; | |
| 8274 } else { | |
| 8275 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"
); | |
| 8276 } | |
| 8277 } | 8067 } |
| 8278 state = state._nextState; | 8068 state = state._nextState; |
| 8279 } | 8069 } |
| 8280 ; | 8070 return descriptor.defaultValue; |
| 8281 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) | |
| 8282 || identical(descriptor, DartEntry.VERIFICATION_ERRORS) | |
| 8283 || identical(descriptor, DartEntry.HINTS)) { | |
| 8284 return AnalysisError.NO_ERRORS; | |
| 8285 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | |
| 8286 return null; | |
| 8287 } else { | |
| 8288 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | |
| 8289 } | |
| 8290 } | 8071 } |
| 8291 | 8072 |
| 8292 /** | 8073 /** |
| 8293 * Return `true` if the data represented by the given [descriptor] is marked | 8074 * Return `true` if the data represented by the given [descriptor] is marked |
| 8294 * as being invalid. If the descriptor represents library-specific data then | 8075 * as being invalid. If the descriptor represents library-specific data then |
| 8295 * this method will return `true` if the data associated with any library it | 8076 * this method will return `true` if the data associated with any library it |
| 8296 * marked as invalid. | 8077 * marked as invalid. |
| 8297 */ | 8078 */ |
| 8298 bool hasInvalidData(DataDescriptor descriptor) { | 8079 bool hasInvalidData(DataDescriptor descriptor) { |
| 8299 if (identical(descriptor, DartEntry.ELEMENT)) { | 8080 if (_isValidDescriptor(descriptor)) { |
| 8300 return _elementState == CacheState.INVALID; | 8081 return getState(descriptor) == CacheState.INVALID; |
| 8301 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 8082 } else if (_isValidLibraryDescriptor(descriptor)) { |
| 8302 return _exportedLibrariesState == CacheState.INVALID; | |
| 8303 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | |
| 8304 return _importedLibrariesState == CacheState.INVALID; | |
| 8305 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | |
| 8306 return _includedPartsState == CacheState.INVALID; | |
| 8307 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | |
| 8308 return _clientServerState == CacheState.INVALID; | |
| 8309 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | |
| 8310 return _launchableState == CacheState.INVALID; | |
| 8311 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | |
| 8312 return _parseErrorsState == CacheState.INVALID; | |
| 8313 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | |
| 8314 return _parsedUnitState == CacheState.INVALID; | |
| 8315 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | |
| 8316 return _publicNamespaceState == CacheState.INVALID; | |
| 8317 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { | |
| 8318 return _scanErrorsState == CacheState.INVALID; | |
| 8319 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | |
| 8320 return _sourceKindState == CacheState.INVALID; | |
| 8321 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { | |
| 8322 return _tokenStreamState == CacheState.INVALID; | |
| 8323 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) | |
| 8324 || identical(descriptor, DartEntry.RESOLVED_UNIT) | |
| 8325 || identical(descriptor, DartEntry.VERIFICATION_ERRORS) | |
| 8326 || identical(descriptor, DartEntry.HINTS)) { | |
| 8327 ResolutionState state = _resolutionState; | 8083 ResolutionState state = _resolutionState; |
| 8328 while (state != null) { | 8084 while (state != null) { |
| 8329 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 8085 if (state.getState(descriptor) == CacheState.INVALID) { |
| 8330 return state._resolutionErrorsState == CacheState.INVALID; | 8086 return true; |
| 8331 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | |
| 8332 return state._resolvedUnitState == CacheState.INVALID; | |
| 8333 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { | |
| 8334 return state._verificationErrorsState == CacheState.INVALID; | |
| 8335 } else if (identical(descriptor, DartEntry.HINTS)) { | |
| 8336 return state._hintsState == CacheState.INVALID; | |
| 8337 } | 8087 } |
| 8088 state = state._nextState; |
| 8338 } | 8089 } |
| 8339 return false; | |
| 8340 } else { | |
| 8341 return super.getState(descriptor) == CacheState.INVALID; | |
| 8342 } | 8090 } |
| 8091 return false; |
| 8343 } | 8092 } |
| 8344 | 8093 |
| 8345 /** | 8094 /** |
| 8346 * Return `true` if this entry has an AST structure that can be resolved, even | 8095 * Return `true` if this entry has an AST structure that can be resolved, even |
| 8347 * if it needs to be copied. Returning `true` implies that the method | 8096 * if it needs to be copied. Returning `true` implies that the method |
| 8348 * [resolvableCompilationUnit] will return a non-`null` result. | 8097 * [resolvableCompilationUnit] will return a non-`null` result. |
| 8349 */ | 8098 */ |
| 8350 bool get hasResolvableCompilationUnit { | 8099 bool get hasResolvableCompilationUnit { |
| 8351 if (_parsedUnitState == CacheState.VALID) { | 8100 if (getState(PARSED_UNIT) == CacheState.VALID) { |
| 8352 return true; | 8101 return true; |
| 8353 } | 8102 } |
| 8354 ResolutionState state = _resolutionState; | 8103 ResolutionState state = _resolutionState; |
| 8355 while (state != null) { | 8104 while (state != null) { |
| 8356 if (state._builtUnitState == CacheState.VALID | 8105 if (state.getState(BUILT_UNIT) == CacheState.VALID |
| 8357 || state._resolvedUnitState == CacheState.VALID) { | 8106 || state.getState(RESOLVED_UNIT) == CacheState.VALID) { |
| 8358 return true; | 8107 return true; |
| 8359 } | 8108 } |
| 8360 state = state._nextState; | 8109 state = state._nextState; |
| 8361 } | 8110 } |
| 8362 ; | 8111 ; |
| 8363 return false; | 8112 return false; |
| 8364 } | 8113 } |
| 8365 | 8114 |
| 8366 @override | 8115 @override |
| 8367 void invalidateAllInformation() { | 8116 void invalidateAllInformation() { |
| 8368 super.invalidateAllInformation(); | 8117 super.invalidateAllInformation(); |
| 8369 _scanErrors = AnalysisError.NO_ERRORS; | 8118 setState(SCAN_ERRORS, CacheState.INVALID); |
| 8370 _scanErrorsState = CacheState.INVALID; | 8119 setState(TOKEN_STREAM, CacheState.INVALID); |
| 8371 _tokenStream = null; | 8120 setState(SOURCE_KIND, CacheState.INVALID); |
| 8372 _tokenStreamState = CacheState.INVALID; | 8121 setState(PARSE_ERRORS, CacheState.INVALID); |
| 8373 _sourceKind = SourceKind.UNKNOWN; | 8122 setState(PARSED_UNIT, CacheState.INVALID); |
| 8374 _sourceKindState = CacheState.INVALID; | |
| 8375 _parseErrors = AnalysisError.NO_ERRORS; | |
| 8376 _parseErrorsState = CacheState.INVALID; | |
| 8377 _parsedUnit = null; | |
| 8378 _parsedUnitAccessed = false; | |
| 8379 _parsedUnitState = CacheState.INVALID; | |
| 8380 _discardCachedResolutionInformation(true); | 8123 _discardCachedResolutionInformation(true); |
| 8381 } | 8124 } |
| 8382 | 8125 |
| 8383 /** | 8126 /** |
| 8384 * Invalidate all of the resolution information associated with the | 8127 * Invalidate all of the resolution information associated with the |
| 8385 * compilation unit. The flag [invalidateUris] should be `true` if the cached | 8128 * compilation unit. The flag [invalidateUris] should be `true` if the cached |
| 8386 * results of converting URIs to source files should also be invalidated. | 8129 * results of converting URIs to source files should also be invalidated. |
| 8387 */ | 8130 */ |
| 8388 void invalidateAllResolutionInformation(bool invalidateUris) { | 8131 void invalidateAllResolutionInformation(bool invalidateUris) { |
| 8389 if (_parsedUnitState == CacheState.FLUSHED) { | 8132 if (getState(PARSED_UNIT) == CacheState.FLUSHED) { |
| 8390 ResolutionState state = _resolutionState; | 8133 ResolutionState state = _resolutionState; |
| 8391 while (state != null) { | 8134 while (state != null) { |
| 8392 if (state._builtUnitState == CacheState.VALID) { | 8135 if (state.getState(BUILT_UNIT) == CacheState.VALID) { |
| 8393 _parsedUnit = state._builtUnit; | 8136 setValue(PARSED_UNIT, state.getValue(BUILT_UNIT)); |
| 8394 _parsedUnitAccessed = true; | |
| 8395 _parsedUnitState = CacheState.VALID; | |
| 8396 break; | 8137 break; |
| 8397 } else if (state._resolvedUnitState == CacheState.VALID) { | 8138 } else if (state.getState(RESOLVED_UNIT) == CacheState.VALID) { |
| 8398 _parsedUnit = state._resolvedUnit; | 8139 setValue(PARSED_UNIT, state.getValue(RESOLVED_UNIT)); |
| 8399 _parsedUnitAccessed = true; | |
| 8400 _parsedUnitState = CacheState.VALID; | |
| 8401 break; | 8140 break; |
| 8402 } | 8141 } |
| 8403 state = state._nextState; | 8142 state = state._nextState; |
| 8404 } | 8143 } |
| 8405 } | 8144 } |
| 8406 _discardCachedResolutionInformation(invalidateUris); | 8145 _discardCachedResolutionInformation(invalidateUris); |
| 8407 } | 8146 } |
| 8408 | 8147 |
| 8409 /** | 8148 /** |
| 8410 * Return `true` if this data is safe to use in refactoring. | 8149 * Return `true` if this data is safe to use in refactoring. |
| 8411 */ | 8150 */ |
| 8412 bool get isRefactoringSafe { | 8151 bool get isRefactoringSafe { |
| 8413 ResolutionState state = _resolutionState; | 8152 ResolutionState state = _resolutionState; |
| 8414 while (state != null) { | 8153 while (state != null) { |
| 8415 CacheState resolvedState = state._resolvedUnitState; | 8154 CacheState resolvedState = state.getState(RESOLVED_UNIT); |
| 8416 if (resolvedState != CacheState.VALID | 8155 if (resolvedState != CacheState.VALID |
| 8417 && resolvedState != CacheState.FLUSHED) { | 8156 && resolvedState != CacheState.FLUSHED) { |
| 8418 return false; | 8157 return false; |
| 8419 } | 8158 } |
| 8420 state = state._nextState; | 8159 state = state._nextState; |
| 8421 } | 8160 } |
| 8422 return true; | 8161 return true; |
| 8423 } | 8162 } |
| 8424 | 8163 |
| 8425 /** | 8164 /** |
| 8426 * Record that an error occurred while attempting to build the element model | 8165 * Record that an error occurred while attempting to build the element model |
| 8427 * for the source represented by this entry. This will set the state of all | 8166 * for the source represented by this entry. This will set the state of all |
| 8428 * resolution-based information as being in error, but will not change the | 8167 * resolution-based information as being in error, but will not change the |
| 8429 * state of any parse results. | 8168 * state of any parse results. |
| 8430 * | 8169 * |
| 8431 * @param librarySource the source of the library in which the element model w
as being built | 8170 * @param librarySource the source of the library in which the element model w
as being built |
| 8432 * @param exception the exception that shows where the error occurred | 8171 * @param exception the exception that shows where the error occurred |
| 8433 */ | 8172 */ |
| 8434 void recordBuildElementErrorInLibrary(Source librarySource, CaughtException ex
ception) { | 8173 void recordBuildElementErrorInLibrary(Source librarySource, CaughtException ex
ception) { |
| 8435 this.exception = exception; | 8174 this.exception = exception; |
| 8436 _element = null; | 8175 setState(ELEMENT, CacheState.ERROR); |
| 8437 _elementState = CacheState.ERROR; | 8176 setState(IS_LAUNCHABLE, CacheState.ERROR); |
| 8438 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]); | 8177 setState(IS_CLIENT, CacheState.ERROR); |
| 8439 _clientServerState = CacheState.ERROR; | |
| 8440 _launchableState = CacheState.ERROR; | |
| 8441 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8178 ResolutionState state = _getOrCreateResolutionState(librarySource); |
| 8442 state.recordBuildElementError(); | 8179 state.recordBuildElementError(); |
| 8443 } | 8180 } |
| 8444 | 8181 |
| 8445 /** | |
| 8446 * Record that an in-process model build has stopped without recording results | |
| 8447 * because the results were invalidated before they could be recorded. | |
| 8448 */ | |
| 8449 void recordBuildElementNotInProcess() { | |
| 8450 if (_elementState == CacheState.IN_PROCESS) { | |
| 8451 _elementState = CacheState.INVALID; | |
| 8452 } | |
| 8453 if (_clientServerState == CacheState.IN_PROCESS) { | |
| 8454 _clientServerState = CacheState.INVALID; | |
| 8455 } | |
| 8456 if (_launchableState == CacheState.IN_PROCESS) { | |
| 8457 _launchableState = CacheState.INVALID; | |
| 8458 } | |
| 8459 } | |
| 8460 | |
| 8461 @override | 8182 @override |
| 8462 void recordContentError(CaughtException exception) { | 8183 void recordContentError(CaughtException exception) { |
| 8463 super.recordContentError(exception); | 8184 super.recordContentError(exception); |
| 8464 recordScanError(exception); | 8185 recordScanError(exception); |
| 8465 } | 8186 } |
| 8466 | 8187 |
| 8467 /** | 8188 /** |
| 8468 * Record that an error occurred while attempting to generate hints for the | 8189 * Record that an error occurred while attempting to generate hints for the |
| 8469 * source represented by this entry. This will set the state of all | 8190 * source represented by this entry. This will set the state of all |
| 8470 * verification information as being in error. | 8191 * verification information as being in error. |
| 8471 * | 8192 * |
| 8472 * @param librarySource the source of the library in which hints were being ge
nerated | 8193 * @param librarySource the source of the library in which hints were being ge
nerated |
| 8473 * @param exception the exception that shows where the error occurred | 8194 * @param exception the exception that shows where the error occurred |
| 8474 */ | 8195 */ |
| 8475 void recordHintErrorInLibrary(Source librarySource, CaughtException exception)
{ | 8196 void recordHintErrorInLibrary(Source librarySource, CaughtException exception)
{ |
| 8476 this.exception = exception; | 8197 this.exception = exception; |
| 8477 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8198 ResolutionState state = _getOrCreateResolutionState(librarySource); |
| 8478 state.recordHintError(); | 8199 state.recordHintError(); |
| 8479 } | 8200 } |
| 8480 | 8201 |
| 8481 /** | 8202 /** |
| 8482 * Record that an [exception] occurred while attempting to scan or parse the | 8203 * Record that an [exception] occurred while attempting to scan or parse the |
| 8483 * entry represented by this entry. This will set the state of all information
, | 8204 * entry represented by this entry. This will set the state of all information
, |
| 8484 * including any resolution-based information, as being in error. | 8205 * including any resolution-based information, as being in error. |
| 8485 */ | 8206 */ |
| 8486 void recordParseError(CaughtException exception) { | 8207 void recordParseError(CaughtException exception) { |
| 8487 _sourceKind = SourceKind.UNKNOWN; | 8208 setState(SOURCE_KIND, CacheState.ERROR); |
| 8488 _sourceKindState = CacheState.ERROR; | 8209 setState(PARSE_ERRORS, CacheState.ERROR); |
| 8489 _parseErrors = AnalysisError.NO_ERRORS; | 8210 setState(PARSED_UNIT, CacheState.ERROR); |
| 8490 _parseErrorsState = CacheState.ERROR; | 8211 setState(EXPORTED_LIBRARIES, CacheState.ERROR); |
| 8491 _parsedUnit = null; | 8212 setState(IMPORTED_LIBRARIES, CacheState.ERROR); |
| 8492 _parsedUnitAccessed = false; | 8213 setState(INCLUDED_PARTS, CacheState.ERROR); |
| 8493 _parsedUnitState = CacheState.ERROR; | |
| 8494 _exportedLibraries = Source.EMPTY_ARRAY; | |
| 8495 _exportedLibrariesState = CacheState.ERROR; | |
| 8496 _importedLibraries = Source.EMPTY_ARRAY; | |
| 8497 _importedLibrariesState = CacheState.ERROR; | |
| 8498 _includedParts = Source.EMPTY_ARRAY; | |
| 8499 _includedPartsState = CacheState.ERROR; | |
| 8500 recordResolutionError(exception); | 8214 recordResolutionError(exception); |
| 8501 } | 8215 } |
| 8502 | 8216 |
| 8503 /** | 8217 /** |
| 8504 * Record that the parse-related information for the associated source is | |
| 8505 * about to be computed by the current thread. | |
| 8506 */ | |
| 8507 void recordParseInProcess() { | |
| 8508 if (_sourceKindState != CacheState.VALID) { | |
| 8509 _sourceKindState = CacheState.IN_PROCESS; | |
| 8510 } | |
| 8511 if (_parseErrorsState != CacheState.VALID) { | |
| 8512 _parseErrorsState = CacheState.IN_PROCESS; | |
| 8513 } | |
| 8514 if (_parsedUnitState != CacheState.VALID) { | |
| 8515 _parsedUnitState = CacheState.IN_PROCESS; | |
| 8516 } | |
| 8517 if (_exportedLibrariesState != CacheState.VALID) { | |
| 8518 _exportedLibrariesState = CacheState.IN_PROCESS; | |
| 8519 } | |
| 8520 if (_importedLibrariesState != CacheState.VALID) { | |
| 8521 _importedLibrariesState = CacheState.IN_PROCESS; | |
| 8522 } | |
| 8523 if (_includedPartsState != CacheState.VALID) { | |
| 8524 _includedPartsState = CacheState.IN_PROCESS; | |
| 8525 } | |
| 8526 } | |
| 8527 | |
| 8528 /** | |
| 8529 * Record that an in-process parse has stopped without recording results | |
| 8530 * because the results were invalidated before they could be recorded. | |
| 8531 */ | |
| 8532 void recordParseNotInProcess() { | |
| 8533 if (getState(SourceEntry.LINE_INFO) == CacheState.IN_PROCESS) { | |
| 8534 setState(SourceEntry.LINE_INFO, CacheState.INVALID); | |
| 8535 } | |
| 8536 if (_sourceKindState == CacheState.IN_PROCESS) { | |
| 8537 _sourceKindState = CacheState.INVALID; | |
| 8538 } | |
| 8539 if (_parseErrorsState == CacheState.IN_PROCESS) { | |
| 8540 _parseErrorsState = CacheState.INVALID; | |
| 8541 } | |
| 8542 if (_parsedUnitState == CacheState.IN_PROCESS) { | |
| 8543 _parsedUnitState = CacheState.INVALID; | |
| 8544 } | |
| 8545 if (_exportedLibrariesState == CacheState.IN_PROCESS) { | |
| 8546 _exportedLibrariesState = CacheState.INVALID; | |
| 8547 } | |
| 8548 if (_importedLibrariesState == CacheState.IN_PROCESS) { | |
| 8549 _importedLibrariesState = CacheState.INVALID; | |
| 8550 } | |
| 8551 if (_includedPartsState == CacheState.IN_PROCESS) { | |
| 8552 _includedPartsState = CacheState.INVALID; | |
| 8553 } | |
| 8554 } | |
| 8555 | |
| 8556 /** | |
| 8557 * Record that an [exception] occurred while attempting to resolve the source | 8218 * Record that an [exception] occurred while attempting to resolve the source |
| 8558 * represented by this entry. This will set the state of all resolution-based | 8219 * represented by this entry. This will set the state of all resolution-based |
| 8559 * information as being in error, but will not change the state of any parse | 8220 * information as being in error, but will not change the state of any parse |
| 8560 * results. | 8221 * results. |
| 8561 * | 8222 * |
| 8562 * @param exception the exception that shows where the error occurred | 8223 * @param exception the exception that shows where the error occurred |
| 8563 */ | 8224 */ |
| 8564 void recordResolutionError(CaughtException exception) { | 8225 void recordResolutionError(CaughtException exception) { |
| 8565 this.exception = exception; | 8226 this.exception = exception; |
| 8566 _element = null; | 8227 setState(ELEMENT, CacheState.ERROR); |
| 8567 _elementState = CacheState.ERROR; | 8228 setState(IS_CLIENT, CacheState.ERROR); |
| 8568 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]); | 8229 setState(IS_LAUNCHABLE, CacheState.ERROR); |
| 8569 _clientServerState = CacheState.ERROR; | 8230 setState(PUBLIC_NAMESPACE, CacheState.ERROR); |
| 8570 _launchableState = CacheState.ERROR; | |
| 8571 _publicNamespace = null; | |
| 8572 _publicNamespaceState = CacheState.ERROR; | |
| 8573 _resolutionState.recordResolutionErrorsInAllLibraries(); | 8231 _resolutionState.recordResolutionErrorsInAllLibraries(); |
| 8574 } | 8232 } |
| 8575 | 8233 |
| 8576 /** | 8234 /** |
| 8577 * Record that an error occurred while attempting to resolve the source repres
ented by this entry. | 8235 * Record that an error occurred while attempting to resolve the source repres
ented by this entry. |
| 8578 * This will set the state of all resolution-based information as being in err
or, but will not | 8236 * This will set the state of all resolution-based information as being in err
or, but will not |
| 8579 * change the state of any parse results. | 8237 * change the state of any parse results. |
| 8580 * | 8238 * |
| 8581 * @param librarySource the source of the library in which resolution was bein
g performed | 8239 * @param librarySource the source of the library in which resolution was bein
g performed |
| 8582 * @param exception the exception that shows where the error occurred | 8240 * @param exception the exception that shows where the error occurred |
| 8583 */ | 8241 */ |
| 8584 void recordResolutionErrorInLibrary(Source librarySource, CaughtException exce
ption) { | 8242 void recordResolutionErrorInLibrary(Source librarySource, CaughtException exce
ption) { |
| 8585 this.exception = exception; | 8243 this.exception = exception; |
| 8586 _element = null; | 8244 setState(ELEMENT, CacheState.ERROR); |
| 8587 _elementState = CacheState.ERROR; | 8245 setState(IS_CLIENT, CacheState.ERROR); |
| 8588 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]); | 8246 setState(IS_LAUNCHABLE, CacheState.ERROR); |
| 8589 _clientServerState = CacheState.ERROR; | 8247 setState(PUBLIC_NAMESPACE, CacheState.ERROR); |
| 8590 _launchableState = CacheState.ERROR; | |
| 8591 _publicNamespace = null; | |
| 8592 _publicNamespaceState = CacheState.ERROR; | |
| 8593 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8248 ResolutionState state = _getOrCreateResolutionState(librarySource); |
| 8594 state.recordResolutionError(); | 8249 state.recordResolutionError(); |
| 8595 } | 8250 } |
| 8596 | 8251 |
| 8597 /** | 8252 /** |
| 8598 * Record that an in-process resolution has stopped without recording results
because the results | |
| 8599 * were invalidated before they could be recorded. | |
| 8600 */ | |
| 8601 void recordResolutionNotInProcess() { | |
| 8602 if (_elementState == CacheState.IN_PROCESS) { | |
| 8603 _elementState = CacheState.INVALID; | |
| 8604 } | |
| 8605 if (_clientServerState == CacheState.IN_PROCESS) { | |
| 8606 _clientServerState = CacheState.INVALID; | |
| 8607 } | |
| 8608 if (_launchableState == CacheState.IN_PROCESS) { | |
| 8609 _launchableState = CacheState.INVALID; | |
| 8610 } | |
| 8611 // TODO(brianwilkerson) Remove the code above this line after resolution and
element building | |
| 8612 // are separated. | |
| 8613 if (_publicNamespaceState == CacheState.IN_PROCESS) { | |
| 8614 _publicNamespaceState = CacheState.INVALID; | |
| 8615 } | |
| 8616 _resolutionState.recordResolutionNotInProcess(); | |
| 8617 } | |
| 8618 | |
| 8619 /** | |
| 8620 * Record that an [exception] occurred while attempting to scan or parse the | 8253 * Record that an [exception] occurred while attempting to scan or parse the |
| 8621 * entry represented by this entry. This will set the state of all information
, | 8254 * entry represented by this entry. This will set the state of all information
, |
| 8622 * including any resolution-based information, as being in error. | 8255 * including any resolution-based information, as being in error. |
| 8623 */ | 8256 */ |
| 8624 @override | 8257 @override |
| 8625 void recordScanError(CaughtException exception) { | 8258 void recordScanError(CaughtException exception) { |
| 8626 super.recordScanError(exception); | 8259 super.recordScanError(exception); |
| 8627 _scanErrors = AnalysisError.NO_ERRORS; | 8260 setState(SCAN_ERRORS, CacheState.ERROR); |
| 8628 _scanErrorsState = CacheState.ERROR; | 8261 setState(TOKEN_STREAM, CacheState.ERROR); |
| 8629 _tokenStream = null; | |
| 8630 _tokenStreamState = CacheState.ERROR; | |
| 8631 recordParseError(exception); | 8262 recordParseError(exception); |
| 8632 } | 8263 } |
| 8633 | 8264 |
| 8634 /** | 8265 /** |
| 8635 * Record that the scan-related information for the associated source is about | |
| 8636 * to be computed by the current thread. | |
| 8637 */ | |
| 8638 void recordScanInProcess() { | |
| 8639 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { | |
| 8640 setState(SourceEntry.LINE_INFO, CacheState.IN_PROCESS); | |
| 8641 } | |
| 8642 if (_scanErrorsState != CacheState.VALID) { | |
| 8643 _scanErrorsState = CacheState.IN_PROCESS; | |
| 8644 } | |
| 8645 if (_tokenStreamState != CacheState.VALID) { | |
| 8646 _tokenStreamState = CacheState.IN_PROCESS; | |
| 8647 } | |
| 8648 } | |
| 8649 | |
| 8650 /** | |
| 8651 * Record that an in-process scan has stopped without recording results | |
| 8652 * because the results were invalidated before they could be recorded. | |
| 8653 */ | |
| 8654 void recordScanNotInProcess() { | |
| 8655 if (getState(SourceEntry.LINE_INFO) == CacheState.IN_PROCESS) { | |
| 8656 setState(SourceEntry.LINE_INFO, CacheState.INVALID); | |
| 8657 } | |
| 8658 if (_scanErrorsState == CacheState.IN_PROCESS) { | |
| 8659 _scanErrorsState = CacheState.INVALID; | |
| 8660 } | |
| 8661 if (_tokenStreamState == CacheState.IN_PROCESS) { | |
| 8662 _tokenStreamState = CacheState.INVALID; | |
| 8663 } | |
| 8664 } | |
| 8665 | |
| 8666 /** | |
| 8667 * Record that an [exception] occurred while attempting to generate errors and | 8266 * Record that an [exception] occurred while attempting to generate errors and |
| 8668 * warnings for the source represented by this entry. This will set the state | 8267 * warnings for the source represented by this entry. This will set the state |
| 8669 * of all verification information as being in error. | 8268 * of all verification information as being in error. |
| 8670 * | 8269 * |
| 8671 * @param librarySource the source of the library in which verification was be
ing performed | 8270 * @param librarySource the source of the library in which verification was be
ing performed |
| 8672 * @param exception the exception that shows where the error occurred | 8271 * @param exception the exception that shows where the error occurred |
| 8673 */ | 8272 */ |
| 8674 void recordVerificationErrorInLibrary(Source librarySource, CaughtException ex
ception) { | 8273 void recordVerificationErrorInLibrary(Source librarySource, CaughtException ex
ception) { |
| 8675 this.exception = exception; | 8274 this.exception = exception; |
| 8676 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8275 ResolutionState state = _getOrCreateResolutionState(librarySource); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8720 * only the given source. This method should only be invoked on entries that | 8319 * only the given source. This method should only be invoked on entries that |
| 8721 * represent a library. | 8320 * represent a library. |
| 8722 * | 8321 * |
| 8723 * @param librarySource the source of the single library that the list should
contain | 8322 * @param librarySource the source of the single library that the list should
contain |
| 8724 */ | 8323 */ |
| 8725 void set containingLibrary(Source librarySource) { | 8324 void set containingLibrary(Source librarySource) { |
| 8726 _containingLibraries.clear(); | 8325 _containingLibraries.clear(); |
| 8727 _containingLibraries.add(librarySource); | 8326 _containingLibraries.add(librarySource); |
| 8728 } | 8327 } |
| 8729 | 8328 |
| 8730 @override | |
| 8731 void setState(DataDescriptor descriptor, CacheState state) { | |
| 8732 if (identical(descriptor, DartEntry.ELEMENT)) { | |
| 8733 _element = updatedValue(state, _element, null); | |
| 8734 _elementState = state; | |
| 8735 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | |
| 8736 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_
ARRAY); | |
| 8737 _exportedLibrariesState = state; | |
| 8738 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | |
| 8739 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_
ARRAY); | |
| 8740 _importedLibrariesState = state; | |
| 8741 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | |
| 8742 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); | |
| 8743 _includedPartsState = state; | |
| 8744 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | |
| 8745 _updateValueOfFlag(_CLIENT_CODE_INDEX, state); | |
| 8746 _clientServerState = state; | |
| 8747 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | |
| 8748 _updateValueOfFlag(_LAUNCHABLE_INDEX, state); | |
| 8749 _launchableState = state; | |
| 8750 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | |
| 8751 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); | |
| 8752 _parseErrorsState = state; | |
| 8753 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | |
| 8754 CompilationUnit newUnit = updatedValue(state, _parsedUnit, null); | |
| 8755 if (!identical(newUnit, _parsedUnit)) { | |
| 8756 _parsedUnitAccessed = false; | |
| 8757 } | |
| 8758 _parsedUnit = newUnit; | |
| 8759 _parsedUnitState = state; | |
| 8760 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | |
| 8761 _publicNamespace = updatedValue(state, _publicNamespace, null); | |
| 8762 _publicNamespaceState = state; | |
| 8763 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { | |
| 8764 _scanErrors = updatedValue(state, _scanErrors, AnalysisError.NO_ERRORS); | |
| 8765 _scanErrorsState = state; | |
| 8766 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | |
| 8767 _sourceKind = updatedValue(state, _sourceKind, SourceKind.UNKNOWN); | |
| 8768 _sourceKindState = state; | |
| 8769 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { | |
| 8770 _tokenStream = updatedValue(state, _tokenStream, null); | |
| 8771 _tokenStreamState = state; | |
| 8772 } else { | |
| 8773 super.setState(descriptor, state); | |
| 8774 } | |
| 8775 } | |
| 8776 | |
| 8777 /** | 8329 /** |
| 8778 * Set the state of the data represented by the given descriptor in the contex
t of the given | 8330 * Set the state of the data represented by the given descriptor in the contex
t of the given |
| 8779 * library to the given state. | 8331 * library to the given state. |
| 8780 * | 8332 * |
| 8781 * @param descriptor the descriptor representing the data whose state is to be
set | 8333 * @param descriptor the descriptor representing the data whose state is to be
set |
| 8782 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 8334 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 8783 * context for the data | 8335 * context for the data |
| 8784 * @param cacheState the new state of the data represented by the given descri
ptor | 8336 * @param cacheState the new state of the data represented by the given descri
ptor |
| 8785 */ | 8337 */ |
| 8786 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS
tate cacheState) { | 8338 void setStateInLibrary(DataDescriptor descriptor, Source librarySource, CacheS
tate cacheState) { |
| 8339 if (!_isValidLibraryDescriptor(descriptor)) { |
| 8340 throw new ArgumentError("Invalid descriptor: $descriptor"); |
| 8341 } |
| 8787 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8342 ResolutionState state = _getOrCreateResolutionState(librarySource); |
| 8788 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 8343 state.setState(descriptor, cacheState); |
| 8789 state._resolutionErrors = updatedValue(cacheState, state._resolutionErrors
, AnalysisError.NO_ERRORS); | |
| 8790 state._resolutionErrorsState = cacheState; | |
| 8791 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | |
| 8792 state._resolvedUnit = updatedValue(cacheState, state._resolvedUnit, null); | |
| 8793 state._resolvedUnitState = cacheState; | |
| 8794 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { | |
| 8795 state._verificationErrors = updatedValue(cacheState, state._verificationEr
rors, AnalysisError.NO_ERRORS); | |
| 8796 state._verificationErrorsState = cacheState; | |
| 8797 } else if (identical(descriptor, DartEntry.HINTS)) { | |
| 8798 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR
ORS); | |
| 8799 state._hintsState = cacheState; | |
| 8800 } else { | |
| 8801 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | |
| 8802 } | |
| 8803 } | |
| 8804 | |
| 8805 @override | |
| 8806 void setValue(DataDescriptor descriptor, Object value) { | |
| 8807 if (identical(descriptor, DartEntry.ANGULAR_ERRORS)) { | |
| 8808 _angularErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<
AnalysisError>); | |
| 8809 } else if (identical(descriptor, DartEntry.ELEMENT)) { | |
| 8810 _element = value as LibraryElement; | |
| 8811 _elementState = CacheState.VALID; | |
| 8812 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | |
| 8813 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); | |
| 8814 _exportedLibrariesState = CacheState.VALID; | |
| 8815 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | |
| 8816 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); | |
| 8817 _importedLibrariesState = CacheState.VALID; | |
| 8818 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | |
| 8819 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); | |
| 8820 _includedPartsState = CacheState.VALID; | |
| 8821 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | |
| 8822 setFlag(_CLIENT_CODE_INDEX, value as bool); | |
| 8823 _clientServerState = CacheState.VALID; | |
| 8824 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | |
| 8825 setFlag(_LAUNCHABLE_INDEX, value as bool); | |
| 8826 _launchableState = CacheState.VALID; | |
| 8827 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | |
| 8828 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); | |
| 8829 _parseErrorsState = CacheState.VALID; | |
| 8830 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | |
| 8831 _parsedUnit = value as CompilationUnit; | |
| 8832 _parsedUnitAccessed = false; | |
| 8833 _parsedUnitState = CacheState.VALID; | |
| 8834 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | |
| 8835 _publicNamespace = value as Namespace; | |
| 8836 _publicNamespaceState = CacheState.VALID; | |
| 8837 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { | |
| 8838 _scanErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<Ana
lysisError>); | |
| 8839 _scanErrorsState = CacheState.VALID; | |
| 8840 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | |
| 8841 _sourceKind = value as SourceKind; | |
| 8842 _sourceKindState = CacheState.VALID; | |
| 8843 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { | |
| 8844 _tokenStream = value as Token; | |
| 8845 _tokenStreamState = CacheState.VALID; | |
| 8846 } else { | |
| 8847 super.setValue(descriptor, value); | |
| 8848 } | |
| 8849 } | 8344 } |
| 8850 | 8345 |
| 8851 /** | 8346 /** |
| 8852 * Set the value of the data represented by the given descriptor in the contex
t of the given | 8347 * Set the value of the data represented by the given descriptor in the contex
t of the given |
| 8853 * library to the given value, and set the state of that data to [CacheState.V
ALID]. | 8348 * library to the given value, and set the state of that data to [CacheState.V
ALID]. |
| 8854 * | 8349 * |
| 8855 * @param descriptor the descriptor representing which data is to have its val
ue set | 8350 * @param descriptor the descriptor representing which data is to have its val
ue set |
| 8856 * @param librarySource the source of the defining compilation unit of the lib
rary that is the | 8351 * @param librarySource the source of the defining compilation unit of the lib
rary that is the |
| 8857 * context for the data | 8352 * context for the data |
| 8858 * @param value the new value of the data represented by the given descriptor
and library | 8353 * @param value the new value of the data represented by the given descriptor
and library |
| 8859 */ | 8354 */ |
| 8860 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object
value) { | 8355 void setValueInLibrary(DataDescriptor descriptor, Source librarySource, Object
value) { |
| 8356 if (!_isValidLibraryDescriptor(descriptor)) { |
| 8357 throw new ArgumentError("Invalid descriptor: $descriptor"); |
| 8358 } |
| 8861 ResolutionState state = _getOrCreateResolutionState(librarySource); | 8359 ResolutionState state = _getOrCreateResolutionState(librarySource); |
| 8862 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 8360 state.setValue(descriptor, value); |
| 8863 state._resolutionErrors = value == null ? AnalysisError.NO_ERRORS : (value
as List<AnalysisError>); | |
| 8864 state._resolutionErrorsState = CacheState.VALID; | |
| 8865 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | |
| 8866 state._resolvedUnit = value as CompilationUnit; | |
| 8867 state._resolvedUnitState = CacheState.VALID; | |
| 8868 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { | |
| 8869 state._verificationErrors = value == null ? AnalysisError.NO_ERRORS : (val
ue as List<AnalysisError>); | |
| 8870 state._verificationErrorsState = CacheState.VALID; | |
| 8871 } else if (identical(descriptor, DartEntry.HINTS)) { | |
| 8872 state._hints = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); | |
| 8873 state._hintsState = CacheState.VALID; | |
| 8874 } | |
| 8875 } | 8361 } |
| 8876 | 8362 |
| 8877 @override | 8363 @override |
| 8878 bool get hasErrorState => super.hasErrorState || _scanErrorsState == CacheStat
e.ERROR || _tokenStreamState == CacheState.ERROR || _sourceKindState == CacheSta
te.ERROR || _parsedUnitState == CacheState.ERROR || _parseErrorsState == CacheSt
ate.ERROR || _importedLibrariesState == CacheState.ERROR || _exportedLibrariesSt
ate == CacheState.ERROR || _includedPartsState == CacheState.ERROR || _elementSt
ate == CacheState.ERROR || _publicNamespaceState == CacheState.ERROR || _clientS
erverState == CacheState.ERROR || _launchableState == CacheState.ERROR || _resol
utionState.hasErrorState; | 8364 bool _writeDiffOn(StringBuffer buffer, SourceEntry oldEntry) { |
| 8879 | 8365 bool needsSeparator = super._writeDiffOn(buffer, oldEntry); |
| 8880 @override | |
| 8881 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) { | |
| 8882 bool needsSeparator = super.writeDiffOn(builder, oldEntry); | |
| 8883 if (oldEntry is! DartEntry) { | 8366 if (oldEntry is! DartEntry) { |
| 8884 if (needsSeparator) { | 8367 if (needsSeparator) { |
| 8885 builder.append("; "); | 8368 buffer.write("; "); |
| 8886 } | 8369 } |
| 8887 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()}
"); | 8370 buffer.write("entry type changed; was "); |
| 8371 buffer.write(oldEntry.runtimeType.toString()); |
| 8888 return true; | 8372 return true; |
| 8889 } | 8373 } |
| 8890 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.TOKEN_STREAM, "tokenStream"); | 8374 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "tokenStream", Da
rtEntry.TOKEN_STREAM, oldEntry); |
| 8891 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.SCAN_ERRORS, "scanErrors"); | 8375 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "scanErrors", Dar
tEntry.SCAN_ERRORS, oldEntry); |
| 8892 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.SOURCE_KIND, "sourceKind"); | 8376 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "sourceKind", Dar
tEntry.SOURCE_KIND, oldEntry); |
| 8893 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.PARSED_UNIT, "parsedUnit"); | 8377 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "parsedUnit", Dar
tEntry.PARSED_UNIT, oldEntry); |
| 8894 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.PARSE_ERRORS, "parseErrors"); | 8378 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "parseErrors", Da
rtEntry.PARSE_ERRORS, oldEntry); |
| 8895 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.IMPORTED_LIBRARIES, "importedLibraries"); | 8379 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "importedLibrarie
s", DartEntry.IMPORTED_LIBRARIES, oldEntry); |
| 8896 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.EXPORTED_LIBRARIES, "exportedLibraries"); | 8380 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "exportedLibrarie
s", DartEntry.EXPORTED_LIBRARIES, oldEntry); |
| 8897 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.INCLUDED_PARTS, "includedParts"); | 8381 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "includedParts",
DartEntry.INCLUDED_PARTS, oldEntry); |
| 8898 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.ELEMENT, "element"); | 8382 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "element", DartEn
try.ELEMENT, oldEntry); |
| 8899 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.PUBLIC_NAMESPACE, "publicNamespace"); | 8383 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "publicNamespace"
, DartEntry.PUBLIC_NAMESPACE, oldEntry); |
| 8900 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.IS_CLIENT, "clientServer"); | 8384 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "clientServer", D
artEntry.IS_CLIENT, oldEntry); |
| 8901 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.IS_LAUNCHABLE, "launchable"); | 8385 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "launchable", Dar
tEntry.IS_LAUNCHABLE, oldEntry); |
| 8902 // TODO(brianwilkerson) Add better support for containingLibraries. It would
be nice to be able | 8386 // TODO(brianwilkerson) Add better support for containingLibraries. It would
be nice to be able |
| 8903 // to report on size-preserving changes. | 8387 // to report on size-preserving changes. |
| 8904 int oldLibraryCount = (oldEntry as DartEntry)._containingLibraries.length; | 8388 int oldLibraryCount = (oldEntry as DartEntry)._containingLibraries.length; |
| 8905 int libraryCount = _containingLibraries.length; | 8389 int libraryCount = _containingLibraries.length; |
| 8906 if (oldLibraryCount != libraryCount) { | 8390 if (oldLibraryCount != libraryCount) { |
| 8907 if (needsSeparator) { | 8391 if (needsSeparator) { |
| 8908 builder.append("; "); | 8392 buffer.write("; "); |
| 8909 } | 8393 } |
| 8910 builder.append("containingLibraryCount = "); | 8394 buffer.write("containingLibraryCount = "); |
| 8911 builder.append(oldLibraryCount); | 8395 buffer.write(oldLibraryCount); |
| 8912 builder.append(" -> "); | 8396 buffer.write(" -> "); |
| 8913 builder.append(libraryCount); | 8397 buffer.write(libraryCount); |
| 8914 needsSeparator = true; | 8398 needsSeparator = true; |
| 8915 } | 8399 } |
| 8916 // | 8400 // |
| 8917 // Report change to the per-library state. | 8401 // Report change to the per-library state. |
| 8918 // | 8402 // |
| 8919 HashMap<Source, ResolutionState> oldStateMap = new HashMap<Source, Resolutio
nState>(); | 8403 HashMap<Source, ResolutionState> oldStateMap = new HashMap<Source, Resolutio
nState>(); |
| 8920 ResolutionState state = (oldEntry as DartEntry)._resolutionState; | 8404 ResolutionState state = (oldEntry as DartEntry)._resolutionState; |
| 8921 while (state != null) { | 8405 while (state != null) { |
| 8922 Source librarySource = state._librarySource; | 8406 Source librarySource = state._librarySource; |
| 8923 if (librarySource != null) { | 8407 if (librarySource != null) { |
| 8924 oldStateMap[librarySource] = state; | 8408 oldStateMap[librarySource] = state; |
| 8925 } | 8409 } |
| 8926 state = state._nextState; | 8410 state = state._nextState; |
| 8927 } | 8411 } |
| 8928 state = _resolutionState; | 8412 state = _resolutionState; |
| 8929 while (state != null) { | 8413 while (state != null) { |
| 8930 Source librarySource = state._librarySource; | 8414 Source librarySource = state._librarySource; |
| 8931 if (librarySource != null) { | 8415 if (librarySource != null) { |
| 8932 ResolutionState oldState = oldStateMap.remove(librarySource); | 8416 ResolutionState oldState = oldStateMap.remove(librarySource); |
| 8933 if (oldState == null) { | 8417 if (oldState == null) { |
| 8934 if (needsSeparator) { | 8418 if (needsSeparator) { |
| 8935 builder.append("; "); | 8419 buffer.write("; "); |
| 8936 } | 8420 } |
| 8937 builder.append("added resolution for "); | 8421 buffer.write("added resolution for "); |
| 8938 builder.append(librarySource.fullName); | 8422 buffer.write(librarySource.fullName); |
| 8939 needsSeparator = true; | 8423 needsSeparator = true; |
| 8940 } else { | 8424 } else { |
| 8941 needsSeparator = oldState.writeDiffOn(builder, needsSeparator, oldEntr
y as DartEntry); | 8425 needsSeparator = oldState._writeDiffOn(buffer, needsSeparator, oldEntr
y as DartEntry); |
| 8942 } | 8426 } |
| 8943 } | 8427 } |
| 8944 state = state._nextState; | 8428 state = state._nextState; |
| 8945 } | 8429 } |
| 8946 for (Source librarySource in oldStateMap.keys.toSet()) { | 8430 for (Source librarySource in oldStateMap.keys.toSet()) { |
| 8947 if (needsSeparator) { | 8431 if (needsSeparator) { |
| 8948 builder.append("; "); | 8432 buffer.write("; "); |
| 8949 } | 8433 } |
| 8950 builder.append("removed resolution for "); | 8434 buffer.write("removed resolution for "); |
| 8951 builder.append(librarySource.fullName); | 8435 buffer.write(librarySource.fullName); |
| 8952 needsSeparator = true; | 8436 needsSeparator = true; |
| 8953 } | 8437 } |
| 8954 return needsSeparator; | 8438 return needsSeparator; |
| 8955 } | 8439 } |
| 8956 | 8440 |
| 8957 @override | 8441 @override |
| 8958 void writeOn(JavaStringBuilder builder) { | 8442 void _writeOn(StringBuffer buffer) { |
| 8959 builder.append("Dart: "); | 8443 buffer.write("Dart: "); |
| 8960 super.writeOn(builder); | 8444 super._writeOn(buffer); |
| 8961 builder.append("; tokenStream = "); | 8445 _writeStateOn(buffer, "tokenStream", TOKEN_STREAM); |
| 8962 builder.append(_tokenStreamState); | 8446 _writeStateOn(buffer, "scanErrors", SCAN_ERRORS); |
| 8963 builder.append("; scanErrors = "); | 8447 _writeStateOn(buffer, "sourceKind", SOURCE_KIND); |
| 8964 builder.append(_scanErrorsState); | 8448 _writeStateOn(buffer, "parsedUnit", PARSED_UNIT); |
| 8965 builder.append("; sourceKind = "); | 8449 _writeStateOn(buffer, "parseErrors", PARSE_ERRORS); |
| 8966 builder.append(_sourceKindState); | 8450 _writeStateOn(buffer, "exportedLibraries", EXPORTED_LIBRARIES); |
| 8967 builder.append("; parsedUnit = "); | 8451 _writeStateOn(buffer, "importedLibraries", IMPORTED_LIBRARIES); |
| 8968 builder.append(_parsedUnitState); | 8452 _writeStateOn(buffer, "includedParts", INCLUDED_PARTS); |
| 8969 builder.append(" ("); | 8453 _writeStateOn(buffer, "element", ELEMENT); |
| 8970 builder.append(_parsedUnitAccessed ? "T" : "F"); | 8454 _writeStateOn(buffer, "publicNamespace", PUBLIC_NAMESPACE); |
| 8971 builder.append("); parseErrors = "); | 8455 _writeStateOn(buffer, "clientServer", IS_CLIENT); |
| 8972 builder.append(_parseErrorsState); | 8456 _writeStateOn(buffer, "launchable", IS_LAUNCHABLE); |
| 8973 builder.append("; exportedLibraries = "); | 8457 _writeStateOn(buffer, "angularErrors", ANGULAR_ERRORS); |
| 8974 builder.append(_exportedLibrariesState); | 8458 _resolutionState._writeOn(buffer); |
| 8975 builder.append("; importedLibraries = "); | |
| 8976 builder.append(_importedLibrariesState); | |
| 8977 builder.append("; includedParts = "); | |
| 8978 builder.append(_includedPartsState); | |
| 8979 builder.append("; element = "); | |
| 8980 builder.append(_elementState); | |
| 8981 builder.append("; publicNamespace = "); | |
| 8982 builder.append(_publicNamespaceState); | |
| 8983 builder.append("; clientServer = "); | |
| 8984 builder.append(_clientServerState); | |
| 8985 builder.append("; launchable = "); | |
| 8986 builder.append(_launchableState); | |
| 8987 // builder.append("; angularElements = "); | |
| 8988 _resolutionState.writeOn(builder); | |
| 8989 } | 8459 } |
| 8990 | 8460 |
| 8991 /** | 8461 /** |
| 8992 * Invalidate all of the resolution information associated with the compilatio
n unit. | 8462 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 8993 * | 8463 * |
| 8994 * @param invalidateUris true if the cached results of converting URIs to sour
ce files should also | 8464 * @param invalidateUris true if the cached results of converting URIs to sour
ce files should also |
| 8995 * be invalidated. | 8465 * be invalidated. |
| 8996 */ | 8466 */ |
| 8997 void _discardCachedResolutionInformation(bool invalidateUris) { | 8467 void _discardCachedResolutionInformation(bool invalidateUris) { |
| 8998 _element = null; | 8468 setState(ELEMENT, CacheState.INVALID); |
| 8999 _elementState = CacheState.INVALID; | 8469 setState(IS_CLIENT, CacheState.INVALID); |
| 9000 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]); | 8470 setState(IS_LAUNCHABLE, CacheState.INVALID); |
| 9001 _clientServerState = CacheState.INVALID; | 8471 setState(PUBLIC_NAMESPACE, CacheState.INVALID); |
| 9002 _launchableState = CacheState.INVALID; | |
| 9003 _publicNamespace = null; | |
| 9004 _publicNamespaceState = CacheState.INVALID; | |
| 9005 _resolutionState.invalidateAllResolutionInformation(); | 8472 _resolutionState.invalidateAllResolutionInformation(); |
| 9006 if (invalidateUris) { | 8473 if (invalidateUris) { |
| 9007 _importedLibraries = Source.EMPTY_ARRAY; | 8474 setState(EXPORTED_LIBRARIES, CacheState.INVALID); |
| 9008 _importedLibrariesState = CacheState.INVALID; | 8475 setState(IMPORTED_LIBRARIES, CacheState.INVALID); |
| 9009 _exportedLibraries = Source.EMPTY_ARRAY; | 8476 setState(INCLUDED_PARTS, CacheState.INVALID); |
| 9010 _exportedLibrariesState = CacheState.INVALID; | |
| 9011 _includedParts = Source.EMPTY_ARRAY; | |
| 9012 _includedPartsState = CacheState.INVALID; | |
| 9013 } | 8477 } |
| 9014 } | 8478 } |
| 9015 | 8479 |
| 9016 /** | 8480 /** |
| 9017 * Return a resolution state for the specified library, creating one as necess
ary. | 8481 * Return a resolution state for the specified library, creating one as necess
ary. |
| 9018 * | 8482 * |
| 9019 * @param librarySource the library source (not `null`) | 8483 * @param librarySource the library source (not `null`) |
| 9020 * @return the resolution state (not `null`) | 8484 * @return the resolution state (not `null`) |
| 9021 */ | 8485 */ |
| 9022 ResolutionState _getOrCreateResolutionState(Source librarySource) { | 8486 ResolutionState _getOrCreateResolutionState(Source librarySource) { |
| 9023 ResolutionState state = _resolutionState; | 8487 ResolutionState state = _resolutionState; |
| 9024 if (state._librarySource == null) { | 8488 if (state._librarySource == null) { |
| 9025 state._librarySource = librarySource; | 8489 state._librarySource = librarySource; |
| 9026 return state; | 8490 return state; |
| 9027 } | 8491 } |
| 9028 while (state._librarySource != librarySource) { | 8492 while (state._librarySource != librarySource) { |
| 9029 if (state._nextState == null) { | 8493 if (state._nextState == null) { |
| 9030 ResolutionState newState = new ResolutionState(); | 8494 ResolutionState newState = new ResolutionState(); |
| 9031 newState._librarySource = librarySource; | 8495 newState._librarySource = librarySource; |
| 9032 state._nextState = newState; | 8496 state._nextState = newState; |
| 9033 return newState; | 8497 return newState; |
| 9034 } | 8498 } |
| 9035 state = state._nextState; | 8499 state = state._nextState; |
| 9036 } | 8500 } |
| 9037 return state; | 8501 return state; |
| 9038 } | 8502 } |
| 9039 | 8503 |
| 8504 @override |
| 8505 bool _isValidDescriptor(DataDescriptor descriptor) { |
| 8506 return descriptor == ANGULAR_ERRORS |
| 8507 || descriptor == CONTAINING_LIBRARIES |
| 8508 || descriptor == ELEMENT |
| 8509 || descriptor == EXPORTED_LIBRARIES |
| 8510 || descriptor == IMPORTED_LIBRARIES |
| 8511 || descriptor == INCLUDED_PARTS |
| 8512 || descriptor == IS_CLIENT |
| 8513 || descriptor == IS_LAUNCHABLE |
| 8514 || descriptor == PARSED_UNIT |
| 8515 || descriptor == PARSE_ERRORS |
| 8516 || descriptor == PUBLIC_NAMESPACE |
| 8517 || descriptor == SCAN_ERRORS |
| 8518 || descriptor == SOURCE_KIND |
| 8519 || descriptor == TOKEN_STREAM |
| 8520 || super._isValidDescriptor(descriptor); |
| 8521 } |
| 8522 |
| 8523 /** |
| 8524 * Return `true` if the [descriptor] is valid for this entry when the data is |
| 8525 * relative to a library. |
| 8526 */ |
| 8527 bool _isValidLibraryDescriptor(DataDescriptor descriptor) { |
| 8528 return descriptor == BUILD_ELEMENT_ERRORS |
| 8529 || descriptor == BUILT_UNIT |
| 8530 || descriptor == HINTS |
| 8531 || descriptor == RESOLUTION_ERRORS |
| 8532 || descriptor == RESOLVED_UNIT |
| 8533 || descriptor == VERIFICATION_ERRORS; |
| 8534 } |
| 8535 |
| 9040 /** | 8536 /** |
| 9041 * Given that the specified flag is being transitioned to the given state, set
the value of the | 8537 * Given that the specified flag is being transitioned to the given state, set
the value of the |
| 9042 * flag to the value that should be kept in the cache. | 8538 * flag to the value that should be kept in the cache. |
| 9043 * | 8539 * |
| 9044 * @param index the index of the flag whose state is being set | 8540 * @param index the index of the flag whose state is being set |
| 9045 * @param state the state to which the value is being transitioned | 8541 * @param state the state to which the value is being transitioned |
| 9046 */ | 8542 */ |
| 9047 void _updateValueOfFlag(int index, CacheState state) { | 8543 void _updateValueOfFlag(int index, CacheState state) { |
| 9048 if (state == CacheState.VALID) { | 8544 if (state == CacheState.VALID) { |
| 9049 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 8545 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 9050 } else if (state != CacheState.IN_PROCESS) { | 8546 } else if (state != CacheState.IN_PROCESS) { |
| 9051 // | 8547 // |
| 9052 // If the value is in process, we can leave the current value in the cache
for any 'get' | 8548 // If the value is in process, we can leave the current value in the cache
for any 'get' |
| 9053 // methods to access. | 8549 // methods to access. |
| 9054 // | 8550 // |
| 9055 setFlag(index, false); | 8551 _setFlag(index, false); |
| 9056 } | 8552 } |
| 9057 } | 8553 } |
| 9058 } | 8554 } |
| 9059 | 8555 |
| 9060 /** | 8556 /** |
| 9061 * Instances of the class `DataDescriptor` are immutable constants representing
data that can | 8557 * Instances of the class `DataDescriptor` are immutable constants representing
data that can |
| 9062 * be stored in the cache. | 8558 * be stored in the cache. |
| 9063 */ | 8559 */ |
| 9064 class DataDescriptor<E> { | 8560 class DataDescriptor<E> { |
| 9065 /** | 8561 /** |
| 9066 * The name of the descriptor, used for debugging purposes. | 8562 * The name of the descriptor, used for debugging purposes. |
| 9067 */ | 8563 */ |
| 9068 final String _name; | 8564 final String _name; |
| 9069 | 8565 |
| 9070 /** | 8566 /** |
| 9071 * Initialize a newly created descriptor to have the given name. | 8567 * The default value used when the data does not exist. |
| 9072 * | |
| 9073 * @param name the name of the descriptor | |
| 9074 */ | 8568 */ |
| 9075 DataDescriptor(this._name); | 8569 final E defaultValue; |
| 8570 |
| 8571 /** |
| 8572 * Initialize a newly created descriptor to have the given [name] and |
| 8573 * [defaultValue]. |
| 8574 */ |
| 8575 DataDescriptor(this._name, [this.defaultValue = null]); |
| 9076 | 8576 |
| 9077 @override | 8577 @override |
| 9078 String toString() => _name; | 8578 String toString() => _name; |
| 9079 } | 8579 } |
| 9080 | 8580 |
| 9081 /** | 8581 /** |
| 9082 * Instances of the class `DefaultRetentionPolicy` implement a retention policy
that will keep | 8582 * Instances of the class `DefaultRetentionPolicy` implement a retention policy
that will keep |
| 9083 * AST's in the cache if there is analysis information that needs to be computed
for a source, where | 8583 * AST's in the cache if there is analysis information that needs to be computed
for a source, where |
| 9084 * the computation is dependent on having the AST. | 8584 * the computation is dependent on having the AST. |
| 9085 */ | 8585 */ |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9434 } | 8934 } |
| 9435 } | 8935 } |
| 9436 } | 8936 } |
| 9437 | 8937 |
| 9438 /** | 8938 /** |
| 9439 * An `HtmlEntry` maintains the information cached by an analysis context about | 8939 * An `HtmlEntry` maintains the information cached by an analysis context about |
| 9440 * an individual HTML file. | 8940 * an individual HTML file. |
| 9441 */ | 8941 */ |
| 9442 class HtmlEntry extends SourceEntry { | 8942 class HtmlEntry extends SourceEntry { |
| 9443 /** | 8943 /** |
| 9444 * The state of the cached parsed (but not resolved) HTML unit. | |
| 9445 */ | |
| 9446 CacheState _parsedUnitState = CacheState.INVALID; | |
| 9447 | |
| 9448 /** | |
| 9449 * The parsed HTML unit, or `null` if the parsed HTML unit is not currently ca
ched. | |
| 9450 */ | |
| 9451 ht.HtmlUnit _parsedUnit; | |
| 9452 | |
| 9453 /** | |
| 9454 * The state of the cached resolved HTML unit. | |
| 9455 */ | |
| 9456 CacheState _resolvedUnitState = CacheState.INVALID; | |
| 9457 | |
| 9458 /** | |
| 9459 * The resolved HTML unit, or `null` if the resolved HTML unit is not currentl
y cached. | |
| 9460 */ | |
| 9461 ht.HtmlUnit _resolvedUnit; | |
| 9462 | |
| 9463 /** | |
| 9464 * The state of the cached parse errors. | |
| 9465 */ | |
| 9466 CacheState _parseErrorsState = CacheState.INVALID; | |
| 9467 | |
| 9468 /** | |
| 9469 * The errors produced while scanning and parsing the HTML, or `null` if the e
rrors are not | |
| 9470 * currently cached. | |
| 9471 */ | |
| 9472 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; | |
| 9473 | |
| 9474 /** | |
| 9475 * The state of the cached resolution errors. | |
| 9476 */ | |
| 9477 CacheState _resolutionErrorsState = CacheState.INVALID; | |
| 9478 | |
| 9479 /** | |
| 9480 * The errors produced while resolving the HTML, or `null` if the errors are n
ot currently | |
| 9481 * cached. | |
| 9482 */ | |
| 9483 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | |
| 9484 | |
| 9485 /** | |
| 9486 * The state of the cached list of referenced libraries. | |
| 9487 */ | |
| 9488 CacheState _referencedLibrariesState = CacheState.INVALID; | |
| 9489 | |
| 9490 /** | |
| 9491 * The list of libraries referenced in the HTML, or `null` if the list is not
currently | |
| 9492 * cached. Note that this list does not include libraries defined directly wit
hin the HTML file. | |
| 9493 */ | |
| 9494 List<Source> _referencedLibraries = Source.EMPTY_ARRAY; | |
| 9495 | |
| 9496 /** | |
| 9497 * The state of the cached HTML element. | |
| 9498 */ | |
| 9499 CacheState _elementState = CacheState.INVALID; | |
| 9500 | |
| 9501 /** | |
| 9502 * The element representing the HTML file, or `null` if the element is not cur
rently cached. | |
| 9503 */ | |
| 9504 HtmlElement _element; | |
| 9505 | |
| 9506 /** | |
| 9507 * The state of the [angularApplication]. | |
| 9508 */ | |
| 9509 CacheState _angularApplicationState = CacheState.VALID; | |
| 9510 | |
| 9511 /** | |
| 9512 * Information about the Angular Application this unit is used in. | |
| 9513 */ | |
| 9514 AngularApplication _angularApplication; | |
| 9515 | |
| 9516 /** | |
| 9517 * The state of the [angularEntry]. | |
| 9518 */ | |
| 9519 CacheState _angularEntryState = CacheState.INVALID; | |
| 9520 | |
| 9521 /** | |
| 9522 * Information about the Angular Application this unit is entry point for. | |
| 9523 */ | |
| 9524 AngularApplication _angularEntry = null; | |
| 9525 | |
| 9526 /** | |
| 9527 * The state of the [angularComponent]. | |
| 9528 */ | |
| 9529 CacheState _angularComponentState = CacheState.VALID; | |
| 9530 | |
| 9531 /** | |
| 9532 * Information about the [AngularComponentElement] this unit is used as templa
te for. | |
| 9533 */ | |
| 9534 AngularComponentElement _angularComponent = null; | |
| 9535 | |
| 9536 /** | |
| 9537 * The state of the Angular resolution errors. | |
| 9538 */ | |
| 9539 CacheState _angularErrorsState = CacheState.INVALID; | |
| 9540 | |
| 9541 /** | |
| 9542 * The hints produced while performing Angular resolution, or an empty array i
f the error are not | |
| 9543 * currently cached. | |
| 9544 */ | |
| 9545 List<AnalysisError> _angularErrors = AnalysisError.NO_ERRORS; | |
| 9546 | |
| 9547 /** | |
| 9548 * The state of the cached hints. | |
| 9549 */ | |
| 9550 CacheState _hintsState = CacheState.INVALID; | |
| 9551 | |
| 9552 /** | |
| 9553 * The hints produced while auditing the compilation unit, or an empty array i
f the hints are not | |
| 9554 * currently cached. | |
| 9555 */ | |
| 9556 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; | |
| 9557 | |
| 9558 /** | |
| 9559 * The state of the Polymer elements. | |
| 9560 */ | |
| 9561 CacheState _polymerBuildErrorsState = CacheState.INVALID; | |
| 9562 | |
| 9563 /** | |
| 9564 * The hints produced while performing Polymer HTML elements building, or an e
mpty array if the | |
| 9565 * error are not currently cached. | |
| 9566 */ | |
| 9567 List<AnalysisError> _polymerBuildErrors = AnalysisError.NO_ERRORS; | |
| 9568 | |
| 9569 /** | |
| 9570 * The state of the Polymer resolution errors. | |
| 9571 */ | |
| 9572 CacheState _polymerResolutionErrorsState = CacheState.INVALID; | |
| 9573 | |
| 9574 /** | |
| 9575 * The hints produced while performing Polymer resolution, or an empty array i
f the error are not | |
| 9576 * currently cached. | |
| 9577 */ | |
| 9578 List<AnalysisError> _polymerResolutionErrors = AnalysisError.NO_ERRORS; | |
| 9579 | |
| 9580 /** | |
| 9581 * The data descriptor representing the information about an Angular | 8944 * The data descriptor representing the information about an Angular |
| 9582 * application this source is used in. | 8945 * application this source is used in. |
| 9583 */ | 8946 */ |
| 9584 static final DataDescriptor<AngularApplication> ANGULAR_APPLICATION | 8947 static final DataDescriptor<AngularApplication> ANGULAR_APPLICATION |
| 9585 = new DataDescriptor<AngularApplication>("HtmlEntry.ANGULAR_APPLICATION"); | 8948 = new DataDescriptor<AngularApplication>("HtmlEntry.ANGULAR_APPLICATION"); |
| 9586 | 8949 |
| 9587 /** | 8950 /** |
| 9588 * The data descriptor representing the information about an Angular component | 8951 * The data descriptor representing the information about an Angular component |
| 9589 * this source is used as template for. | 8952 * this source is used as template for. |
| 9590 */ | 8953 */ |
| 9591 static final DataDescriptor<AngularComponentElement> ANGULAR_COMPONENT | 8954 static final DataDescriptor<AngularComponentElement> ANGULAR_COMPONENT |
| 9592 = new DataDescriptor<AngularComponentElement>("HtmlEntry.ANGULAR_COMPONENT
"); | 8955 = new DataDescriptor<AngularComponentElement>("HtmlEntry.ANGULAR_COMPONENT
"); |
| 9593 | 8956 |
| 9594 /** | 8957 /** |
| 9595 * The data descriptor representing the information about an Angular | 8958 * The data descriptor representing the information about an Angular |
| 9596 * application for which this source is an entry point. | 8959 * application for which this source is an entry point. |
| 9597 */ | 8960 */ |
| 9598 static final DataDescriptor<AngularApplication> ANGULAR_ENTRY | 8961 static final DataDescriptor<AngularApplication> ANGULAR_ENTRY |
| 9599 = new DataDescriptor<AngularApplication>("HtmlEntry.ANGULAR_ENTRY"); | 8962 = new DataDescriptor<AngularApplication>("HtmlEntry.ANGULAR_ENTRY"); |
| 9600 | 8963 |
| 9601 /** | 8964 /** |
| 9602 * The data descriptor representing the errors reported during Angular | 8965 * The data descriptor representing the errors reported during Angular |
| 9603 * resolution. | 8966 * resolution. |
| 9604 */ | 8967 */ |
| 9605 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS | 8968 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS |
| 9606 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.ANGULAR_ERRORS"); | 8969 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.ANGULAR_ERRORS", Anal
ysisError.NO_ERRORS); |
| 9607 | 8970 |
| 9608 /** | 8971 /** |
| 9609 * The data descriptor representing the HTML element. | 8972 * The data descriptor representing the HTML element. |
| 9610 */ | 8973 */ |
| 9611 static final DataDescriptor<HtmlElement> ELEMENT | 8974 static final DataDescriptor<HtmlElement> ELEMENT |
| 9612 = new DataDescriptor<HtmlElement>("HtmlEntry.ELEMENT"); | 8975 = new DataDescriptor<HtmlElement>("HtmlEntry.ELEMENT"); |
| 9613 | 8976 |
| 9614 /** | 8977 /** |
| 9615 * The data descriptor representing the hints resulting from auditing the | 8978 * The data descriptor representing the hints resulting from auditing the |
| 9616 * source. | 8979 * source. |
| 9617 */ | 8980 */ |
| 9618 static final DataDescriptor<List<AnalysisError>> HINTS | 8981 static final DataDescriptor<List<AnalysisError>> HINTS |
| 9619 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.HINTS"); | 8982 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.HINTS", AnalysisError
.NO_ERRORS); |
| 9620 | 8983 |
| 9621 /** | 8984 /** |
| 9622 * The data descriptor representing the errors resulting from parsing the | 8985 * The data descriptor representing the errors resulting from parsing the |
| 9623 * source. | 8986 * source. |
| 9624 */ | 8987 */ |
| 9625 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS | 8988 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS |
| 9626 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.PARSE_ERRORS"); | 8989 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.PARSE_ERRORS", Analys
isError.NO_ERRORS); |
| 9627 | 8990 |
| 9628 /** | 8991 /** |
| 9629 * The data descriptor representing the parsed AST structure. | 8992 * The data descriptor representing the parsed AST structure. |
| 9630 */ | 8993 */ |
| 9631 static final DataDescriptor<ht.HtmlUnit> PARSED_UNIT | 8994 static final DataDescriptor<ht.HtmlUnit> PARSED_UNIT |
| 9632 = new DataDescriptor<ht.HtmlUnit>("HtmlEntry.PARSED_UNIT"); | 8995 = new DataDescriptor<ht.HtmlUnit>("HtmlEntry.PARSED_UNIT"); |
| 9633 | 8996 |
| 9634 /** | 8997 /** |
| 9635 * The data descriptor representing the resolved AST structure. | 8998 * The data descriptor representing the resolved AST structure. |
| 9636 */ | 8999 */ |
| 9637 static final DataDescriptor<ht.HtmlUnit> RESOLVED_UNIT | 9000 static final DataDescriptor<ht.HtmlUnit> RESOLVED_UNIT |
| 9638 = new DataDescriptor<ht.HtmlUnit>("HtmlEntry.RESOLVED_UNIT"); | 9001 = new DataDescriptor<ht.HtmlUnit>("HtmlEntry.RESOLVED_UNIT"); |
| 9639 | 9002 |
| 9640 /** | 9003 /** |
| 9641 * The data descriptor representing the list of referenced libraries. | 9004 * The data descriptor representing the list of referenced libraries. |
| 9642 */ | 9005 */ |
| 9643 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES | 9006 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES |
| 9644 = new DataDescriptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); | 9007 = new DataDescriptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES", Sourc
e.EMPTY_ARRAY); |
| 9645 | 9008 |
| 9646 /** | 9009 /** |
| 9647 * The data descriptor representing the errors resulting from resolving the | 9010 * The data descriptor representing the errors resulting from resolving the |
| 9648 * source. | 9011 * source. |
| 9649 */ | 9012 */ |
| 9650 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS | 9013 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS |
| 9651 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); | 9014 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS", A
nalysisError.NO_ERRORS); |
| 9652 | 9015 |
| 9653 /** | 9016 /** |
| 9654 * The data descriptor representing the status of Polymer elements in the | 9017 * The data descriptor representing the status of Polymer elements in the |
| 9655 * source. | 9018 * source. |
| 9656 */ | 9019 */ |
| 9657 static final DataDescriptor<List<AnalysisError>> POLYMER_BUILD_ERRORS | 9020 static final DataDescriptor<List<AnalysisError>> POLYMER_BUILD_ERRORS |
| 9658 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_BUILD_ERRORS"
); | 9021 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_BUILD_ERRORS"
, AnalysisError.NO_ERRORS); |
| 9659 | 9022 |
| 9660 /** | 9023 /** |
| 9661 * The data descriptor representing the errors reported during Polymer | 9024 * The data descriptor representing the errors reported during Polymer |
| 9662 * resolution. | 9025 * resolution. |
| 9663 */ | 9026 */ |
| 9664 static final DataDescriptor<List<AnalysisError>> POLYMER_RESOLUTION_ERRORS | 9027 static final DataDescriptor<List<AnalysisError>> POLYMER_RESOLUTION_ERRORS |
| 9665 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_RESOLUTION_ER
RORS"); | 9028 = new DataDescriptor<List<AnalysisError>>("HtmlEntry.POLYMER_RESOLUTION_ER
RORS", AnalysisError.NO_ERRORS); |
| 9666 | 9029 |
| 9667 /** | 9030 /** |
| 9668 * Flush any AST structures being maintained by this entry. | 9031 * Flush any AST structures being maintained by this entry. |
| 9669 */ | 9032 */ |
| 9670 void flushAstStructures() { | 9033 void flushAstStructures() { |
| 9671 if (_parsedUnitState == CacheState.VALID) { | 9034 _flush(PARSED_UNIT); |
| 9672 _parsedUnitState = CacheState.FLUSHED; | 9035 _flush(RESOLVED_UNIT); |
| 9673 _parsedUnit = null; | 9036 _flush(ANGULAR_ENTRY); |
| 9674 } | 9037 _flush(ANGULAR_ERRORS); |
| 9675 if (_resolvedUnitState == CacheState.VALID) { | |
| 9676 _resolvedUnitState = CacheState.FLUSHED; | |
| 9677 _resolvedUnit = null; | |
| 9678 } | |
| 9679 if (_angularEntryState == CacheState.VALID) { | |
| 9680 _angularEntryState = CacheState.FLUSHED; | |
| 9681 } | |
| 9682 if (_angularErrorsState == CacheState.VALID) { | |
| 9683 _angularErrorsState = CacheState.FLUSHED; | |
| 9684 } | |
| 9685 } | 9038 } |
| 9686 | 9039 |
| 9687 /** | 9040 /** |
| 9688 * Return all of the errors associated with the compilation unit that are | 9041 * Return all of the errors associated with the HTML file that are currently |
| 9689 * currently cached. | 9042 * cached. |
| 9690 */ | 9043 */ |
| 9691 List<AnalysisError> get allErrors { | 9044 List<AnalysisError> get allErrors { |
| 9692 List<AnalysisError> errors = new List<AnalysisError>(); | 9045 List<AnalysisError> errors = new List<AnalysisError>(); |
| 9693 if (_parseErrors != null) { | 9046 errors.addAll(getValue(PARSE_ERRORS)); |
| 9694 for (AnalysisError error in _parseErrors) { | 9047 errors.addAll(getValue(RESOLUTION_ERRORS)); |
| 9695 errors.add(error); | 9048 errors.addAll(getValue(ANGULAR_ERRORS)); |
| 9696 } | 9049 errors.addAll(getValue(HINTS)); |
| 9697 } | 9050 errors.addAll(getValue(POLYMER_BUILD_ERRORS)); |
| 9698 if (_resolutionErrors != null) { | 9051 errors.addAll(getValue(POLYMER_RESOLUTION_ERRORS)); |
| 9699 for (AnalysisError error in _resolutionErrors) { | |
| 9700 errors.add(error); | |
| 9701 } | |
| 9702 } | |
| 9703 if (_angularErrors != null) { | |
| 9704 for (AnalysisError error in _angularErrors) { | |
| 9705 errors.add(error); | |
| 9706 } | |
| 9707 } | |
| 9708 if (_hints != null) { | |
| 9709 for (AnalysisError error in _hints) { | |
| 9710 errors.add(error); | |
| 9711 } | |
| 9712 } | |
| 9713 if (_polymerBuildErrors != null) { | |
| 9714 for (AnalysisError error in _polymerBuildErrors) { | |
| 9715 errors.add(error); | |
| 9716 } | |
| 9717 } | |
| 9718 if (_polymerResolutionErrors != null) { | |
| 9719 for (AnalysisError error in _polymerResolutionErrors) { | |
| 9720 errors.add(error); | |
| 9721 } | |
| 9722 } | |
| 9723 if (errors.length == 0) { | 9052 if (errors.length == 0) { |
| 9724 return AnalysisError.NO_ERRORS; | 9053 return AnalysisError.NO_ERRORS; |
| 9725 } | 9054 } |
| 9726 return new List.from(errors); | 9055 return errors; |
| 9727 } | 9056 } |
| 9728 | 9057 |
| 9729 /** | 9058 /** |
| 9730 * Return a valid parsed unit, either an unresolved AST structure or the | 9059 * Return a valid parsed unit, either an unresolved AST structure or the |
| 9731 * result of resolving the AST structure, or `null` if there is no parsed unit | 9060 * result of resolving the AST structure, or `null` if there is no parsed unit |
| 9732 * available. | 9061 * available. |
| 9733 */ | 9062 */ |
| 9734 ht.HtmlUnit get anyParsedUnit { | 9063 ht.HtmlUnit get anyParsedUnit { |
| 9735 if (_parsedUnitState == CacheState.VALID) { | 9064 if (getState(PARSED_UNIT) == CacheState.VALID) { |
| 9736 // parsedUnitAccessed = true; | 9065 return getValue(PARSED_UNIT); |
| 9737 return _parsedUnit; | |
| 9738 } | 9066 } |
| 9739 if (_resolvedUnitState == CacheState.VALID) { | 9067 if (getState(RESOLVED_UNIT) == CacheState.VALID) { |
| 9740 // resovledUnitAccessed = true; | 9068 return getValue(RESOLVED_UNIT); |
| 9741 return _resolvedUnit; | |
| 9742 } | 9069 } |
| 9743 return null; | 9070 return null; |
| 9744 } | 9071 } |
| 9745 | 9072 |
| 9746 @override | 9073 @override |
| 9747 SourceKind get kind => SourceKind.HTML; | 9074 SourceKind get kind => SourceKind.HTML; |
| 9748 | 9075 |
| 9749 @override | 9076 @override |
| 9750 CacheState getState(DataDescriptor descriptor) { | |
| 9751 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { | |
| 9752 return _angularApplicationState; | |
| 9753 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { | |
| 9754 return _angularComponentState; | |
| 9755 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { | |
| 9756 return _angularEntryState; | |
| 9757 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { | |
| 9758 return _angularErrorsState; | |
| 9759 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { | |
| 9760 return _elementState; | |
| 9761 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { | |
| 9762 return _parseErrorsState; | |
| 9763 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | |
| 9764 return _parsedUnitState; | |
| 9765 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | |
| 9766 return _resolvedUnitState; | |
| 9767 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | |
| 9768 return _referencedLibrariesState; | |
| 9769 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | |
| 9770 return _resolutionErrorsState; | |
| 9771 } else if (identical(descriptor, HtmlEntry.HINTS)) { | |
| 9772 return _hintsState; | |
| 9773 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) { | |
| 9774 return _polymerBuildErrorsState; | |
| 9775 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) { | |
| 9776 return _polymerResolutionErrorsState; | |
| 9777 } | |
| 9778 return super.getState(descriptor); | |
| 9779 } | |
| 9780 | |
| 9781 @override | |
| 9782 Object getValue(DataDescriptor descriptor) { | |
| 9783 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { | |
| 9784 return _angularApplication; | |
| 9785 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { | |
| 9786 return _angularComponent; | |
| 9787 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { | |
| 9788 return _angularEntry; | |
| 9789 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { | |
| 9790 return _angularErrors; | |
| 9791 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { | |
| 9792 return _element; | |
| 9793 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { | |
| 9794 return _parseErrors; | |
| 9795 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | |
| 9796 return _parsedUnit; | |
| 9797 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | |
| 9798 return _resolvedUnit; | |
| 9799 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | |
| 9800 return _referencedLibraries; | |
| 9801 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | |
| 9802 return _resolutionErrors; | |
| 9803 } else if (identical(descriptor, HtmlEntry.HINTS)) { | |
| 9804 return _hints; | |
| 9805 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) { | |
| 9806 return _polymerBuildErrors; | |
| 9807 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) { | |
| 9808 return _polymerResolutionErrors; | |
| 9809 } | |
| 9810 return super.getValue(descriptor); | |
| 9811 } | |
| 9812 | |
| 9813 @override | |
| 9814 void invalidateAllInformation() { | 9077 void invalidateAllInformation() { |
| 9815 super.invalidateAllInformation(); | 9078 super.invalidateAllInformation(); |
| 9816 _parseErrors = AnalysisError.NO_ERRORS; | 9079 setState(PARSE_ERRORS, CacheState.INVALID); |
| 9817 _parseErrorsState = CacheState.INVALID; | 9080 setState(PARSED_UNIT, CacheState.INVALID); |
| 9818 _parsedUnit = null; | 9081 setState(RESOLVED_UNIT, CacheState.INVALID); |
| 9819 _parsedUnitState = CacheState.INVALID; | |
| 9820 _resolvedUnit = null; | |
| 9821 _resolvedUnitState = CacheState.INVALID; | |
| 9822 invalidateAllResolutionInformation(true); | 9082 invalidateAllResolutionInformation(true); |
| 9823 } | 9083 } |
| 9824 | 9084 |
| 9825 /** | 9085 /** |
| 9826 * Invalidate all of the resolution information associated with the HTML file. | 9086 * Invalidate all of the resolution information associated with the HTML file. |
| 9827 * | 9087 * If [invalidateUris] is `true`, the cached results of converting URIs to |
| 9828 * @param invalidateUris true if the cached results of converting URIs to sour
ce files should also | 9088 * source files should also be invalidated. |
| 9829 * be invalidated. | |
| 9830 */ | 9089 */ |
| 9831 void invalidateAllResolutionInformation(bool invalidateUris) { | 9090 void invalidateAllResolutionInformation(bool invalidateUris) { |
| 9832 _angularEntry = null; | 9091 setState(ANGULAR_ENTRY, CacheState.INVALID); |
| 9833 _angularEntryState = CacheState.INVALID; | 9092 setState(ANGULAR_ERRORS, CacheState.INVALID); |
| 9834 _angularErrors = AnalysisError.NO_ERRORS; | 9093 setState(POLYMER_BUILD_ERRORS, CacheState.INVALID); |
| 9835 _angularErrorsState = CacheState.INVALID; | 9094 setState(POLYMER_RESOLUTION_ERRORS, CacheState.INVALID); |
| 9836 _polymerBuildErrors = AnalysisError.NO_ERRORS; | 9095 setState(ELEMENT, CacheState.INVALID); |
| 9837 _polymerBuildErrorsState = CacheState.INVALID; | 9096 setState(RESOLUTION_ERRORS, CacheState.INVALID); |
| 9838 _polymerResolutionErrors = AnalysisError.NO_ERRORS; | 9097 setState(HINTS, CacheState.INVALID); |
| 9839 _polymerResolutionErrorsState = CacheState.INVALID; | |
| 9840 _element = null; | |
| 9841 _elementState = CacheState.INVALID; | |
| 9842 _resolutionErrors = AnalysisError.NO_ERRORS; | |
| 9843 _resolutionErrorsState = CacheState.INVALID; | |
| 9844 _hints = AnalysisError.NO_ERRORS; | |
| 9845 _hintsState = CacheState.INVALID; | |
| 9846 if (invalidateUris) { | 9098 if (invalidateUris) { |
| 9847 _referencedLibraries = Source.EMPTY_ARRAY; | 9099 setState(REFERENCED_LIBRARIES, CacheState.INVALID); |
| 9848 _referencedLibrariesState = CacheState.INVALID; | |
| 9849 } | 9100 } |
| 9850 } | 9101 } |
| 9851 | 9102 |
| 9852 @override | 9103 @override |
| 9853 void recordContentError(CaughtException exception) { | 9104 void recordContentError(CaughtException exception) { |
| 9854 super.recordContentError(exception); | 9105 super.recordContentError(exception); |
| 9855 recordParseError(exception); | 9106 recordParseError(exception); |
| 9856 } | 9107 } |
| 9857 | 9108 |
| 9858 /** | 9109 /** |
| 9859 * Record that an error was encountered while attempting to parse the source a
ssociated with this | 9110 * Record that an [exception] was encountered while attempting to parse the |
| 9860 * entry. | 9111 * source associated with this entry. |
| 9861 * | |
| 9862 * @param exception the exception that shows where the error occurred | |
| 9863 */ | 9112 */ |
| 9864 void recordParseError(CaughtException exception) { | 9113 void recordParseError(CaughtException exception) { |
| 9865 // If the scanning and parsing of HTML are separated, the following line can
be removed. | 9114 // If the scanning and parsing of HTML are separated, the following line can
be removed. |
| 9866 recordScanError(exception); | 9115 recordScanError(exception); |
| 9867 _parseErrors = AnalysisError.NO_ERRORS; | 9116 setState(PARSE_ERRORS, CacheState.ERROR); |
| 9868 _parseErrorsState = CacheState.ERROR; | 9117 setState(PARSED_UNIT, CacheState.ERROR); |
| 9869 _parsedUnit = null; | 9118 setState(REFERENCED_LIBRARIES, CacheState.ERROR); |
| 9870 _parsedUnitState = CacheState.ERROR; | |
| 9871 _referencedLibraries = Source.EMPTY_ARRAY; | |
| 9872 _referencedLibrariesState = CacheState.ERROR; | |
| 9873 recordResolutionError(exception); | 9119 recordResolutionError(exception); |
| 9874 } | 9120 } |
| 9875 | 9121 |
| 9876 /** | 9122 /** |
| 9877 * Record that an error was encountered while attempting to resolve the source
associated with | 9123 * Record that an [exception] was encountered while attempting to resolve the |
| 9878 * this entry. | 9124 * source associated with this entry. |
| 9879 * | |
| 9880 * @param exception the exception that shows where the error occurred | |
| 9881 */ | 9125 */ |
| 9882 void recordResolutionError(CaughtException exception) { | 9126 void recordResolutionError(CaughtException exception) { |
| 9883 this.exception = exception; | 9127 this.exception = exception; |
| 9884 _angularErrors = AnalysisError.NO_ERRORS; | 9128 setState(ANGULAR_ERRORS, CacheState.ERROR); |
| 9885 _angularErrorsState = CacheState.ERROR; | 9129 setState(RESOLVED_UNIT, CacheState.ERROR); |
| 9886 _resolvedUnit = null; | 9130 setState(ELEMENT, CacheState.ERROR); |
| 9887 _resolvedUnitState = CacheState.ERROR; | 9131 setState(RESOLUTION_ERRORS, CacheState.ERROR); |
| 9888 _element = null; | 9132 setState(HINTS, CacheState.ERROR); |
| 9889 _elementState = CacheState.ERROR; | 9133 setState(POLYMER_BUILD_ERRORS, CacheState.ERROR); |
| 9890 _resolutionErrors = AnalysisError.NO_ERRORS; | 9134 setState(POLYMER_RESOLUTION_ERRORS, CacheState.ERROR); |
| 9891 _resolutionErrorsState = CacheState.ERROR; | |
| 9892 _hints = AnalysisError.NO_ERRORS; | |
| 9893 _hintsState = CacheState.ERROR; | |
| 9894 _polymerBuildErrors = AnalysisError.NO_ERRORS; | |
| 9895 _polymerBuildErrorsState = CacheState.ERROR; | |
| 9896 _polymerResolutionErrors = AnalysisError.NO_ERRORS; | |
| 9897 _polymerResolutionErrorsState = CacheState.ERROR; | |
| 9898 } | 9135 } |
| 9899 | 9136 |
| 9900 @override | 9137 @override |
| 9901 void setState(DataDescriptor descriptor, CacheState state) { | 9138 bool _isValidDescriptor(DataDescriptor descriptor) { |
| 9902 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { | 9139 return descriptor == ANGULAR_APPLICATION |
| 9903 _angularApplication = updatedValue(state, _angularApplication, null); | 9140 || descriptor == ANGULAR_COMPONENT |
| 9904 _angularApplicationState = state; | 9141 || descriptor == ANGULAR_ENTRY |
| 9905 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { | 9142 || descriptor == ANGULAR_ERRORS |
| 9906 _angularComponent = updatedValue(state, _angularComponent, null); | 9143 || descriptor == ELEMENT |
| 9907 _angularComponentState = state; | 9144 || descriptor == HINTS |
| 9908 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { | 9145 || descriptor == PARSED_UNIT |
| 9909 _angularEntry = updatedValue(state, _angularEntry, null); | 9146 || descriptor == PARSE_ERRORS |
| 9910 _angularEntryState = state; | 9147 || descriptor == POLYMER_BUILD_ERRORS |
| 9911 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { | 9148 || descriptor == POLYMER_RESOLUTION_ERRORS |
| 9912 _angularErrors = updatedValue(state, _angularErrors, null); | 9149 || descriptor == REFERENCED_LIBRARIES |
| 9913 _angularErrorsState = state; | 9150 || descriptor == RESOLUTION_ERRORS |
| 9914 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { | 9151 || descriptor == RESOLVED_UNIT |
| 9915 _element = updatedValue(state, _element, null); | 9152 || super._isValidDescriptor(descriptor); |
| 9916 _elementState = state; | |
| 9917 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { | |
| 9918 _parseErrors = updatedValue(state, _parseErrors, null); | |
| 9919 _parseErrorsState = state; | |
| 9920 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | |
| 9921 _parsedUnit = updatedValue(state, _parsedUnit, null); | |
| 9922 _parsedUnitState = state; | |
| 9923 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | |
| 9924 _resolvedUnit = updatedValue(state, _resolvedUnit, null); | |
| 9925 _resolvedUnitState = state; | |
| 9926 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | |
| 9927 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM
PTY_ARRAY); | |
| 9928 _referencedLibrariesState = state; | |
| 9929 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | |
| 9930 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N
O_ERRORS); | |
| 9931 _resolutionErrorsState = state; | |
| 9932 } else if (identical(descriptor, HtmlEntry.HINTS)) { | |
| 9933 _hints = updatedValue(state, _hints, AnalysisError.NO_ERRORS); | |
| 9934 _hintsState = state; | |
| 9935 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) { | |
| 9936 _polymerBuildErrors = updatedValue(state, _polymerBuildErrors, null); | |
| 9937 _polymerBuildErrorsState = state; | |
| 9938 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) { | |
| 9939 _polymerResolutionErrors = updatedValue(state, _polymerResolutionErrors, n
ull); | |
| 9940 _polymerResolutionErrorsState = state; | |
| 9941 } else { | |
| 9942 super.setState(descriptor, state); | |
| 9943 } | |
| 9944 } | 9153 } |
| 9945 | 9154 |
| 9946 @override | 9155 @override |
| 9947 void setValue(DataDescriptor descriptor, Object value) { | 9156 bool _writeDiffOn(StringBuffer buffer, SourceEntry oldEntry) { |
| 9948 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { | 9157 bool needsSeparator = super._writeDiffOn(buffer, oldEntry); |
| 9949 _angularApplication = value as AngularApplication; | |
| 9950 _angularApplicationState = CacheState.VALID; | |
| 9951 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { | |
| 9952 _angularComponent = value as AngularComponentElement; | |
| 9953 _angularComponentState = CacheState.VALID; | |
| 9954 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { | |
| 9955 _angularEntry = value as AngularApplication; | |
| 9956 _angularEntryState = CacheState.VALID; | |
| 9957 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { | |
| 9958 _angularErrors = value as List<AnalysisError>; | |
| 9959 _angularErrorsState = CacheState.VALID; | |
| 9960 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { | |
| 9961 _element = value as HtmlElement; | |
| 9962 _elementState = CacheState.VALID; | |
| 9963 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { | |
| 9964 _parseErrors = value as List<AnalysisError>; | |
| 9965 _parseErrorsState = CacheState.VALID; | |
| 9966 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | |
| 9967 _parsedUnit = value as ht.HtmlUnit; | |
| 9968 _parsedUnitState = CacheState.VALID; | |
| 9969 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { | |
| 9970 _resolvedUnit = value as ht.HtmlUnit; | |
| 9971 _resolvedUnitState = CacheState.VALID; | |
| 9972 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | |
| 9973 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List
<Source>); | |
| 9974 _referencedLibrariesState = CacheState.VALID; | |
| 9975 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | |
| 9976 _resolutionErrors = value as List<AnalysisError>; | |
| 9977 _resolutionErrorsState = CacheState.VALID; | |
| 9978 } else if (identical(descriptor, HtmlEntry.HINTS)) { | |
| 9979 _hints = value as List<AnalysisError>; | |
| 9980 _hintsState = CacheState.VALID; | |
| 9981 } else if (identical(descriptor, HtmlEntry.POLYMER_BUILD_ERRORS)) { | |
| 9982 _polymerBuildErrors = value as List<AnalysisError>; | |
| 9983 _polymerBuildErrorsState = CacheState.VALID; | |
| 9984 } else if (identical(descriptor, HtmlEntry.POLYMER_RESOLUTION_ERRORS)) { | |
| 9985 _polymerResolutionErrors = value as List<AnalysisError>; | |
| 9986 _polymerResolutionErrorsState = CacheState.VALID; | |
| 9987 } else { | |
| 9988 super.setValue(descriptor, value); | |
| 9989 } | |
| 9990 } | |
| 9991 | |
| 9992 @override | |
| 9993 bool get hasErrorState => super.hasErrorState || _parsedUnitState == CacheStat
e.ERROR || _resolvedUnitState == CacheState.ERROR || _parseErrorsState == CacheS
tate.ERROR || _resolutionErrorsState == CacheState.ERROR || _referencedLibraries
State == CacheState.ERROR || _elementState == CacheState.ERROR || _angularErrors
State == CacheState.ERROR || _hintsState == CacheState.ERROR || _polymerBuildErr
orsState == CacheState.ERROR || _polymerResolutionErrorsState == CacheState.ERRO
R; | |
| 9994 | |
| 9995 @override | |
| 9996 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) { | |
| 9997 bool needsSeparator = super.writeDiffOn(builder, oldEntry); | |
| 9998 if (oldEntry is! HtmlEntry) { | 9158 if (oldEntry is! HtmlEntry) { |
| 9999 if (needsSeparator) { | 9159 if (needsSeparator) { |
| 10000 builder.append("; "); | 9160 buffer.write("; "); |
| 10001 } | 9161 } |
| 10002 builder.append("entry type changed; was ${oldEntry.runtimeType.toString()}
"); | 9162 buffer.write("entry type changed; was "); |
| 9163 buffer.write(oldEntry.runtimeType); |
| 10003 return true; | 9164 return true; |
| 10004 } | 9165 } |
| 10005 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.PARSE_ERRORS, "parseErrors"); | 9166 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "parseErrors", Ht
mlEntry.PARSE_ERRORS, oldEntry); |
| 10006 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.PARSED_UNIT, "parsedUnit"); | 9167 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "parsedUnit", Htm
lEntry.PARSED_UNIT, oldEntry); |
| 10007 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.RESOLVED_UNIT, "resolvedUnit"); | 9168 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "resolvedUnit", H
tmlEntry.RESOLVED_UNIT, oldEntry); |
| 10008 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.RESOLUTION_ERRORS, "resolutionErrors"); | 9169 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "resolutionErrors
", HtmlEntry.RESOLUTION_ERRORS, oldEntry); |
| 10009 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.REFERENCED_LIBRARIES, "referencedLibraries"); | 9170 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "referencedLibrar
ies", HtmlEntry.REFERENCED_LIBRARIES, oldEntry); |
| 10010 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.ELEMENT, "element"); | 9171 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "element", HtmlEn
try.ELEMENT, oldEntry); |
| 10011 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.ANGULAR_APPLICATION, "angularApplicationState"); | 9172 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "angularApplicati
onState", HtmlEntry.ANGULAR_APPLICATION, oldEntry); |
| 10012 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.ANGULAR_COMPONENT, "angularComponent"); | 9173 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "angularComponent
", HtmlEntry.ANGULAR_COMPONENT, oldEntry); |
| 10013 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.ANGULAR_ENTRY, "angularEntry"); | 9174 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "angularEntry", H
tmlEntry.ANGULAR_ENTRY, oldEntry); |
| 10014 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.ANGULAR_ERRORS, "angularErrors"); | 9175 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "angularErrors",
HtmlEntry.ANGULAR_ERRORS, oldEntry); |
| 10015 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.POLYMER_BUILD_ERRORS, "polymerBuildErrors"); | 9176 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "polymerBuildErro
rs", HtmlEntry.POLYMER_BUILD_ERRORS, oldEntry); |
| 10016 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, HtmlEnt
ry.POLYMER_RESOLUTION_ERRORS, "polymerResolutionErrors"); | 9177 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "polymerResolutio
nErrors", HtmlEntry.POLYMER_RESOLUTION_ERRORS, oldEntry); |
| 10017 return needsSeparator; | 9178 return needsSeparator; |
| 10018 } | 9179 } |
| 10019 | 9180 |
| 10020 @override | 9181 @override |
| 10021 void writeOn(JavaStringBuilder builder) { | 9182 void _writeOn(StringBuffer buffer) { |
| 10022 builder.append("Html: "); | 9183 buffer.write("Html: "); |
| 10023 super.writeOn(builder); | 9184 super._writeOn(buffer); |
| 10024 builder.append("; parseErrors = "); | 9185 _writeStateOn(buffer, "parseErrors", PARSE_ERRORS); |
| 10025 builder.append(_parseErrorsState); | 9186 _writeStateOn(buffer, "parsedUnit", PARSED_UNIT); |
| 10026 builder.append("; parsedUnit = "); | 9187 _writeStateOn(buffer, "resolvedUnit", RESOLVED_UNIT); |
| 10027 builder.append(_parsedUnitState); | 9188 _writeStateOn(buffer, "resolutionErrors", RESOLUTION_ERRORS); |
| 10028 builder.append("; resolvedUnit = "); | 9189 _writeStateOn(buffer, "referencedLibraries", REFERENCED_LIBRARIES); |
| 10029 builder.append(_resolvedUnitState); | 9190 _writeStateOn(buffer, "element", ELEMENT); |
| 10030 builder.append("; resolutionErrors = "); | 9191 _writeStateOn(buffer, "angularApplication", ANGULAR_APPLICATION); |
| 10031 builder.append(_resolutionErrorsState); | 9192 _writeStateOn(buffer, "angularComponent", ANGULAR_COMPONENT); |
| 10032 builder.append("; referencedLibraries = "); | 9193 _writeStateOn(buffer, "angularEntry", ANGULAR_ENTRY); |
| 10033 builder.append(_referencedLibrariesState); | 9194 _writeStateOn(buffer, "angularErrors", ANGULAR_ERRORS); |
| 10034 builder.append("; element = "); | 9195 _writeStateOn(buffer, "polymerBuildErrors", POLYMER_BUILD_ERRORS); |
| 10035 builder.append(_elementState); | 9196 _writeStateOn(buffer, "polymerResolutionErrors", POLYMER_RESOLUTION_ERRORS); |
| 10036 builder.append("; angularApplication = "); | |
| 10037 builder.append(_angularApplicationState); | |
| 10038 builder.append("; angularComponent = "); | |
| 10039 builder.append(_angularComponentState); | |
| 10040 builder.append("; angularEntry = "); | |
| 10041 builder.append(_angularEntryState); | |
| 10042 builder.append("; angularErrors = "); | |
| 10043 builder.append(_angularErrorsState); | |
| 10044 builder.append("; polymerBuildErrors = "); | |
| 10045 builder.append(_polymerBuildErrorsState); | |
| 10046 builder.append("; polymerResolutionErrors = "); | |
| 10047 builder.append(_polymerResolutionErrorsState); | |
| 10048 } | 9197 } |
| 10049 } | 9198 } |
| 10050 | 9199 |
| 10051 /** | 9200 /** |
| 10052 * Instances of the class `IncrementalAnalysisCache` hold information used to pe
rform | 9201 * Instances of the class `IncrementalAnalysisCache` hold information used to pe
rform |
| 10053 * incremental analysis. | 9202 * incremental analysis. |
| 10054 * | 9203 * |
| 10055 * @see AnalysisContextImpl.setChangedContents(Source, String, int, int, int) | 9204 * @see AnalysisContextImpl.setChangedContents(Source, String, int, int, int) |
| 10056 */ | 9205 */ |
| 10057 class IncrementalAnalysisCache { | 9206 class IncrementalAnalysisCache { |
| (...skipping 2689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12747 ResolutionState _nextState; | 11896 ResolutionState _nextState; |
| 12748 | 11897 |
| 12749 /** | 11898 /** |
| 12750 * The source for the defining compilation unit of the library that contains t
his unit. If this | 11899 * The source for the defining compilation unit of the library that contains t
his unit. If this |
| 12751 * unit is the defining compilation unit for it's library, then this will be t
he source for this | 11900 * unit is the defining compilation unit for it's library, then this will be t
he source for this |
| 12752 * unit. | 11901 * unit. |
| 12753 */ | 11902 */ |
| 12754 Source _librarySource; | 11903 Source _librarySource; |
| 12755 | 11904 |
| 12756 /** | 11905 /** |
| 12757 * The state of the cached compilation unit that contains references to the bu
ilt element model. | 11906 * A table mapping data descriptors to the cached results for those |
| 11907 * descriptors. |
| 12758 */ | 11908 */ |
| 12759 CacheState _builtUnitState = CacheState.INVALID; | 11909 Map<DataDescriptor, CachedResult> resultMap |
| 12760 | 11910 = new HashMap<DataDescriptor, CachedResult>(); |
| 12761 /** | |
| 12762 * The compilation unit that contains references to the built element model, o
r `null` if | |
| 12763 * that compilation unit is not currently cached. | |
| 12764 */ | |
| 12765 CompilationUnit _builtUnit; | |
| 12766 | |
| 12767 /** | |
| 12768 * The state of the cached errors reported while building an element model. | |
| 12769 */ | |
| 12770 CacheState _buildElementErrorsState = CacheState.INVALID; | |
| 12771 | |
| 12772 /** | |
| 12773 * The errors produced while building an element model, or an empty array if t
he errors are not | |
| 12774 * currently cached. | |
| 12775 */ | |
| 12776 List<AnalysisError> _buildElementErrors = AnalysisError.NO_ERRORS; | |
| 12777 | |
| 12778 /** | |
| 12779 * The state of the cached resolved compilation unit. | |
| 12780 */ | |
| 12781 CacheState _resolvedUnitState = CacheState.INVALID; | |
| 12782 | |
| 12783 /** | |
| 12784 * The resolved compilation unit, or `null` if the resolved compilation unit i
s not | |
| 12785 * currently cached. | |
| 12786 */ | |
| 12787 CompilationUnit _resolvedUnit; | |
| 12788 | |
| 12789 /** | |
| 12790 * The state of the cached resolution errors. | |
| 12791 */ | |
| 12792 CacheState _resolutionErrorsState = CacheState.INVALID; | |
| 12793 | |
| 12794 /** | |
| 12795 * The errors produced while resolving the compilation unit, or an empty array
if the errors are | |
| 12796 * not currently cached. | |
| 12797 */ | |
| 12798 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | |
| 12799 | |
| 12800 /** | |
| 12801 * The state of the cached verification errors. | |
| 12802 */ | |
| 12803 CacheState _verificationErrorsState = CacheState.INVALID; | |
| 12804 | |
| 12805 /** | |
| 12806 * The errors produced while verifying the compilation unit, or an empty array
if the errors are | |
| 12807 * not currently cached. | |
| 12808 */ | |
| 12809 List<AnalysisError> _verificationErrors = AnalysisError.NO_ERRORS; | |
| 12810 | |
| 12811 /** | |
| 12812 * The state of the cached hints. | |
| 12813 */ | |
| 12814 CacheState _hintsState = CacheState.INVALID; | |
| 12815 | |
| 12816 /** | |
| 12817 * The hints produced while auditing the compilation unit, or an empty array i
f the hints are | |
| 12818 * not currently cached. | |
| 12819 */ | |
| 12820 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; | |
| 12821 | 11911 |
| 12822 /** | 11912 /** |
| 12823 * Flush any AST structures being maintained by this state. | 11913 * Flush any AST structures being maintained by this state. |
| 12824 */ | 11914 */ |
| 12825 void flushAstStructures() { | 11915 void flushAstStructures() { |
| 12826 if (_builtUnitState == CacheState.VALID) { | 11916 _flush(DartEntry.BUILT_UNIT); |
| 12827 _builtUnitState = CacheState.FLUSHED; | 11917 _flush(DartEntry.RESOLVED_UNIT); |
| 12828 _builtUnit = null; | |
| 12829 } | |
| 12830 if (_resolvedUnitState == CacheState.VALID) { | |
| 12831 _resolvedUnitState = CacheState.FLUSHED; | |
| 12832 _resolvedUnit = null; | |
| 12833 } | |
| 12834 if (_nextState != null) { | 11918 if (_nextState != null) { |
| 12835 _nextState.flushAstStructures(); | 11919 _nextState.flushAstStructures(); |
| 12836 } | 11920 } |
| 12837 } | 11921 } |
| 12838 | 11922 |
| 12839 bool get hasErrorState => _builtUnitState == CacheState.ERROR || _buildElement
ErrorsState == CacheState.ERROR || _resolvedUnitState == CacheState.ERROR || _re
solutionErrorsState == CacheState.ERROR || _verificationErrorsState == CacheStat
e.ERROR || _hintsState == CacheState.ERROR || (_nextState != null && _nextState.
hasErrorState); | 11923 /** |
| 11924 * Return the state of the data represented by the given [descriptor]. |
| 11925 */ |
| 11926 CacheState getState(DataDescriptor descriptor) { |
| 11927 CachedResult result = resultMap[descriptor]; |
| 11928 if (result == null) { |
| 11929 return CacheState.INVALID; |
| 11930 } |
| 11931 return result.state; |
| 11932 } |
| 11933 |
| 11934 /** |
| 11935 * Return the value of the data represented by the given [descriptor], or |
| 11936 * `null` if the data represented by the descriptor is not valid. |
| 11937 */ |
| 11938 /*<V>*/ dynamic /*V*/ getValue(DataDescriptor/*<V>*/ descriptor) { |
| 11939 CachedResult result = resultMap[descriptor]; |
| 11940 if (result == null) { |
| 11941 return descriptor.defaultValue; |
| 11942 } |
| 11943 return result.value; |
| 11944 } |
| 11945 |
| 11946 /** |
| 11947 * Return `true` if the state of any data value is [CacheState.ERROR]. |
| 11948 */ |
| 11949 bool hasErrorState() { |
| 11950 for (CachedResult result in resultMap.values) { |
| 11951 if (result.state == CacheState.ERROR) { |
| 11952 return true; |
| 11953 } |
| 11954 } |
| 11955 return false; |
| 11956 } |
| 12840 | 11957 |
| 12841 /** | 11958 /** |
| 12842 * Invalidate all of the resolution information associated with the compilatio
n unit. | 11959 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 12843 */ | 11960 */ |
| 12844 void invalidateAllResolutionInformation() { | 11961 void invalidateAllResolutionInformation() { |
| 12845 _nextState = null; | 11962 _nextState = null; |
| 12846 _librarySource = null; | 11963 _librarySource = null; |
| 12847 _builtUnitState = CacheState.INVALID; | 11964 setState(DartEntry.BUILT_UNIT, CacheState.INVALID); |
| 12848 _builtUnit = null; | 11965 setState(DartEntry.BUILD_ELEMENT_ERRORS, CacheState.INVALID); |
| 12849 _buildElementErrorsState = CacheState.INVALID; | 11966 setState(DartEntry.RESOLVED_UNIT, CacheState.INVALID); |
| 12850 _buildElementErrors = AnalysisError.NO_ERRORS; | 11967 setState(DartEntry.RESOLUTION_ERRORS, CacheState.INVALID); |
| 12851 _resolvedUnitState = CacheState.INVALID; | 11968 setState(DartEntry.VERIFICATION_ERRORS, CacheState.INVALID); |
| 12852 _resolvedUnit = null; | 11969 setState(DartEntry.HINTS, CacheState.INVALID); |
| 12853 _resolutionErrorsState = CacheState.INVALID; | |
| 12854 _resolutionErrors = AnalysisError.NO_ERRORS; | |
| 12855 _verificationErrorsState = CacheState.INVALID; | |
| 12856 _verificationErrors = AnalysisError.NO_ERRORS; | |
| 12857 _hintsState = CacheState.INVALID; | |
| 12858 _hints = AnalysisError.NO_ERRORS; | |
| 12859 } | 11970 } |
| 12860 | 11971 |
| 12861 /** | 11972 /** |
| 12862 * Record that an error occurred while attempting to build the element model f
or the source | 11973 * Record that an error occurred while attempting to build the element model f
or the source |
| 12863 * represented by this state. | 11974 * represented by this state. |
| 12864 */ | 11975 */ |
| 12865 void recordBuildElementError() { | 11976 void recordBuildElementError() { |
| 12866 _builtUnitState = CacheState.ERROR; | 11977 setState(DartEntry.BUILT_UNIT, CacheState.ERROR); |
| 12867 _builtUnit = null; | 11978 setState(DartEntry.BUILD_ELEMENT_ERRORS, CacheState.ERROR); |
| 12868 _buildElementErrorsState = CacheState.ERROR; | |
| 12869 _buildElementErrors = AnalysisError.NO_ERRORS; | |
| 12870 recordResolutionError(); | 11979 recordResolutionError(); |
| 12871 } | 11980 } |
| 12872 | 11981 |
| 12873 /** | 11982 /** |
| 12874 * Record that an error occurred while attempting to generate hints for the so
urce represented | 11983 * Record that an error occurred while attempting to generate hints for the so
urce represented |
| 12875 * by this entry. This will set the state of all verification information as b
eing in error. | 11984 * by this entry. This will set the state of all verification information as b
eing in error. |
| 12876 */ | 11985 */ |
| 12877 void recordHintError() { | 11986 void recordHintError() { |
| 12878 _hints = AnalysisError.NO_ERRORS; | 11987 setState(DartEntry.HINTS, CacheState.ERROR); |
| 12879 _hintsState = CacheState.ERROR; | |
| 12880 } | 11988 } |
| 12881 | 11989 |
| 12882 /** | 11990 /** |
| 12883 * Record that an error occurred while attempting to resolve the source repres
ented by this | 11991 * Record that an error occurred while attempting to resolve the source repres
ented by this |
| 12884 * state. | 11992 * state. |
| 12885 */ | 11993 */ |
| 12886 void recordResolutionError() { | 11994 void recordResolutionError() { |
| 12887 _resolvedUnitState = CacheState.ERROR; | 11995 setState(DartEntry.RESOLVED_UNIT, CacheState.ERROR); |
| 12888 _resolvedUnit = null; | 11996 setState(DartEntry.RESOLUTION_ERRORS, CacheState.ERROR); |
| 12889 _resolutionErrorsState = CacheState.ERROR; | |
| 12890 _resolutionErrors = AnalysisError.NO_ERRORS; | |
| 12891 recordVerificationError(); | 11997 recordVerificationError(); |
| 12892 } | 11998 } |
| 12893 | 11999 |
| 12894 /** | 12000 /** |
| 12895 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this | 12001 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
| 12896 * entry. This will set the state of all resolution-based information as being
in error, but | 12002 * entry. This will set the state of all resolution-based information as being
in error, but |
| 12897 * will not change the state of any parse results. | 12003 * will not change the state of any parse results. |
| 12898 */ | 12004 */ |
| 12899 void recordResolutionErrorsInAllLibraries() { | 12005 void recordResolutionErrorsInAllLibraries() { |
| 12900 _builtUnitState = CacheState.ERROR; | 12006 recordBuildElementError(); |
| 12901 _builtUnit = null; | |
| 12902 _buildElementErrorsState = CacheState.ERROR; | |
| 12903 _buildElementErrors = AnalysisError.NO_ERRORS; | |
| 12904 _resolvedUnitState = CacheState.ERROR; | |
| 12905 _resolvedUnit = null; | |
| 12906 _resolutionErrorsState = CacheState.ERROR; | |
| 12907 _resolutionErrors = AnalysisError.NO_ERRORS; | |
| 12908 recordVerificationError(); | |
| 12909 if (_nextState != null) { | 12007 if (_nextState != null) { |
| 12910 _nextState.recordResolutionErrorsInAllLibraries(); | 12008 _nextState.recordResolutionErrorsInAllLibraries(); |
| 12911 } | 12009 } |
| 12912 } | 12010 } |
| 12913 | 12011 |
| 12914 /** | 12012 /** |
| 12915 * Record that an in-process parse has stopped without recording results becau
se the results | |
| 12916 * were invalidated before they could be recorded. | |
| 12917 */ | |
| 12918 void recordResolutionNotInProcess() { | |
| 12919 if (_resolvedUnitState == CacheState.IN_PROCESS) { | |
| 12920 _resolvedUnitState = CacheState.INVALID; | |
| 12921 } | |
| 12922 if (_resolutionErrorsState == CacheState.IN_PROCESS) { | |
| 12923 _resolutionErrorsState = CacheState.INVALID; | |
| 12924 } | |
| 12925 if (_verificationErrorsState == CacheState.IN_PROCESS) { | |
| 12926 _verificationErrorsState = CacheState.INVALID; | |
| 12927 } | |
| 12928 if (_hintsState == CacheState.IN_PROCESS) { | |
| 12929 _hintsState = CacheState.INVALID; | |
| 12930 } | |
| 12931 if (_nextState != null) { | |
| 12932 _nextState.recordResolutionNotInProcess(); | |
| 12933 } | |
| 12934 } | |
| 12935 | |
| 12936 /** | |
| 12937 * Record that an error occurred while attempting to generate errors and warni
ngs for the source | 12013 * Record that an error occurred while attempting to generate errors and warni
ngs for the source |
| 12938 * represented by this entry. This will set the state of all verification info
rmation as being | 12014 * represented by this entry. This will set the state of all verification info
rmation as being |
| 12939 * in error. | 12015 * in error. |
| 12940 */ | 12016 */ |
| 12941 void recordVerificationError() { | 12017 void recordVerificationError() { |
| 12942 _verificationErrors = AnalysisError.NO_ERRORS; | 12018 setState(DartEntry.VERIFICATION_ERRORS, CacheState.ERROR); |
| 12943 _verificationErrorsState = CacheState.ERROR; | |
| 12944 recordHintError(); | 12019 recordHintError(); |
| 12945 } | 12020 } |
| 12946 | 12021 |
| 12947 /** | 12022 /** |
| 12023 * Set the state of the data represented by the given [descriptor] to the |
| 12024 * given [state]. |
| 12025 */ |
| 12026 void setState(DataDescriptor descriptor, CacheState state) { |
| 12027 if (state == CacheState.VALID) { |
| 12028 throw new ArgumentError("use setValue() to set the state to VALID"); |
| 12029 } |
| 12030 CachedResult result = resultMap.putIfAbsent( |
| 12031 descriptor, |
| 12032 () => new CachedResult(descriptor)); |
| 12033 result.state = state; |
| 12034 if (state != CacheState.IN_PROCESS) { |
| 12035 // |
| 12036 // If the state is in-process, we can leave the current value in the cache |
| 12037 // for any 'get' methods to access. |
| 12038 // |
| 12039 result.value = descriptor.defaultValue; |
| 12040 } |
| 12041 } |
| 12042 |
| 12043 /** |
| 12044 * Set the value of the data represented by the given [descriptor] to the |
| 12045 * given [value]. |
| 12046 */ |
| 12047 void setValue(DataDescriptor/*<V>*/ descriptor, dynamic /*V*/ value) { |
| 12048 CachedResult result = resultMap.putIfAbsent( |
| 12049 descriptor, |
| 12050 () => new CachedResult(descriptor)); |
| 12051 result.state = CacheState.VALID; |
| 12052 result.value = value == null ? descriptor.defaultValue : value; |
| 12053 } |
| 12054 |
| 12055 /** |
| 12056 * Flush the value of the data described by the [descriptor]. |
| 12057 */ |
| 12058 void _flush(DataDescriptor descriptor) { |
| 12059 CachedResult result = resultMap[descriptor]; |
| 12060 if (result != null && result.state == CacheState.VALID) { |
| 12061 result.state = CacheState.FLUSHED; |
| 12062 result.value = descriptor.defaultValue; |
| 12063 } |
| 12064 } |
| 12065 |
| 12066 /** |
| 12948 * Write a textual representation of the difference between the old entry and
this entry to the | 12067 * Write a textual representation of the difference between the old entry and
this entry to the |
| 12949 * given string builder. | 12068 * given string builder. |
| 12950 * | 12069 * |
| 12951 * @param builder the string builder to which the difference is to be written | 12070 * @param builder the string builder to which the difference is to be written |
| 12952 * @param oldEntry the entry that was replaced by this entry | 12071 * @param oldEntry the entry that was replaced by this entry |
| 12953 * @return `true` if some difference was written | 12072 * @return `true` if some difference was written |
| 12954 */ | 12073 */ |
| 12955 bool writeDiffOn(JavaStringBuilder builder, bool needsSeparator, DartEntry old
Entry) { | 12074 bool _writeDiffOn(StringBuffer buffer, bool needsSeparator, DartEntry oldEntry
) { |
| 12956 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.RESOLVED_UNIT, _resolvedUnitState, "resolvedUnit"); | 12075 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "resolvedUnit", D
artEntry.RESOLVED_UNIT, oldEntry); |
| 12957 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.RESOLUTION_ERRORS, _resolutionErrorsState, "resolutionErrors"); | 12076 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "resolutionErrors
", DartEntry.RESOLUTION_ERRORS, oldEntry); |
| 12958 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.VERIFICATION_ERRORS, _verificationErrorsState, "verificationErrors"); | 12077 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "verificationErro
rs", DartEntry.VERIFICATION_ERRORS, oldEntry); |
| 12959 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, DartEnt
ry.HINTS, _hintsState, "hints"); | 12078 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "hints", DartEntr
y.HINTS, oldEntry); |
| 12960 return needsSeparator; | 12079 return needsSeparator; |
| 12961 } | 12080 } |
| 12962 | 12081 |
| 12963 /** | 12082 /** |
| 12964 * Write a textual representation of this state to the given builder. The resu
lt will only be | 12083 * Write a textual representation of this state to the given builder. The resu
lt will only be |
| 12965 * used for debugging purposes. | 12084 * used for debugging purposes. |
| 12966 * | 12085 * |
| 12967 * @param builder the builder to which the text should be written | 12086 * @param builder the builder to which the text should be written |
| 12968 */ | 12087 */ |
| 12969 void writeOn(JavaStringBuilder builder) { | 12088 void _writeOn(StringBuffer buffer) { |
| 12970 if (_librarySource != null) { | 12089 if (_librarySource != null) { |
| 12971 builder.append("; builtUnit = "); | 12090 _writeStateOn(buffer, "builtUnit", DartEntry.BUILT_UNIT); |
| 12972 builder.append(_builtUnitState); | 12091 _writeStateOn(buffer, "buildElementErrors", DartEntry.BUILD_ELEMENT_ERRORS
); |
| 12973 builder.append("; buildElementErrors = "); | 12092 _writeStateOn(buffer, "resolvedUnit", DartEntry.RESOLVED_UNIT); |
| 12974 builder.append(_buildElementErrorsState); | 12093 _writeStateOn(buffer, "resolutionErrors", DartEntry.RESOLUTION_ERRORS); |
| 12975 builder.append("; resolvedUnit = "); | 12094 _writeStateOn(buffer, "verificationErrors", DartEntry.VERIFICATION_ERRORS)
; |
| 12976 builder.append(_resolvedUnitState); | 12095 _writeStateOn(buffer, "hints", DartEntry.HINTS); |
| 12977 builder.append("; resolutionErrors = "); | |
| 12978 builder.append(_resolutionErrorsState); | |
| 12979 builder.append("; verificationErrors = "); | |
| 12980 builder.append(_verificationErrorsState); | |
| 12981 builder.append("; hints = "); | |
| 12982 builder.append(_hintsState); | |
| 12983 if (_nextState != null) { | 12096 if (_nextState != null) { |
| 12984 _nextState.writeOn(builder); | 12097 _nextState._writeOn(buffer); |
| 12985 } | 12098 } |
| 12986 } | 12099 } |
| 12987 } | 12100 } |
| 12988 | 12101 |
| 12989 /** | 12102 /** |
| 12990 * Write a textual representation of the difference between the state of the s
pecified data | 12103 * Write a textual representation of the difference between the state of the |
| 12991 * between the old entry and this entry to the given string builder. | 12104 * value described by the given [descriptor] between the [oldEntry] and this |
| 12992 * | 12105 * entry to the given [buffer]. Return `true` if some difference was written. |
| 12993 * @param builder the string builder to which the difference is to be written | |
| 12994 * @param needsSeparator `true` if any data that is written | |
| 12995 * @param oldEntry the entry that was replaced by this entry | |
| 12996 * @param descriptor the descriptor defining the data whose state is being com
pared | |
| 12997 * @param label the label used to describe the state | |
| 12998 * @return `true` if some difference was written | |
| 12999 */ | 12106 */ |
| 13000 bool writeStateDiffOn(JavaStringBuilder builder, bool needsSeparator, SourceEn
try oldEntry, DataDescriptor descriptor, CacheState newState, String label) { | 12107 bool _writeStateDiffOn(StringBuffer buffer, bool needsSeparator, String label, |
| 13001 CacheState oldState = (oldEntry as DartEntry).getStateInLibrary(descriptor,
_librarySource); | 12108 DataDescriptor descriptor, SourceEntry oldEntry) { |
| 12109 CacheState oldState = oldEntry.getState(descriptor); |
| 12110 CacheState newState = getState(descriptor); |
| 13002 if (oldState != newState) { | 12111 if (oldState != newState) { |
| 13003 if (needsSeparator) { | 12112 if (needsSeparator) { |
| 13004 builder.append("; "); | 12113 buffer.write("; "); |
| 13005 } | 12114 } |
| 13006 builder.append(label); | 12115 buffer.write(label); |
| 13007 builder.append(" = "); | 12116 buffer.write(" = "); |
| 13008 builder.append(oldState); | 12117 buffer.write(oldState); |
| 13009 builder.append(" -> "); | 12118 buffer.write(" -> "); |
| 13010 builder.append(newState); | 12119 buffer.write(newState); |
| 13011 return true; | 12120 return true; |
| 13012 } | 12121 } |
| 13013 return needsSeparator; | 12122 return needsSeparator; |
| 13014 } | 12123 } |
| 12124 |
| 12125 /** |
| 12126 * Write a textual representation of the state of the value described by the |
| 12127 * given [descriptor] to the given bugger, prefixed by the given [label] to |
| 12128 * the given [buffer]. |
| 12129 */ |
| 12130 void _writeStateOn(StringBuffer buffer, String label, DataDescriptor descripto
r) { |
| 12131 CachedResult result = resultMap[descriptor]; |
| 12132 buffer.write("; "); |
| 12133 buffer.write(label); |
| 12134 buffer.write(" = "); |
| 12135 buffer.write(result == null ? "INVALID" : result.state); |
| 12136 } |
| 13015 } | 12137 } |
| 13016 | 12138 |
| 13017 /** | 12139 /** |
| 13018 * A `ResolvableCompilationUnit` is a compilation unit that is not referenced by | 12140 * A `ResolvableCompilationUnit` is a compilation unit that is not referenced by |
| 13019 * any other objects. It is used by the [LibraryResolver] to resolve a library. | 12141 * any other objects. It is used by the [LibraryResolver] to resolve a library. |
| 13020 */ | 12142 */ |
| 13021 class ResolvableCompilationUnit { | 12143 class ResolvableCompilationUnit { |
| 13022 /** | 12144 /** |
| 13023 * The source of the compilation unit. | 12145 * The source of the compilation unit. |
| 13024 */ | 12146 */ |
| (...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13705 | 12827 |
| 13706 /** | 12828 /** |
| 13707 * A `SourceEntry` maintains the information cached by an analysis context about | 12829 * A `SourceEntry` maintains the information cached by an analysis context about |
| 13708 * an individual source, no matter what kind of source it is. | 12830 * an individual source, no matter what kind of source it is. |
| 13709 */ | 12831 */ |
| 13710 abstract class SourceEntry { | 12832 abstract class SourceEntry { |
| 13711 /** | 12833 /** |
| 13712 * The most recent time at which the state of the source matched the state | 12834 * The most recent time at which the state of the source matched the state |
| 13713 * represented by this entry. | 12835 * represented by this entry. |
| 13714 */ | 12836 */ |
| 13715 int _modificationTime = 0; | 12837 int modificationTime = 0; |
| 12838 |
| 12839 /** |
| 12840 * The exception that caused one or more values to have a state of |
| 12841 * [CacheState.ERROR]. |
| 12842 */ |
| 12843 CaughtException exception; |
| 13716 | 12844 |
| 13717 /** | 12845 /** |
| 13718 * A bit-encoding of boolean flags associated with this element. | 12846 * A bit-encoding of boolean flags associated with this element. |
| 13719 */ | 12847 */ |
| 13720 int _flags = 0; | 12848 int _flags = 0; |
| 13721 | 12849 |
| 13722 /** | 12850 /** |
| 13723 * The exception that caused one or more values to have a state of | 12851 * A table mapping data descriptors to the cached results for those |
| 13724 * [CacheState.ERROR]. | 12852 * descriptors. |
| 13725 */ | 12853 */ |
| 13726 CaughtException _exception; | 12854 Map<DataDescriptor, CachedResult> resultMap |
| 13727 | 12855 = new HashMap<DataDescriptor, CachedResult>(); |
| 13728 /** | |
| 13729 * The state of the cached content. | |
| 13730 */ | |
| 13731 CacheState _contentState = CacheState.INVALID; | |
| 13732 | |
| 13733 /** | |
| 13734 * The content of the source, or `null` if the content is not currently cached
. | |
| 13735 */ | |
| 13736 String _content; | |
| 13737 | |
| 13738 /** | |
| 13739 * The state of the cached line information. | |
| 13740 */ | |
| 13741 CacheState _lineInfoState = CacheState.INVALID; | |
| 13742 | |
| 13743 /** | |
| 13744 * The line information computed for the source, or `null` if the line | |
| 13745 * information is not currently cached. | |
| 13746 */ | |
| 13747 LineInfo _lineInfo; | |
| 13748 | 12856 |
| 13749 /** | 12857 /** |
| 13750 * The data descriptor representing the contents of the source. | 12858 * The data descriptor representing the contents of the source. |
| 13751 */ | 12859 */ |
| 13752 static final DataDescriptor<String> CONTENT | 12860 static final DataDescriptor<String> CONTENT |
| 13753 = new DataDescriptor<String>("SourceEntry.CONTENT"); | 12861 = new DataDescriptor<String>("SourceEntry.CONTENT"); |
| 13754 | 12862 |
| 13755 /** | 12863 /** |
| 13756 * The data descriptor representing the line information. | 12864 * The data descriptor representing the line information. |
| 13757 */ | 12865 */ |
| 13758 static final DataDescriptor<LineInfo> LINE_INFO | 12866 static final DataDescriptor<LineInfo> LINE_INFO |
| 13759 = new DataDescriptor<LineInfo>("SourceEntry.LINE_INFO"); | 12867 = new DataDescriptor<LineInfo>("SourceEntry.LINE_INFO"); |
| 13760 | 12868 |
| 13761 /** | 12869 /** |
| 13762 * The index of the flag indicating whether the source was explicitly added to | 12870 * The index of the flag indicating whether the source was explicitly added to |
| 13763 * the context or whether the source was implicitly added because it was | 12871 * the context or whether the source was implicitly added because it was |
| 13764 * referenced by another source. | 12872 * referenced by another source. |
| 13765 */ | 12873 */ |
| 13766 static int _EXPLICITLY_ADDED_FLAG = 0; | 12874 static int _EXPLICITLY_ADDED_FLAG = 0; |
| 13767 | 12875 |
| 13768 /** | 12876 /** |
| 13769 * Fix the state of the [exception] to match the current state of the entry. | |
| 13770 */ | |
| 13771 void fixExceptionState() { | |
| 13772 if (hasErrorState) { | |
| 13773 if (_exception == null) { | |
| 13774 // | |
| 13775 // This code should never be reached, but is a fail-safe in case an exce
ption is not | |
| 13776 // recorded when it should be. | |
| 13777 // | |
| 13778 _exception = new CaughtException(new AnalysisException("State set to ERR
OR without setting an exception"), null); | |
| 13779 } | |
| 13780 } else { | |
| 13781 _exception = null; | |
| 13782 } | |
| 13783 } | |
| 13784 | |
| 13785 /** | |
| 13786 * Return a textual representation of the difference between the old entry and
this entry. The | |
| 13787 * difference is represented as a sequence of fields whose value would change
if the old entry | |
| 13788 * were converted into the new entry. | |
| 13789 * | |
| 13790 * @param oldEntry the entry being diff'd with this entry | |
| 13791 * @return a textual representation of the difference | |
| 13792 */ | |
| 13793 String getDiff(SourceEntry oldEntry) { | |
| 13794 JavaStringBuilder builder = new JavaStringBuilder(); | |
| 13795 writeDiffOn(builder, oldEntry); | |
| 13796 return builder.toString(); | |
| 13797 } | |
| 13798 | |
| 13799 /** | |
| 13800 * Return the exception that caused one or more values to have a state of | |
| 13801 * [CacheState.ERROR]. | |
| 13802 */ | |
| 13803 CaughtException get exception => _exception; | |
| 13804 | |
| 13805 /** | |
| 13806 * Return `true` if the source was explicitly added to the context or `false` | 12877 * Return `true` if the source was explicitly added to the context or `false` |
| 13807 * if the source was implicitly added because it was referenced by another | 12878 * if the source was implicitly added because it was referenced by another |
| 13808 * source. | 12879 * source. |
| 13809 */ | 12880 */ |
| 13810 bool get explicitlyAdded => getFlag(_EXPLICITLY_ADDED_FLAG); | 12881 bool get explicitlyAdded => _getFlag(_EXPLICITLY_ADDED_FLAG); |
| 12882 |
| 12883 /** |
| 12884 * Set whether the source was explicitly added to the context to match the |
| 12885 * [explicitlyAdded] flag. |
| 12886 */ |
| 12887 void set explicitlyAdded(bool explicitlyAdded) { |
| 12888 _setFlag(_EXPLICITLY_ADDED_FLAG, explicitlyAdded); |
| 12889 } |
| 12890 |
| 12891 /** |
| 12892 * Fix the state of the [exception] to match the current state of the entry. |
| 12893 */ |
| 12894 void fixExceptionState() { |
| 12895 if (hasErrorState()) { |
| 12896 if (exception == null) { |
| 12897 // |
| 12898 // This code should never be reached, but is a fail-safe in case an |
| 12899 // exception is not recorded when it should be. |
| 12900 // |
| 12901 String message = "State set to ERROR without setting an exception"; |
| 12902 exception = new CaughtException(new AnalysisException(message), null); |
| 12903 } |
| 12904 } else { |
| 12905 exception = null; |
| 12906 } |
| 12907 } |
| 12908 |
| 12909 /** |
| 12910 * Return a textual representation of the difference between the [oldEntry] |
| 12911 * and this entry. The difference is represented as a sequence of fields whose |
| 12912 * value would change if the old entry were converted into the new entry. |
| 12913 */ |
| 12914 String getDiff(SourceEntry oldEntry) { |
| 12915 StringBuffer buffer = new StringBuffer(); |
| 12916 _writeDiffOn(buffer, oldEntry); |
| 12917 return buffer.toString(); |
| 12918 } |
| 12919 |
| 12920 /** |
| 12921 * Return the state of the data represented by the given [descriptor]. |
| 12922 */ |
| 12923 CacheState getState(DataDescriptor descriptor) { |
| 12924 if (!_isValidDescriptor(descriptor)) { |
| 12925 throw new ArgumentError("Invalid descriptor: $descriptor"); |
| 12926 } |
| 12927 CachedResult result = resultMap[descriptor]; |
| 12928 if (result == null) { |
| 12929 return CacheState.INVALID; |
| 12930 } |
| 12931 return result.state; |
| 12932 } |
| 12933 |
| 12934 /** |
| 12935 * Return the value of the data represented by the given [descriptor], or |
| 12936 * `null` if the data represented by the descriptor is not valid. |
| 12937 */ |
| 12938 /*<V>*/ dynamic /*V*/ getValue(DataDescriptor/*<V>*/ descriptor) { |
| 12939 if (!_isValidDescriptor(descriptor)) { |
| 12940 throw new ArgumentError("Invalid descriptor: $descriptor"); |
| 12941 } |
| 12942 CachedResult result = resultMap[descriptor]; |
| 12943 if (result == null) { |
| 12944 return descriptor.defaultValue; |
| 12945 } |
| 12946 return result.value; |
| 12947 } |
| 12948 |
| 12949 /** |
| 12950 * Return `true` if the state of any data value is [CacheState.ERROR]. |
| 12951 */ |
| 12952 bool hasErrorState() { |
| 12953 for (CachedResult result in resultMap.values) { |
| 12954 if (result.state == CacheState.ERROR) { |
| 12955 return true; |
| 12956 } |
| 12957 } |
| 12958 return false; |
| 12959 } |
| 12960 |
| 12961 /** |
| 12962 * Invalidate all of the information associated with this source. |
| 12963 */ |
| 12964 void invalidateAllInformation() { |
| 12965 setState(CONTENT, CacheState.INVALID); |
| 12966 setState(LINE_INFO, CacheState.INVALID); |
| 12967 } |
| 13811 | 12968 |
| 13812 /** | 12969 /** |
| 13813 * Return the kind of the source, or `null` if the kind is not currently | 12970 * Return the kind of the source, or `null` if the kind is not currently |
| 13814 * cached. | 12971 * cached. |
| 13815 */ | 12972 */ |
| 13816 SourceKind get kind; | 12973 SourceKind get kind; |
| 13817 | 12974 |
| 13818 /** | 12975 /** |
| 13819 * Return the most recent time at which the state of the source matched the | 12976 * Record that an [exception] occurred while attempting to get the contents of |
| 13820 * state represented by this entry. | 12977 * the source represented by this entry. This will set the state of all |
| 13821 */ | 12978 * information, including any resolution-based information, as being in error. |
| 13822 int get modificationTime => _modificationTime; | |
| 13823 | |
| 13824 /** | |
| 13825 * Return the state of the data represented by the given [descriptor]. | |
| 13826 */ | |
| 13827 CacheState getState(DataDescriptor descriptor) { | |
| 13828 if (identical(descriptor, SourceEntry.CONTENT)) { | |
| 13829 return _contentState; | |
| 13830 } else if (identical(descriptor, SourceEntry.LINE_INFO)) { | |
| 13831 return _lineInfoState; | |
| 13832 } else { | |
| 13833 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | |
| 13834 } | |
| 13835 } | |
| 13836 | |
| 13837 /** | |
| 13838 * Return the value of the data represented by the given [descriptor], or | |
| 13839 * `null` if the data represented by the descriptor is not in the cache. | |
| 13840 */ | |
| 13841 Object getValue(DataDescriptor descriptor) { | |
| 13842 if (identical(descriptor, SourceEntry.CONTENT)) { | |
| 13843 return _content; | |
| 13844 } else if (identical(descriptor, SourceEntry.LINE_INFO)) { | |
| 13845 return _lineInfo; | |
| 13846 } else { | |
| 13847 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | |
| 13848 } | |
| 13849 } | |
| 13850 | |
| 13851 /** | |
| 13852 * Invalidate all of the information associated with this source. | |
| 13853 */ | |
| 13854 void invalidateAllInformation() { | |
| 13855 _content = null; | |
| 13856 _contentState = _checkContentState(CacheState.INVALID); | |
| 13857 _lineInfo = null; | |
| 13858 _lineInfoState = CacheState.INVALID; | |
| 13859 } | |
| 13860 | |
| 13861 /** | |
| 13862 * Record that an error occurred while attempting to get the contents of the s
ource represented by | |
| 13863 * this entry. This will set the state of all information, including any resol
ution-based | |
| 13864 * information, as being in error. | |
| 13865 * | |
| 13866 * @param exception the exception that shows where the error occurred | |
| 13867 */ | 12979 */ |
| 13868 void recordContentError(CaughtException exception) { | 12980 void recordContentError(CaughtException exception) { |
| 13869 _content = null; | 12981 setState(CONTENT, CacheState.ERROR); |
| 13870 _contentState = CacheState.ERROR; | |
| 13871 recordScanError(exception); | 12982 recordScanError(exception); |
| 13872 } | 12983 } |
| 13873 | 12984 |
| 13874 /** | 12985 /** |
| 13875 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this | 12986 * Record that an [exception] occurred while attempting to scan or parse the |
| 13876 * entry. This will set the state of all information, including any resolution
-based information, | 12987 * entry represented by this entry. This will set the state of all |
| 13877 * as being in error. | 12988 * information, including any resolution-based information, as being in error. |
| 13878 * | |
| 13879 * @param exception the exception that shows where the error occurred | |
| 13880 */ | 12989 */ |
| 13881 void recordScanError(CaughtException exception) { | 12990 void recordScanError(CaughtException exception) { |
| 13882 this.exception = exception; | 12991 this.exception = exception; |
| 13883 _lineInfo = null; | 12992 setState(LINE_INFO, CacheState.ERROR); |
| 13884 _lineInfoState = CacheState.ERROR; | 12993 } |
| 13885 } | 12994 |
| 13886 | 12995 /** |
| 13887 /** | 12996 * Set the state of the data represented by the given [descriptor] to the |
| 13888 * Set whether the source was explicitly added to the context to match the | 12997 * given [state]. |
| 13889 * given value. | |
| 13890 */ | |
| 13891 void set explicitlyAdded(bool explicitlyAdded) { | |
| 13892 setFlag(_EXPLICITLY_ADDED_FLAG, explicitlyAdded); | |
| 13893 } | |
| 13894 | |
| 13895 /** | |
| 13896 * Set the most recent time at which the state of the source matched the state | |
| 13897 * represented by this entry to the given time. | |
| 13898 */ | |
| 13899 void set modificationTime(int time) { | |
| 13900 _modificationTime = time; | |
| 13901 } | |
| 13902 | |
| 13903 /** | |
| 13904 * Set the state of the data represented by the given descriptor to the given
state. | |
| 13905 * | |
| 13906 * @param descriptor the descriptor representing the data whose state is to be
set | |
| 13907 * @param the new state of the data represented by the given descriptor | |
| 13908 */ | 12998 */ |
| 13909 void setState(DataDescriptor descriptor, CacheState state) { | 12999 void setState(DataDescriptor descriptor, CacheState state) { |
| 13910 if (identical(descriptor, SourceEntry.CONTENT)) { | 13000 if (!_isValidDescriptor(descriptor)) { |
| 13911 _content = updatedValue(state, _content, null); | 13001 throw new ArgumentError("Invalid descriptor: $descriptor"); |
| 13912 _contentState = _checkContentState(state); | 13002 } |
| 13913 } else if (identical(descriptor, SourceEntry.LINE_INFO)) { | 13003 if (state == CacheState.VALID) { |
| 13914 _lineInfo = updatedValue(state, _lineInfo, null); | 13004 throw new ArgumentError("use setValue() to set the state to VALID"); |
| 13915 _lineInfoState = state; | 13005 } |
| 13916 } else { | 13006 _validateStateChange(descriptor, state); |
| 13917 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 13007 CachedResult result = resultMap.putIfAbsent( |
| 13918 } | 13008 descriptor, |
| 13919 } | 13009 () => new CachedResult(descriptor)); |
| 13920 | 13010 result.state = state; |
| 13921 /** | 13011 if (state != CacheState.IN_PROCESS) { |
| 13922 * Set the value of the data represented by the given descriptor to the given
value. | 13012 // |
| 13923 * | 13013 // If the state is in-process, we can leave the current value in the cache |
| 13924 * @param descriptor the descriptor representing the data whose value is to be
set | 13014 // for any 'get' methods to access. |
| 13925 * @param value the new value of the data represented by the given descriptor | 13015 // |
| 13926 */ | 13016 result.value = descriptor.defaultValue; |
| 13927 void setValue(DataDescriptor descriptor, Object value) { | 13017 } |
| 13928 if (identical(descriptor, SourceEntry.CONTENT)) { | 13018 } |
| 13929 _content = value as String; | 13019 |
| 13930 _contentState = _checkContentState(CacheState.VALID); | 13020 /** |
| 13931 } else if (identical(descriptor, SourceEntry.LINE_INFO)) { | 13021 * Set the value of the data represented by the given [descriptor] to the |
| 13932 _lineInfo = value as LineInfo; | 13022 * given [value]. |
| 13933 _lineInfoState = CacheState.VALID; | 13023 */ |
| 13934 } else { | 13024 void setValue(DataDescriptor/*<V>*/ descriptor, dynamic /*V*/ value) { |
| 13935 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 13025 if (!_isValidDescriptor(descriptor)) { |
| 13936 } | 13026 throw new ArgumentError("Invalid descriptor: $descriptor"); |
| 13027 } |
| 13028 _validateStateChange(descriptor, CacheState.VALID); |
| 13029 CachedResult result = resultMap.putIfAbsent( |
| 13030 descriptor, |
| 13031 () => new CachedResult(descriptor)); |
| 13032 result.state = CacheState.VALID; |
| 13033 result.value = value == null ? descriptor.defaultValue : value; |
| 13937 } | 13034 } |
| 13938 | 13035 |
| 13939 @override | 13036 @override |
| 13940 String toString() { | 13037 String toString() { |
| 13941 JavaStringBuilder builder = new JavaStringBuilder(); | 13038 StringBuffer buffer = new StringBuffer(); |
| 13942 writeOn(builder); | 13039 _writeOn(buffer); |
| 13943 return builder.toString(); | 13040 return buffer.toString(); |
| 13944 } | 13041 } |
| 13945 | 13042 |
| 13946 /** | 13043 /** |
| 13947 * Set the value of all of the flags with the given indexes to false. | 13044 * Set the value of all of the flags with the given [indexes] to false. |
| 13948 * | 13045 */ |
| 13949 * @param indexes the indexes of the flags whose value is to be set to false | 13046 void _clearFlags(List<int> indexes) { |
| 13950 */ | |
| 13951 void clearFlags(List<int> indexes) { | |
| 13952 for (int i = 0; i < indexes.length; i++) { | 13047 for (int i = 0; i < indexes.length; i++) { |
| 13953 _flags = BooleanArray.set(_flags, indexes[i], false); | 13048 _flags = BooleanArray.set(_flags, indexes[i], false); |
| 13954 } | 13049 } |
| 13955 } | 13050 } |
| 13956 | 13051 |
| 13957 /** | 13052 /** |
| 13958 * Return the value of the flag with the given index. | 13053 * Flush the value of the data described by the [descriptor]. |
| 13959 * | 13054 */ |
| 13960 * @param index the index of the flag whose value is to be returned | 13055 void _flush(DataDescriptor descriptor) { |
| 13961 * @return the value of the flag with the given index | 13056 CachedResult result = resultMap[descriptor]; |
| 13962 */ | 13057 if (result != null && result.state == CacheState.VALID) { |
| 13963 bool getFlag(int index) => BooleanArray.get(_flags, index); | 13058 _validateStateChange(descriptor, CacheState.FLUSHED); |
| 13964 | 13059 result.state = CacheState.FLUSHED; |
| 13965 /** | 13060 result.value = descriptor.defaultValue; |
| 13966 * Return `true` if the state of any data value is [CacheState.ERROR]. | 13061 } |
| 13967 * | 13062 } |
| 13968 * @return `true` if the state of any data value is [CacheState.ERROR] | 13063 |
| 13969 */ | 13064 /** |
| 13970 bool get hasErrorState => _contentState == CacheState.ERROR || _lineInfoState
== CacheState.ERROR; | 13065 * Return the value of the flag with the given [index]. |
| 13971 | 13066 */ |
| 13972 /** | 13067 bool _getFlag(int index) => BooleanArray.get(_flags, index); |
| 13973 * Set the exception that caused one or more values to have a state of | 13068 |
| 13974 * [CacheState.ERROR] to the given [exception]. | 13069 /** |
| 13975 */ | 13070 * Return `true` if the [descriptor] is valid for this entry. |
| 13976 void set exception(CaughtException exception) { | 13071 */ |
| 13977 if (exception == null) { | 13072 bool _isValidDescriptor(DataDescriptor descriptor) { |
| 13978 throw new IllegalArgumentException("exception cannot be null"); | 13073 return descriptor == CONTENT |
| 13979 } | 13074 || descriptor == LINE_INFO; |
| 13980 this._exception = exception; | 13075 } |
| 13981 } | 13076 |
| 13982 | 13077 /** |
| 13983 /** | 13078 * Set the value of the flag with the given [index] to the given [value]. |
| 13984 * Set the value of the flag with the given index to the given value. | 13079 */ |
| 13985 * | 13080 void _setFlag(int index, bool value) { |
| 13986 * @param index the index of the flag whose value is to be returned | |
| 13987 * @param value the value of the flag with the given index | |
| 13988 */ | |
| 13989 void setFlag(int index, bool value) { | |
| 13990 _flags = BooleanArray.set(_flags, index, value); | 13081 _flags = BooleanArray.set(_flags, index, value); |
| 13991 } | 13082 } |
| 13992 | 13083 |
| 13993 /** | 13084 /** |
| 13994 * Given that some data is being transitioned to the given state, return the v
alue that should be | 13085 * Write a textual representation of the difference between the [oldEntry] and |
| 13995 * kept in the cache. | 13086 * this entry to the given string [buffer]. Return `true` if some difference |
| 13996 * | 13087 * was written. |
| 13997 * @param state the state to which the data is being transitioned | 13088 */ |
| 13998 * @param currentValue the value of the data before the transition | 13089 bool _writeDiffOn(StringBuffer buffer, SourceEntry oldEntry) { |
| 13999 * @param defaultValue the value to be used if the current value is to be remo
ved from the cache | |
| 14000 * @return the value of the data that should be kept in the cache | |
| 14001 */ | |
| 14002 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { | |
| 14003 if (state == CacheState.VALID) { | |
| 14004 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | |
| 14005 } else if (state == CacheState.IN_PROCESS) { | |
| 14006 // | |
| 14007 // We can leave the current value in the cache for any 'get' methods to ac
cess. | |
| 14008 // | |
| 14009 return currentValue; | |
| 14010 } | |
| 14011 return defaultValue; | |
| 14012 } | |
| 14013 | |
| 14014 /** | |
| 14015 * Write a textual representation of the difference between the old entry and
this entry to the | |
| 14016 * given string builder. | |
| 14017 * | |
| 14018 * @param builder the string builder to which the difference is to be written | |
| 14019 * @param oldEntry the entry that was replaced by this entry | |
| 14020 * @return `true` if some difference was written | |
| 14021 */ | |
| 14022 bool writeDiffOn(JavaStringBuilder builder, SourceEntry oldEntry) { | |
| 14023 bool needsSeparator = false; | 13090 bool needsSeparator = false; |
| 14024 CaughtException oldException = oldEntry.exception; | 13091 CaughtException oldException = oldEntry.exception; |
| 14025 if (!identical(oldException, _exception)) { | 13092 if (!identical(oldException, exception)) { |
| 14026 builder.append("exception = "); | 13093 buffer.write("exception = "); |
| 14027 builder.append(oldException.runtimeType); | 13094 buffer.write(oldException.runtimeType); |
| 14028 builder.append(" -> "); | 13095 buffer.write(" -> "); |
| 14029 builder.append(_exception.runtimeType); | 13096 buffer.write(exception.runtimeType); |
| 14030 needsSeparator = true; | 13097 needsSeparator = true; |
| 14031 } | 13098 } |
| 14032 int oldModificationTime = oldEntry.modificationTime; | 13099 int oldModificationTime = oldEntry.modificationTime; |
| 14033 if (oldModificationTime != _modificationTime) { | 13100 if (oldModificationTime != modificationTime) { |
| 14034 if (needsSeparator) { | 13101 if (needsSeparator) { |
| 14035 builder.append("; "); | 13102 buffer.write("; "); |
| 14036 } | 13103 } |
| 14037 builder.append("time = "); | 13104 buffer.write("time = "); |
| 14038 builder.append(oldModificationTime); | 13105 buffer.write(oldModificationTime); |
| 14039 builder.append(" -> "); | 13106 buffer.write(" -> "); |
| 14040 builder.append(_modificationTime); | 13107 buffer.write(modificationTime); |
| 14041 needsSeparator = true; | 13108 needsSeparator = true; |
| 14042 } | 13109 } |
| 14043 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, SourceE
ntry.CONTENT, "content"); | 13110 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "content", CONTEN
T, oldEntry); |
| 14044 needsSeparator = writeStateDiffOn(builder, needsSeparator, oldEntry, SourceE
ntry.LINE_INFO, "lineInfo"); | 13111 needsSeparator = _writeStateDiffOn(buffer, needsSeparator, "lineInfo", LINE_
INFO, oldEntry); |
| 14045 return needsSeparator; | 13112 return needsSeparator; |
| 14046 } | 13113 } |
| 14047 | 13114 |
| 14048 /** | 13115 /** |
| 14049 * Write a textual representation of this entry to the given builder. The resu
lt will only be used | 13116 * Write a textual representation of this entry to the given [buffer]. The |
| 14050 * for debugging purposes. | 13117 * result should only be used for debugging purposes. |
| 14051 * | 13118 */ |
| 14052 * @param builder the builder to which the text should be written | 13119 void _writeOn(StringBuffer buffer) { |
| 14053 */ | 13120 buffer.write("time = "); |
| 14054 void writeOn(JavaStringBuilder builder) { | 13121 buffer.write(modificationTime); |
| 14055 builder.append("time = "); | 13122 _writeStateOn(buffer, "content", CONTENT); |
| 14056 builder.append(_modificationTime); | 13123 _writeStateOn(buffer, "lineInfo", LINE_INFO); |
| 14057 builder.append("; content = "); | 13124 } |
| 14058 builder.append(_contentState); | 13125 |
| 14059 builder.append("; lineInfo = "); | 13126 /** |
| 14060 builder.append(_lineInfoState); | 13127 * Write a textual representation of the difference between the state of the |
| 14061 } | 13128 * value described by the given [descriptor] between the [oldEntry] and this |
| 14062 | 13129 * entry to the given [buffer]. Return `true` if some difference was written. |
| 14063 /** | 13130 */ |
| 14064 * Write a textual representation of the difference between the state of the s
pecified data | 13131 bool _writeStateDiffOn(StringBuffer buffer, bool needsSeparator, String label, |
| 14065 * between the old entry and this entry to the given string builder. | 13132 DataDescriptor descriptor, SourceEntry oldEntry) { |
| 14066 * | |
| 14067 * @param builder the string builder to which the difference is to be written | |
| 14068 * @param needsSeparator `true` if any data that is written | |
| 14069 * @param oldEntry the entry that was replaced by this entry | |
| 14070 * @param descriptor the descriptor defining the data whose state is being com
pared | |
| 14071 * @param label the label used to describe the state | |
| 14072 * @return `true` if some difference was written | |
| 14073 */ | |
| 14074 bool writeStateDiffOn(JavaStringBuilder builder, bool needsSeparator, SourceEn
try oldEntry, DataDescriptor descriptor, String label) { | |
| 14075 CacheState oldState = oldEntry.getState(descriptor); | 13133 CacheState oldState = oldEntry.getState(descriptor); |
| 14076 CacheState newState = getState(descriptor); | 13134 CacheState newState = getState(descriptor); |
| 14077 if (oldState != newState) { | 13135 if (oldState != newState) { |
| 14078 if (needsSeparator) { | 13136 if (needsSeparator) { |
| 14079 builder.append("; "); | 13137 buffer.write("; "); |
| 14080 } | 13138 } |
| 14081 builder.append(label); | 13139 buffer.write(label); |
| 14082 builder.append(" = "); | 13140 buffer.write(" = "); |
| 14083 builder.append(oldState); | 13141 buffer.write(oldState); |
| 14084 builder.append(" -> "); | 13142 buffer.write(" -> "); |
| 14085 builder.append(newState); | 13143 buffer.write(newState); |
| 14086 return true; | 13144 return true; |
| 14087 } | 13145 } |
| 14088 return needsSeparator; | 13146 return needsSeparator; |
| 14089 } | 13147 } |
| 14090 | 13148 |
| 14091 /** | 13149 /** |
| 14092 * If the state is changing from ERROR to anything else, capture the informati
on. This is an | 13150 * Write a textual representation of the state of the value described by the |
| 14093 * attempt to discover the underlying cause of a long-standing bug. | 13151 * given [descriptor] to the given bugger, prefixed by the given [label] to |
| 14094 * | 13152 * the given [buffer]. |
| 14095 * @param newState the new state of the content | 13153 */ |
| 14096 * @return the new state of the content | 13154 void _writeStateOn(StringBuffer buffer, String label, DataDescriptor descripto
r) { |
| 14097 */ | 13155 CachedResult result = resultMap[descriptor]; |
| 14098 CacheState _checkContentState(CacheState newState) { | 13156 buffer.write("; "); |
| 14099 if (_contentState == CacheState.ERROR) { | 13157 buffer.write(label); |
| 14100 InstrumentationBuilder builder = Instrumentation.builder2("SourceEntryImpl
-checkContentState"); | 13158 buffer.write(" = "); |
| 14101 builder.data3("message", "contentState changing from ${_contentState} to $
{newState}"); | 13159 buffer.write(result == null ? "INVALID" : result.state); |
| 13160 } |
| 13161 |
| 13162 /** |
| 13163 * If the state of the value described by the given [descriptor] is changing |
| 13164 * from ERROR to anything else, capture the information. This is an attempt to |
| 13165 * discover the underlying cause of a long-standing bug. |
| 13166 */ |
| 13167 void _validateStateChange(DataDescriptor descriptor, CacheState newState) { |
| 13168 if (descriptor != CONTENT) { |
| 13169 return; |
| 13170 } |
| 13171 CachedResult result = resultMap[CONTENT]; |
| 13172 if (result != null && result.state == CacheState.ERROR) { |
| 13173 String message = "contentState changing from ${result.state} to ${newState
}"; |
| 13174 InstrumentationBuilder builder = Instrumentation.builder2("SourceEntry-val
idateStateChange"); |
| 13175 builder.data3("message", message); |
| 14102 //builder.data("source", source.getFullName()); | 13176 //builder.data("source", source.getFullName()); |
| 14103 builder.record(new CaughtException(new AnalysisException(), null)); | 13177 builder.record(new CaughtException(new AnalysisException(message), null)); |
| 14104 builder.log(); | 13178 builder.log(); |
| 14105 } | 13179 } |
| 14106 return newState; | |
| 14107 } | 13180 } |
| 14108 } | 13181 } |
| 14109 | 13182 |
| 14110 /** | 13183 /** |
| 14111 * The enumerated type `Priority` defines the priority levels used to return sou
rces in an | 13184 * The enumerated type `Priority` defines the priority levels used to return sou
rces in an |
| 14112 * optimal order. A smaller ordinal value equates to a higher priority. | 13185 * optimal order. A smaller ordinal value equates to a higher priority. |
| 14113 */ | 13186 */ |
| 14114 class SourcePriority extends Enum<SourcePriority> { | 13187 class SourcePriority extends Enum<SourcePriority> { |
| 14115 /** | 13188 /** |
| 14116 * Used for a Dart source that is known to be a part contained in a library th
at was recently | 13189 * Used for a Dart source that is known to be a part contained in a library th
at was recently |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14398 _index++; | 13471 _index++; |
| 14399 if (_index >= _manager._workQueues[_queueIndex].length) { | 13472 if (_index >= _manager._workQueues[_queueIndex].length) { |
| 14400 _index = 0; | 13473 _index = 0; |
| 14401 _queueIndex++; | 13474 _queueIndex++; |
| 14402 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_
queueIndex].isEmpty) { | 13475 while (_queueIndex < _manager._workQueues.length && _manager._workQueues[_
queueIndex].isEmpty) { |
| 14403 _queueIndex++; | 13476 _queueIndex++; |
| 14404 } | 13477 } |
| 14405 } | 13478 } |
| 14406 } | 13479 } |
| 14407 } | 13480 } |
| OLD | NEW |