| 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 'java_core.dart'; | 10 import 'java_core.dart'; |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 } | 872 } |
| 873 | 873 |
| 874 /** | 874 /** |
| 875 * Instances of the class `AnalysisResult` | 875 * Instances of the class `AnalysisResult` |
| 876 */ | 876 */ |
| 877 class AnalysisResult { | 877 class AnalysisResult { |
| 878 /** | 878 /** |
| 879 * The change notices associated with this result, or `null` if there were no
changes and | 879 * The change notices associated with this result, or `null` if there were no
changes and |
| 880 * there is no more work to be done. | 880 * there is no more work to be done. |
| 881 */ | 881 */ |
| 882 List<ChangeNotice> _notices; | 882 final List<ChangeNotice> _notices; |
| 883 | 883 |
| 884 /** | 884 /** |
| 885 * The number of milliseconds required to determine which task was to be perfo
rmed. | 885 * The number of milliseconds required to determine which task was to be perfo
rmed. |
| 886 */ | 886 */ |
| 887 int getTime = 0; | 887 final int getTime; |
| 888 | 888 |
| 889 /** | 889 /** |
| 890 * The name of the class of the task that was performed. | 890 * The name of the class of the task that was performed. |
| 891 */ | 891 */ |
| 892 String taskClassName; | 892 final String taskClassName; |
| 893 | 893 |
| 894 /** | 894 /** |
| 895 * The number of milliseconds required to perform the task. | 895 * The number of milliseconds required to perform the task. |
| 896 */ | 896 */ |
| 897 int performTime = 0; | 897 final int performTime; |
| 898 | 898 |
| 899 /** | 899 /** |
| 900 * Initialize a newly created analysis result to have the given values. | 900 * Initialize a newly created analysis result to have the given values. |
| 901 * | 901 * |
| 902 * @param notices the change notices associated with this result | 902 * @param notices the change notices associated with this result |
| 903 * @param getTime the number of milliseconds required to determine which task
was to be performed | 903 * @param getTime the number of milliseconds required to determine which task
was to be performed |
| 904 * @param taskClassName the name of the class of the task that was performed | 904 * @param taskClassName the name of the class of the task that was performed |
| 905 * @param performTime the number of milliseconds required to perform the task | 905 * @param performTime the number of milliseconds required to perform the task |
| 906 */ | 906 */ |
| 907 AnalysisResult(List<ChangeNotice> notices, int getTime, String taskClassName,
int performTime) { | 907 AnalysisResult(this._notices, this.getTime, this.taskClassName, this.performTi
me); |
| 908 this._notices = notices; | |
| 909 this.getTime = getTime; | |
| 910 this.taskClassName = taskClassName; | |
| 911 this.performTime = performTime; | |
| 912 } | |
| 913 | 908 |
| 914 /** | 909 /** |
| 915 * Return the change notices associated with this result, or `null` if there w
ere no changes | 910 * Return the change notices associated with this result, or `null` if there w
ere no changes |
| 916 * and there is no more work to be done. | 911 * and there is no more work to be done. |
| 917 * | 912 * |
| 918 * @return the change notices associated with this result | 913 * @return the change notices associated with this result |
| 919 */ | 914 */ |
| 920 List<ChangeNotice> get changeNotices => _notices; | 915 List<ChangeNotice> get changeNotices => _notices; |
| 921 | 916 |
| 922 /** | 917 /** |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1142 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); | 1137 Map<Source, SourceEntry> _sourceMap = new Map<Source, SourceEntry>(); |
| 1143 | 1138 |
| 1144 /** | 1139 /** |
| 1145 * The maximum number of sources for which AST structures should be kept in th
e cache. | 1140 * The maximum number of sources for which AST structures should be kept in th
e cache. |
| 1146 */ | 1141 */ |
| 1147 int _maxCacheSize = 0; | 1142 int _maxCacheSize = 0; |
| 1148 | 1143 |
| 1149 /** | 1144 /** |
| 1150 * The policy used to determine which pieces of data to remove from the cache. | 1145 * The policy used to determine which pieces of data to remove from the cache. |
| 1151 */ | 1146 */ |
| 1152 CacheRetentionPolicy _retentionPolicy; | 1147 final CacheRetentionPolicy _retentionPolicy; |
| 1153 | 1148 |
| 1154 /** | 1149 /** |
| 1155 * A list containing the most recently accessed sources with the most recently
used at the end of | 1150 * A list containing the most recently accessed sources with the most recently
used at the end of |
| 1156 * the list. When more sources are added than the maximum allowed then the lea
st recently used | 1151 * the list. When more sources are added than the maximum allowed then the lea
st recently used |
| 1157 * source will be removed and will have it's cached AST structure flushed. | 1152 * source will be removed and will have it's cached AST structure flushed. |
| 1158 */ | 1153 */ |
| 1159 List<Source> _recentlyUsed; | 1154 List<Source> _recentlyUsed; |
| 1160 | 1155 |
| 1161 /** | 1156 /** |
| 1162 * Initialize a newly created cache to maintain at most the given number of AS
T structures in the | 1157 * Initialize a newly created cache to maintain at most the given number of AS
T structures in the |
| 1163 * cache. | 1158 * cache. |
| 1164 * | 1159 * |
| 1165 * @param maxCacheSize the maximum number of sources for which AST structures
should be kept in | 1160 * @param maxCacheSize the maximum number of sources for which AST structures
should be kept in |
| 1166 * the cache | 1161 * the cache |
| 1167 * @param retentionPolicy the policy used to determine which pieces of data to
remove from the | 1162 * @param retentionPolicy the policy used to determine which pieces of data to
remove from the |
| 1168 * cache | 1163 * cache |
| 1169 */ | 1164 */ |
| 1170 AnalysisCache(int maxCacheSize, CacheRetentionPolicy retentionPolicy) { | 1165 AnalysisCache(int maxCacheSize, this._retentionPolicy) { |
| 1171 this._maxCacheSize = maxCacheSize; | 1166 this._maxCacheSize = maxCacheSize; |
| 1172 this._retentionPolicy = retentionPolicy; | |
| 1173 _recentlyUsed = new List<Source>(); | 1167 _recentlyUsed = new List<Source>(); |
| 1174 } | 1168 } |
| 1175 | 1169 |
| 1176 /** | 1170 /** |
| 1177 * Record that the AST associated with the given source was just read from the
cache. | 1171 * Record that the AST associated with the given source was just read from the
cache. |
| 1178 * | 1172 * |
| 1179 * @param source the source whose AST was accessed | 1173 * @param source the source whose AST was accessed |
| 1180 */ | 1174 */ |
| 1181 void accessedAst(Source source) { | 1175 void accessedAst(Source source) { |
| 1182 if (_recentlyUsed.remove(source)) { | 1176 if (_recentlyUsed.remove(source)) { |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 * cycle of libraries and the number of AST's being reserved is larger than th
e current cache | 1302 * cycle of libraries and the number of AST's being reserved is larger than th
e current cache |
| 1309 * size. | 1303 * size. |
| 1310 * | 1304 * |
| 1311 * @return the source that was removed | 1305 * @return the source that was removed |
| 1312 */ | 1306 */ |
| 1313 Source _removeAstToFlush() { | 1307 Source _removeAstToFlush() { |
| 1314 int sourceToRemove = -1; | 1308 int sourceToRemove = -1; |
| 1315 for (int i = 0; i < _recentlyUsed.length; i++) { | 1309 for (int i = 0; i < _recentlyUsed.length; i++) { |
| 1316 Source source = _recentlyUsed[i]; | 1310 Source source = _recentlyUsed[i]; |
| 1317 RetentionPriority priority = _retentionPolicy.getAstPriority(source, _sour
ceMap[source]); | 1311 RetentionPriority priority = _retentionPolicy.getAstPriority(source, _sour
ceMap[source]); |
| 1318 if (identical(priority, RetentionPriority.LOW)) { | 1312 if (priority == RetentionPriority.LOW) { |
| 1319 return _recentlyUsed.removeAt(i); | 1313 return _recentlyUsed.removeAt(i); |
| 1320 } else if (identical(priority, RetentionPriority.MEDIUM) && sourceToRemove
< 0) { | 1314 } else if (priority == RetentionPriority.MEDIUM && sourceToRemove < 0) { |
| 1321 sourceToRemove = i; | 1315 sourceToRemove = i; |
| 1322 } | 1316 } |
| 1323 } | 1317 } |
| 1324 if (sourceToRemove < 0) { | 1318 if (sourceToRemove < 0) { |
| 1325 return null; | 1319 return null; |
| 1326 } | 1320 } |
| 1327 return _recentlyUsed.removeAt(sourceToRemove); | 1321 return _recentlyUsed.removeAt(sourceToRemove); |
| 1328 } | 1322 } |
| 1329 } | 1323 } |
| 1330 | 1324 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1347 * The enumeration `CacheState` defines the possible states of cached data. | 1341 * The enumeration `CacheState` defines the possible states of cached data. |
| 1348 */ | 1342 */ |
| 1349 class CacheState extends Enum<CacheState> { | 1343 class CacheState extends Enum<CacheState> { |
| 1350 /** | 1344 /** |
| 1351 * The data is not in the cache and the last time an attempt was made to compu
te the data an | 1345 * The data is not in the cache and the last time an attempt was made to compu
te the data an |
| 1352 * exception occurred, making it pointless to attempt. | 1346 * exception occurred, making it pointless to attempt. |
| 1353 * | 1347 * |
| 1354 * Valid Transitions: | 1348 * Valid Transitions: |
| 1355 * * [INVALID] if a source was modified that might cause the data to be comput
able | 1349 * * [INVALID] if a source was modified that might cause the data to be comput
able |
| 1356 */ | 1350 */ |
| 1357 static final CacheState ERROR = new CacheState('ERROR', 0); | 1351 static const CacheState ERROR = const CacheState('ERROR', 0); |
| 1358 | 1352 |
| 1359 /** | 1353 /** |
| 1360 * The data is not in the cache because it was flushed from the cache in order
to control memory | 1354 * The data is not in the cache because it was flushed from the cache in order
to control memory |
| 1361 * usage. If the data is recomputed, results do not need to be reported. | 1355 * usage. If the data is recomputed, results do not need to be reported. |
| 1362 * | 1356 * |
| 1363 * Valid Transitions: | 1357 * Valid Transitions: |
| 1364 * * [IN_PROCESS] if the data is being recomputed | 1358 * * [IN_PROCESS] if the data is being recomputed |
| 1365 * * [INVALID] if a source was modified that causes the data to need to be rec
omputed | 1359 * * [INVALID] if a source was modified that causes the data to need to be rec
omputed |
| 1366 */ | 1360 */ |
| 1367 static final CacheState FLUSHED = new CacheState('FLUSHED', 1); | 1361 static const CacheState FLUSHED = const CacheState('FLUSHED', 1); |
| 1368 | 1362 |
| 1369 /** | 1363 /** |
| 1370 * The data might or might not be in the cache but is in the process of being
recomputed. | 1364 * The data might or might not be in the cache but is in the process of being
recomputed. |
| 1371 * | 1365 * |
| 1372 * Valid Transitions: | 1366 * Valid Transitions: |
| 1373 * * [ERROR] if an exception occurred while trying to compute the data | 1367 * * [ERROR] if an exception occurred while trying to compute the data |
| 1374 * * [VALID] if the data was successfully computed and stored in the cache | 1368 * * [VALID] if the data was successfully computed and stored in the cache |
| 1375 */ | 1369 */ |
| 1376 static final CacheState IN_PROCESS = new CacheState('IN_PROCESS', 2); | 1370 static const CacheState IN_PROCESS = const CacheState('IN_PROCESS', 2); |
| 1377 | 1371 |
| 1378 /** | 1372 /** |
| 1379 * The data is not in the cache and needs to be recomputed so that results can
be reported. | 1373 * The data is not in the cache and needs to be recomputed so that results can
be reported. |
| 1380 * | 1374 * |
| 1381 * Valid Transitions: | 1375 * Valid Transitions: |
| 1382 * * [IN_PROCESS] if an attempt is being made to recompute the data | 1376 * * [IN_PROCESS] if an attempt is being made to recompute the data |
| 1383 */ | 1377 */ |
| 1384 static final CacheState INVALID = new CacheState('INVALID', 3); | 1378 static const CacheState INVALID = const CacheState('INVALID', 3); |
| 1385 | 1379 |
| 1386 /** | 1380 /** |
| 1387 * The data is in the cache and up-to-date. | 1381 * The data is in the cache and up-to-date. |
| 1388 * | 1382 * |
| 1389 * Valid Transitions: | 1383 * Valid Transitions: |
| 1390 * * [FLUSHED] if the data is removed in order to manage memory usage | 1384 * * [FLUSHED] if the data is removed in order to manage memory usage |
| 1391 * * [INVALID] if a source was modified in such a way as to invalidate the pre
vious data | 1385 * * [INVALID] if a source was modified in such a way as to invalidate the pre
vious data |
| 1392 */ | 1386 */ |
| 1393 static final CacheState VALID = new CacheState('VALID', 4); | 1387 static const CacheState VALID = const CacheState('VALID', 4); |
| 1394 | 1388 |
| 1395 static final List<CacheState> values = [ERROR, FLUSHED, IN_PROCESS, INVALID, V
ALID]; | 1389 static const List<CacheState> values = const [ERROR, FLUSHED, IN_PROCESS, INVA
LID, VALID]; |
| 1396 | 1390 |
| 1397 CacheState(String name, int ordinal) : super(name, ordinal); | 1391 const CacheState(String name, int ordinal) : super(name, ordinal); |
| 1398 } | 1392 } |
| 1399 | 1393 |
| 1400 /** | 1394 /** |
| 1401 * The interface `DartEntry` defines the behavior of objects that maintain the i
nformation | 1395 * The interface `DartEntry` defines the behavior of objects that maintain the i
nformation |
| 1402 * cached by an analysis context about an individual Dart file. | 1396 * cached by an analysis context about an individual Dart file. |
| 1403 */ | 1397 */ |
| 1404 abstract class DartEntry implements SourceEntry { | 1398 abstract class DartEntry implements SourceEntry { |
| 1405 /** | 1399 /** |
| 1406 * The data descriptor representing the errors reported during Angular resolut
ion. | 1400 * The data descriptor representing the errors reported during Angular resolut
ion. |
| 1407 */ | 1401 */ |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 * The state of the cached client/ server flag. | 1699 * The state of the cached client/ server flag. |
| 1706 */ | 1700 */ |
| 1707 CacheState _clientServerState = CacheState.INVALID; | 1701 CacheState _clientServerState = CacheState.INVALID; |
| 1708 | 1702 |
| 1709 /** | 1703 /** |
| 1710 * The state of the cached launchable flag. | 1704 * The state of the cached launchable flag. |
| 1711 */ | 1705 */ |
| 1712 CacheState _launchableState = CacheState.INVALID; | 1706 CacheState _launchableState = CacheState.INVALID; |
| 1713 | 1707 |
| 1714 /** | 1708 /** |
| 1715 * An integer holding bit masks such as [LAUNCHABLE] and [CLIENT_CODE]. | |
| 1716 */ | |
| 1717 int _bitmask = 0; | |
| 1718 | |
| 1719 /** | |
| 1720 * The error produced while performing Angular resolution, or an empty array i
f there are no | 1709 * The error produced while performing Angular resolution, or an empty array i
f there are no |
| 1721 * errors if the error are not currently cached. | 1710 * errors if the error are not currently cached. |
| 1722 */ | 1711 */ |
| 1723 List<AnalysisError> _angularErrors = AnalysisError.NO_ERRORS; | 1712 List<AnalysisError> _angularErrors = AnalysisError.NO_ERRORS; |
| 1724 | 1713 |
| 1725 /** | 1714 /** |
| 1726 * The index of the bit in the [bitmask] indicating that this library is launc
hable: that | 1715 * The index of the flag indicating whether this library is launchable (whethe
r the file has a |
| 1727 * the file has a main method. | 1716 * main method). |
| 1728 */ | 1717 */ |
| 1729 static int _LAUNCHABLE_INDEX = 1; | 1718 static int _LAUNCHABLE_INDEX = 1; |
| 1730 | 1719 |
| 1731 /** | 1720 /** |
| 1732 * The index of the bit in the [bitmask] indicating that the library is client
code: that | 1721 * The index of the flag indicating whether the library is client code (whethe
r the library |
| 1733 * the library depends on the html library. If the library is not "client code
", then it is | 1722 * depends on the html library). If the library is not "client code", then it
is referred to as |
| 1734 * referred to as "server code". | 1723 * "server code". |
| 1735 */ | 1724 */ |
| 1736 static int _CLIENT_CODE_INDEX = 2; | 1725 static int _CLIENT_CODE_INDEX = 2; |
| 1737 | 1726 |
| 1738 /** | 1727 /** |
| 1739 * Add the given library to the list of libraries that contain this part. This
method should only | 1728 * Add the given library to the list of libraries that contain this part. This
method should only |
| 1740 * be invoked on entries that represent a part. | 1729 * be invoked on entries that represent a part. |
| 1741 * | 1730 * |
| 1742 * @param librarySource the source of the library to be added | 1731 * @param librarySource the source of the library to be added |
| 1743 */ | 1732 */ |
| 1744 void addContainingLibrary(Source librarySource) { | 1733 void addContainingLibrary(Source librarySource) { |
| 1745 _containingLibraries.add(librarySource); | 1734 _containingLibraries.add(librarySource); |
| 1746 } | 1735 } |
| 1747 | 1736 |
| 1748 /** | 1737 /** |
| 1749 * Flush any AST structures being maintained by this entry. | 1738 * Flush any AST structures being maintained by this entry. |
| 1750 */ | 1739 */ |
| 1751 void flushAstStructures() { | 1740 void flushAstStructures() { |
| 1752 if (identical(_tokenStreamState, CacheState.VALID)) { | 1741 if (_tokenStreamState == CacheState.VALID) { |
| 1753 _tokenStreamState = CacheState.FLUSHED; | 1742 _tokenStreamState = CacheState.FLUSHED; |
| 1754 _tokenStream = null; | 1743 _tokenStream = null; |
| 1755 } | 1744 } |
| 1756 if (identical(_parsedUnitState, CacheState.VALID)) { | 1745 if (_parsedUnitState == CacheState.VALID) { |
| 1757 _parsedUnitState = CacheState.FLUSHED; | 1746 _parsedUnitState = CacheState.FLUSHED; |
| 1758 _parsedUnitAccessed = false; | 1747 _parsedUnitAccessed = false; |
| 1759 _parsedUnit = null; | 1748 _parsedUnit = null; |
| 1760 } | 1749 } |
| 1761 _resolutionState.flushAstStructures(); | 1750 _resolutionState.flushAstStructures(); |
| 1762 } | 1751 } |
| 1763 | 1752 |
| 1764 @override | 1753 @override |
| 1765 List<AnalysisError> get allErrors { | 1754 List<AnalysisError> get allErrors { |
| 1766 List<AnalysisError> errors = new List<AnalysisError>(); | 1755 List<AnalysisError> errors = new List<AnalysisError>(); |
| 1767 ListUtilities.addAll(errors, _scanErrors); | 1756 ListUtilities.addAll(errors, _scanErrors); |
| 1768 ListUtilities.addAll(errors, _parseErrors); | 1757 ListUtilities.addAll(errors, _parseErrors); |
| 1769 DartEntryImpl_ResolutionState state = _resolutionState; | 1758 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1770 while (state != null) { | 1759 while (state != null) { |
| 1771 ListUtilities.addAll(errors, state._resolutionErrors); | 1760 ListUtilities.addAll(errors, state._resolutionErrors); |
| 1772 ListUtilities.addAll(errors, state._verificationErrors); | 1761 ListUtilities.addAll(errors, state._verificationErrors); |
| 1773 ListUtilities.addAll(errors, state._hints); | 1762 ListUtilities.addAll(errors, state._hints); |
| 1774 state = state._nextState; | 1763 state = state._nextState; |
| 1775 } | 1764 } |
| 1776 ListUtilities.addAll(errors, _angularErrors); | 1765 ListUtilities.addAll(errors, _angularErrors); |
| 1777 if (errors.length == 0) { | 1766 if (errors.length == 0) { |
| 1778 return AnalysisError.NO_ERRORS; | 1767 return AnalysisError.NO_ERRORS; |
| 1779 } | 1768 } |
| 1780 return new List.from(errors); | 1769 return new List.from(errors); |
| 1781 } | 1770 } |
| 1782 | 1771 |
| 1783 @override | 1772 @override |
| 1784 CompilationUnit get anyParsedCompilationUnit { | 1773 CompilationUnit get anyParsedCompilationUnit { |
| 1785 if (identical(_parsedUnitState, CacheState.VALID)) { | 1774 if (_parsedUnitState == CacheState.VALID) { |
| 1786 _parsedUnitAccessed = true; | 1775 _parsedUnitAccessed = true; |
| 1787 return _parsedUnit; | 1776 return _parsedUnit; |
| 1788 } | 1777 } |
| 1789 return anyResolvedCompilationUnit; | 1778 return anyResolvedCompilationUnit; |
| 1790 } | 1779 } |
| 1791 | 1780 |
| 1792 @override | 1781 @override |
| 1793 CompilationUnit get anyResolvedCompilationUnit { | 1782 CompilationUnit get anyResolvedCompilationUnit { |
| 1794 DartEntryImpl_ResolutionState state = _resolutionState; | 1783 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1795 while (state != null) { | 1784 while (state != null) { |
| 1796 if (identical(state._resolvedUnitState, CacheState.VALID)) { | 1785 if (state._resolvedUnitState == CacheState.VALID) { |
| 1797 return state._resolvedUnit; | 1786 return state._resolvedUnit; |
| 1798 } | 1787 } |
| 1799 state = state._nextState; | 1788 state = state._nextState; |
| 1800 } | 1789 } |
| 1801 ; | 1790 ; |
| 1802 return null; | 1791 return null; |
| 1803 } | 1792 } |
| 1804 | 1793 |
| 1794 /** |
| 1795 * Return a list containing the libraries that are known to contain this part. |
| 1796 * |
| 1797 * @return a list containing the libraries that are known to contain this part |
| 1798 */ |
| 1799 List<Source> get containingLibraries => _containingLibraries; |
| 1800 |
| 1805 @override | 1801 @override |
| 1806 SourceKind get kind => _sourceKind; | 1802 SourceKind get kind => _sourceKind; |
| 1807 | 1803 |
| 1808 /** | 1804 /** |
| 1809 * Answer an array of library sources containing the receiver's source. | 1805 * Answer an array of library sources containing the receiver's source. |
| 1810 */ | 1806 */ |
| 1811 List<Source> get librariesContaining { | 1807 List<Source> get librariesContaining { |
| 1812 DartEntryImpl_ResolutionState state = _resolutionState; | 1808 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1813 List<Source> result = new List<Source>(); | 1809 List<Source> result = new List<Source>(); |
| 1814 while (state != null) { | 1810 while (state != null) { |
| 1815 if (state._librarySource != null) { | 1811 if (state._librarySource != null) { |
| 1816 result.add(state._librarySource); | 1812 result.add(state._librarySource); |
| 1817 } | 1813 } |
| 1818 state = state._nextState; | 1814 state = state._nextState; |
| 1819 } | 1815 } |
| 1820 return new List.from(result); | 1816 return new List.from(result); |
| 1821 } | 1817 } |
| 1822 | 1818 |
| 1823 /** | 1819 /** |
| 1824 * Return a compilation unit that has not been accessed by any other client an
d can therefore | 1820 * Return a compilation unit that has not been accessed by any other client an
d can therefore |
| 1825 * safely be modified by the reconciler, or `null` if the source has not been
parsed. | 1821 * safely be modified by the reconciler, or `null` if the source has not been
parsed. |
| 1826 * | 1822 * |
| 1827 * @return a compilation unit that can be modified by the reconciler | 1823 * @return a compilation unit that can be modified by the reconciler |
| 1828 */ | 1824 */ |
| 1829 CompilationUnit get resolvableCompilationUnit { | 1825 CompilationUnit get resolvableCompilationUnit { |
| 1830 if (identical(_parsedUnitState, CacheState.VALID)) { | 1826 if (_parsedUnitState == CacheState.VALID) { |
| 1831 if (_parsedUnitAccessed) { | 1827 if (_parsedUnitAccessed) { |
| 1832 return _parsedUnit.accept(new AstCloner()) as CompilationUnit; | 1828 return _parsedUnit.accept(new AstCloner()) as CompilationUnit; |
| 1833 } | 1829 } |
| 1834 CompilationUnit unit = _parsedUnit; | 1830 CompilationUnit unit = _parsedUnit; |
| 1835 _parsedUnitState = CacheState.FLUSHED; | 1831 _parsedUnitState = CacheState.FLUSHED; |
| 1836 _parsedUnitAccessed = false; | 1832 _parsedUnitAccessed = false; |
| 1837 _parsedUnit = null; | 1833 _parsedUnit = null; |
| 1838 return unit; | 1834 return unit; |
| 1839 } | 1835 } |
| 1840 DartEntryImpl_ResolutionState state = _resolutionState; | 1836 DartEntryImpl_ResolutionState state = _resolutionState; |
| 1841 while (state != null) { | 1837 while (state != null) { |
| 1842 if (identical(state._resolvedUnitState, CacheState.VALID)) { | 1838 if (state._resolvedUnitState == CacheState.VALID) { |
| 1843 return state._resolvedUnit.accept(new AstCloner()) as CompilationUnit; | 1839 return state._resolvedUnit.accept(new AstCloner()) as CompilationUnit; |
| 1844 } | 1840 } |
| 1845 state = state._nextState; | 1841 state = state._nextState; |
| 1846 } | 1842 } |
| 1847 ; | 1843 ; |
| 1848 return null; | 1844 return null; |
| 1849 } | 1845 } |
| 1850 | 1846 |
| 1851 @override | 1847 @override |
| 1852 CacheState getState(DataDescriptor descriptor) { | 1848 CacheState getState(DataDescriptor descriptor) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 return new List.from(_containingLibraries); | 1910 return new List.from(_containingLibraries); |
| 1915 } else if (identical(descriptor, DartEntry.ELEMENT)) { | 1911 } else if (identical(descriptor, DartEntry.ELEMENT)) { |
| 1916 return _element; | 1912 return _element; |
| 1917 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 1913 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 1918 return _exportedLibraries; | 1914 return _exportedLibraries; |
| 1919 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | 1915 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 1920 return _importedLibraries; | 1916 return _importedLibraries; |
| 1921 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1917 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 1922 return _includedParts; | 1918 return _includedParts; |
| 1923 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 1919 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 1924 return BooleanArray.get(_bitmask, _CLIENT_CODE_INDEX); | 1920 return getFlag(_CLIENT_CODE_INDEX); |
| 1925 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 1921 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 1926 return BooleanArray.get(_bitmask, _LAUNCHABLE_INDEX); | 1922 return getFlag(_LAUNCHABLE_INDEX); |
| 1927 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 1923 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 1928 return _parseErrors; | 1924 return _parseErrors; |
| 1929 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 1925 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 1930 _parsedUnitAccessed = true; | 1926 _parsedUnitAccessed = true; |
| 1931 return _parsedUnit; | 1927 return _parsedUnit; |
| 1932 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 1928 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 1933 return _publicNamespace; | 1929 return _publicNamespace; |
| 1934 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { | 1930 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { |
| 1935 return _scanErrors; | 1931 return _scanErrors; |
| 1936 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1932 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1973 @override | 1969 @override |
| 1974 DartEntryImpl get writableCopy { | 1970 DartEntryImpl get writableCopy { |
| 1975 DartEntryImpl copy = new DartEntryImpl(); | 1971 DartEntryImpl copy = new DartEntryImpl(); |
| 1976 copy.copyFrom(this); | 1972 copy.copyFrom(this); |
| 1977 return copy; | 1973 return copy; |
| 1978 } | 1974 } |
| 1979 | 1975 |
| 1980 @override | 1976 @override |
| 1981 bool hasInvalidData(DataDescriptor descriptor) { | 1977 bool hasInvalidData(DataDescriptor descriptor) { |
| 1982 if (identical(descriptor, DartEntry.ELEMENT)) { | 1978 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 1983 return identical(_elementState, CacheState.INVALID); | 1979 return _elementState == CacheState.INVALID; |
| 1984 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 1980 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 1985 return identical(_exportedLibrariesState, CacheState.INVALID); | 1981 return _exportedLibrariesState == CacheState.INVALID; |
| 1986 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | 1982 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 1987 return identical(_importedLibrariesState, CacheState.INVALID); | 1983 return _importedLibrariesState == CacheState.INVALID; |
| 1988 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1984 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 1989 return identical(_includedPartsState, CacheState.INVALID); | 1985 return _includedPartsState == CacheState.INVALID; |
| 1990 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 1986 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 1991 return identical(_clientServerState, CacheState.INVALID); | 1987 return _clientServerState == CacheState.INVALID; |
| 1992 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 1988 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 1993 return identical(_launchableState, CacheState.INVALID); | 1989 return _launchableState == CacheState.INVALID; |
| 1994 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 1990 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 1995 return identical(_parseErrorsState, CacheState.INVALID); | 1991 return _parseErrorsState == CacheState.INVALID; |
| 1996 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 1992 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 1997 return identical(_parsedUnitState, CacheState.INVALID); | 1993 return _parsedUnitState == CacheState.INVALID; |
| 1998 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 1994 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 1999 return identical(_publicNamespaceState, CacheState.INVALID); | 1995 return _publicNamespaceState == CacheState.INVALID; |
| 2000 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { | 1996 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { |
| 2001 return identical(_scanErrorsState, CacheState.INVALID); | 1997 return _scanErrorsState == CacheState.INVALID; |
| 2002 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { | 1998 } else if (identical(descriptor, DartEntry.SOURCE_KIND)) { |
| 2003 return identical(_sourceKindState, CacheState.INVALID); | 1999 return _sourceKindState == CacheState.INVALID; |
| 2004 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { | 2000 } else if (identical(descriptor, DartEntry.TOKEN_STREAM)) { |
| 2005 return identical(_tokenStreamState, CacheState.INVALID); | 2001 return _tokenStreamState == CacheState.INVALID; |
| 2006 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(d
escriptor, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICAT
ION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { | 2002 } else if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(d
escriptor, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICAT
ION_ERRORS) || identical(descriptor, DartEntry.HINTS)) { |
| 2007 DartEntryImpl_ResolutionState state = _resolutionState; | 2003 DartEntryImpl_ResolutionState state = _resolutionState; |
| 2008 while (state != null) { | 2004 while (state != null) { |
| 2009 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { | 2005 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS)) { |
| 2010 return identical(state._resolutionErrorsState, CacheState.INVALID); | 2006 return state._resolutionErrorsState == CacheState.INVALID; |
| 2011 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { | 2007 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 2012 return identical(state._resolvedUnitState, CacheState.INVALID); | 2008 return state._resolvedUnitState == CacheState.INVALID; |
| 2013 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { | 2009 } else if (identical(descriptor, DartEntry.VERIFICATION_ERRORS)) { |
| 2014 return identical(state._verificationErrorsState, CacheState.INVALID); | 2010 return state._verificationErrorsState == CacheState.INVALID; |
| 2015 } else if (identical(descriptor, DartEntry.HINTS)) { | 2011 } else if (identical(descriptor, DartEntry.HINTS)) { |
| 2016 return identical(state._hintsState, CacheState.INVALID); | 2012 return state._hintsState == CacheState.INVALID; |
| 2017 } | 2013 } |
| 2018 } | 2014 } |
| 2019 return false; | 2015 return false; |
| 2020 } else { | 2016 } else { |
| 2021 return identical(super.getState(descriptor), CacheState.INVALID); | 2017 return super.getState(descriptor) == CacheState.INVALID; |
| 2022 } | 2018 } |
| 2023 } | 2019 } |
| 2024 | 2020 |
| 2025 @override | 2021 @override |
| 2026 bool get hasResolvableCompilationUnit { | 2022 bool get hasResolvableCompilationUnit { |
| 2027 if (identical(_parsedUnitState, CacheState.VALID)) { | 2023 if (_parsedUnitState == CacheState.VALID) { |
| 2028 return true; | 2024 return true; |
| 2029 } | 2025 } |
| 2030 DartEntryImpl_ResolutionState state = _resolutionState; | 2026 DartEntryImpl_ResolutionState state = _resolutionState; |
| 2031 while (state != null) { | 2027 while (state != null) { |
| 2032 if (identical(state._resolvedUnitState, CacheState.VALID)) { | 2028 if (state._resolvedUnitState == CacheState.VALID) { |
| 2033 return true; | 2029 return true; |
| 2034 } | 2030 } |
| 2035 state = state._nextState; | 2031 state = state._nextState; |
| 2036 } | 2032 } |
| 2037 ; | 2033 ; |
| 2038 return false; | 2034 return false; |
| 2039 } | 2035 } |
| 2040 | 2036 |
| 2041 @override | 2037 @override |
| 2042 void invalidateAllInformation() { | 2038 void invalidateAllInformation() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2058 _exportedLibrariesState = CacheState.INVALID; | 2054 _exportedLibrariesState = CacheState.INVALID; |
| 2059 _includedParts = Source.EMPTY_ARRAY; | 2055 _includedParts = Source.EMPTY_ARRAY; |
| 2060 _includedPartsState = CacheState.INVALID; | 2056 _includedPartsState = CacheState.INVALID; |
| 2061 _discardCachedResolutionInformation(); | 2057 _discardCachedResolutionInformation(); |
| 2062 } | 2058 } |
| 2063 | 2059 |
| 2064 /** | 2060 /** |
| 2065 * Invalidate all of the resolution information associated with the compilatio
n unit. | 2061 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 2066 */ | 2062 */ |
| 2067 void invalidateAllResolutionInformation() { | 2063 void invalidateAllResolutionInformation() { |
| 2068 if (identical(_parsedUnitState, CacheState.FLUSHED)) { | 2064 if (_parsedUnitState == CacheState.FLUSHED) { |
| 2069 DartEntryImpl_ResolutionState state = _resolutionState; | 2065 DartEntryImpl_ResolutionState state = _resolutionState; |
| 2070 while (state != null) { | 2066 while (state != null) { |
| 2071 if (identical(state._resolvedUnitState, CacheState.VALID)) { | 2067 if (state._resolvedUnitState == CacheState.VALID) { |
| 2072 _parsedUnit = state._resolvedUnit; | 2068 _parsedUnit = state._resolvedUnit; |
| 2073 _parsedUnitAccessed = true; | 2069 _parsedUnitAccessed = true; |
| 2074 _parsedUnitState = CacheState.VALID; | 2070 _parsedUnitState = CacheState.VALID; |
| 2075 break; | 2071 break; |
| 2076 } | 2072 } |
| 2077 state = state._nextState; | 2073 state = state._nextState; |
| 2078 } | 2074 } |
| 2079 } | 2075 } |
| 2080 _discardCachedResolutionInformation(); | 2076 _discardCachedResolutionInformation(); |
| 2081 } | 2077 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 if (_includedPartsState != CacheState.VALID) { | 2140 if (_includedPartsState != CacheState.VALID) { |
| 2145 _includedPartsState = CacheState.IN_PROCESS; | 2141 _includedPartsState = CacheState.IN_PROCESS; |
| 2146 } | 2142 } |
| 2147 } | 2143 } |
| 2148 | 2144 |
| 2149 /** | 2145 /** |
| 2150 * Record that an in-process parse has stopped without recording results becau
se the results were | 2146 * Record that an in-process parse has stopped without recording results becau
se the results were |
| 2151 * invalidated before they could be recorded. | 2147 * invalidated before they could be recorded. |
| 2152 */ | 2148 */ |
| 2153 void recordParseNotInProcess() { | 2149 void recordParseNotInProcess() { |
| 2154 if (identical(getState(SourceEntry.LINE_INFO), CacheState.IN_PROCESS)) { | 2150 if (getState(SourceEntry.LINE_INFO) == CacheState.IN_PROCESS) { |
| 2155 setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 2151 setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 2156 } | 2152 } |
| 2157 if (identical(_sourceKindState, CacheState.IN_PROCESS)) { | 2153 if (_sourceKindState == CacheState.IN_PROCESS) { |
| 2158 _sourceKindState = CacheState.INVALID; | 2154 _sourceKindState = CacheState.INVALID; |
| 2159 } | 2155 } |
| 2160 if (identical(_parseErrorsState, CacheState.IN_PROCESS)) { | 2156 if (_parseErrorsState == CacheState.IN_PROCESS) { |
| 2161 _parseErrorsState = CacheState.INVALID; | 2157 _parseErrorsState = CacheState.INVALID; |
| 2162 } | 2158 } |
| 2163 if (identical(_parsedUnitState, CacheState.IN_PROCESS)) { | 2159 if (_parsedUnitState == CacheState.IN_PROCESS) { |
| 2164 _parsedUnitState = CacheState.INVALID; | 2160 _parsedUnitState = CacheState.INVALID; |
| 2165 } | 2161 } |
| 2166 if (identical(_exportedLibrariesState, CacheState.IN_PROCESS)) { | 2162 if (_exportedLibrariesState == CacheState.IN_PROCESS) { |
| 2167 _exportedLibrariesState = CacheState.INVALID; | 2163 _exportedLibrariesState = CacheState.INVALID; |
| 2168 } | 2164 } |
| 2169 if (identical(_importedLibrariesState, CacheState.IN_PROCESS)) { | 2165 if (_importedLibrariesState == CacheState.IN_PROCESS) { |
| 2170 _importedLibrariesState = CacheState.INVALID; | 2166 _importedLibrariesState = CacheState.INVALID; |
| 2171 } | 2167 } |
| 2172 if (identical(_includedPartsState, CacheState.IN_PROCESS)) { | 2168 if (_includedPartsState == CacheState.IN_PROCESS) { |
| 2173 _includedPartsState = CacheState.INVALID; | 2169 _includedPartsState = CacheState.INVALID; |
| 2174 } | 2170 } |
| 2175 } | 2171 } |
| 2176 | 2172 |
| 2177 /** | 2173 /** |
| 2178 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this | 2174 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
| 2179 * entry. This will set the state of all resolution-based information as being
in error, but will | 2175 * entry. This will set the state of all resolution-based information as being
in error, but will |
| 2180 * not change the state of any parse results. | 2176 * not change the state of any parse results. |
| 2181 */ | 2177 */ |
| 2182 void recordResolutionError() { | 2178 void recordResolutionError() { |
| 2183 _element = null; | 2179 _element = null; |
| 2184 _elementState = CacheState.ERROR; | 2180 _elementState = CacheState.ERROR; |
| 2185 _bitmask = 0; | 2181 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]); |
| 2186 _clientServerState = CacheState.ERROR; | 2182 _clientServerState = CacheState.ERROR; |
| 2187 _launchableState = CacheState.ERROR; | 2183 _launchableState = CacheState.ERROR; |
| 2188 _publicNamespace = null; | 2184 _publicNamespace = null; |
| 2189 _publicNamespaceState = CacheState.ERROR; | 2185 _publicNamespaceState = CacheState.ERROR; |
| 2190 _resolutionState.recordResolutionError(); | 2186 _resolutionState.recordResolutionError(); |
| 2191 } | 2187 } |
| 2192 | 2188 |
| 2193 /** | 2189 /** |
| 2194 * Record that an in-process parse has stopped without recording results becau
se the results were | 2190 * Record that an in-process parse has stopped without recording results becau
se the results were |
| 2195 * invalidated before they could be recorded. | 2191 * invalidated before they could be recorded. |
| 2196 */ | 2192 */ |
| 2197 void recordResolutionNotInProcess() { | 2193 void recordResolutionNotInProcess() { |
| 2198 if (identical(_elementState, CacheState.IN_PROCESS)) { | 2194 if (_elementState == CacheState.IN_PROCESS) { |
| 2199 _elementState = CacheState.INVALID; | 2195 _elementState = CacheState.INVALID; |
| 2200 } | 2196 } |
| 2201 if (identical(_clientServerState, CacheState.IN_PROCESS)) { | 2197 if (_clientServerState == CacheState.IN_PROCESS) { |
| 2202 _clientServerState = CacheState.INVALID; | 2198 _clientServerState = CacheState.INVALID; |
| 2203 } | 2199 } |
| 2204 if (identical(_launchableState, CacheState.IN_PROCESS)) { | 2200 if (_launchableState == CacheState.IN_PROCESS) { |
| 2205 _launchableState = CacheState.INVALID; | 2201 _launchableState = CacheState.INVALID; |
| 2206 } | 2202 } |
| 2207 if (identical(_publicNamespaceState, CacheState.IN_PROCESS)) { | 2203 if (_publicNamespaceState == CacheState.IN_PROCESS) { |
| 2208 _publicNamespaceState = CacheState.INVALID; | 2204 _publicNamespaceState = CacheState.INVALID; |
| 2209 } | 2205 } |
| 2210 _resolutionState.recordResolutionNotInProcess(); | 2206 _resolutionState.recordResolutionNotInProcess(); |
| 2211 } | 2207 } |
| 2212 | 2208 |
| 2213 /** | 2209 /** |
| 2214 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this | 2210 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
| 2215 * entry. This will set the state of all information, including any resolution
-based information, | 2211 * entry. This will set the state of all information, including any resolution
-based information, |
| 2216 * as being in error. | 2212 * as being in error. |
| 2217 */ | 2213 */ |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2238 if (_tokenStreamState != CacheState.VALID) { | 2234 if (_tokenStreamState != CacheState.VALID) { |
| 2239 _tokenStreamState = CacheState.IN_PROCESS; | 2235 _tokenStreamState = CacheState.IN_PROCESS; |
| 2240 } | 2236 } |
| 2241 } | 2237 } |
| 2242 | 2238 |
| 2243 /** | 2239 /** |
| 2244 * Record that an in-process scan has stopped without recording results becaus
e the results were | 2240 * Record that an in-process scan has stopped without recording results becaus
e the results were |
| 2245 * invalidated before they could be recorded. | 2241 * invalidated before they could be recorded. |
| 2246 */ | 2242 */ |
| 2247 void recordScanNotInProcess() { | 2243 void recordScanNotInProcess() { |
| 2248 if (identical(getState(SourceEntry.LINE_INFO), CacheState.IN_PROCESS)) { | 2244 if (getState(SourceEntry.LINE_INFO) == CacheState.IN_PROCESS) { |
| 2249 setState(SourceEntry.LINE_INFO, CacheState.INVALID); | 2245 setState(SourceEntry.LINE_INFO, CacheState.INVALID); |
| 2250 } | 2246 } |
| 2251 if (identical(_scanErrorsState, CacheState.IN_PROCESS)) { | 2247 if (_scanErrorsState == CacheState.IN_PROCESS) { |
| 2252 _scanErrorsState = CacheState.INVALID; | 2248 _scanErrorsState = CacheState.INVALID; |
| 2253 } | 2249 } |
| 2254 if (identical(_tokenStreamState, CacheState.IN_PROCESS)) { | 2250 if (_tokenStreamState == CacheState.IN_PROCESS) { |
| 2255 _tokenStreamState = CacheState.INVALID; | 2251 _tokenStreamState = CacheState.INVALID; |
| 2256 } | 2252 } |
| 2257 } | 2253 } |
| 2258 | 2254 |
| 2259 /** | 2255 /** |
| 2260 * Remove the given library from the list of libraries that contain this part.
This method should | 2256 * Remove the given library from the list of libraries that contain this part.
This method should |
| 2261 * only be invoked on entries that represent a part. | 2257 * only be invoked on entries that represent a part. |
| 2262 * | 2258 * |
| 2263 * @param librarySource the source of the library to be removed | 2259 * @param librarySource the source of the library to be removed |
| 2264 */ | 2260 */ |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2315 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 2311 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 2316 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_
ARRAY); | 2312 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_
ARRAY); |
| 2317 _exportedLibrariesState = state; | 2313 _exportedLibrariesState = state; |
| 2318 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | 2314 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 2319 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_
ARRAY); | 2315 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_
ARRAY); |
| 2320 _importedLibrariesState = state; | 2316 _importedLibrariesState = state; |
| 2321 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 2317 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 2322 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); | 2318 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); |
| 2323 _includedPartsState = state; | 2319 _includedPartsState = state; |
| 2324 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 2320 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 2325 _bitmask = _updatedValueOfFlag(state, _bitmask, _CLIENT_CODE_INDEX); | 2321 _updateValueOfFlag(_CLIENT_CODE_INDEX, state); |
| 2326 _clientServerState = state; | 2322 _clientServerState = state; |
| 2327 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 2323 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 2328 _bitmask = _updatedValueOfFlag(state, _bitmask, _LAUNCHABLE_INDEX); | 2324 _updateValueOfFlag(_LAUNCHABLE_INDEX, state); |
| 2329 _launchableState = state; | 2325 _launchableState = state; |
| 2330 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 2326 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 2331 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); | 2327 _parseErrors = updatedValue(state, _parseErrors, AnalysisError.NO_ERRORS); |
| 2332 _parseErrorsState = state; | 2328 _parseErrorsState = state; |
| 2333 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 2329 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 2334 CompilationUnit newUnit = updatedValue(state, _parsedUnit, null); | 2330 CompilationUnit newUnit = updatedValue(state, _parsedUnit, null); |
| 2335 if (newUnit != _parsedUnit) { | 2331 if (!identical(newUnit, _parsedUnit)) { |
| 2336 _parsedUnitAccessed = false; | 2332 _parsedUnitAccessed = false; |
| 2337 } | 2333 } |
| 2338 _parsedUnit = newUnit; | 2334 _parsedUnit = newUnit; |
| 2339 _parsedUnitState = state; | 2335 _parsedUnitState = state; |
| 2340 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 2336 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 2341 _publicNamespace = updatedValue(state, _publicNamespace, null); | 2337 _publicNamespace = updatedValue(state, _publicNamespace, null); |
| 2342 _publicNamespaceState = state; | 2338 _publicNamespaceState = state; |
| 2343 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { | 2339 } else if (identical(descriptor, DartEntry.SCAN_ERRORS)) { |
| 2344 _scanErrors = updatedValue(state, _scanErrors, AnalysisError.NO_ERRORS); | 2340 _scanErrors = updatedValue(state, _scanErrors, AnalysisError.NO_ERRORS); |
| 2345 _scanErrorsState = state; | 2341 _scanErrorsState = state; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2392 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 2388 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 2393 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); | 2389 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); |
| 2394 _exportedLibrariesState = CacheState.VALID; | 2390 _exportedLibrariesState = CacheState.VALID; |
| 2395 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | 2391 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 2396 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); | 2392 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); |
| 2397 _importedLibrariesState = CacheState.VALID; | 2393 _importedLibrariesState = CacheState.VALID; |
| 2398 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 2394 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 2399 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); | 2395 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); |
| 2400 _includedPartsState = CacheState.VALID; | 2396 _includedPartsState = CacheState.VALID; |
| 2401 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 2397 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 2402 _bitmask = BooleanArray.set(_bitmask, _CLIENT_CODE_INDEX, value as bool); | 2398 setFlag(_CLIENT_CODE_INDEX, value as bool); |
| 2403 _clientServerState = CacheState.VALID; | 2399 _clientServerState = CacheState.VALID; |
| 2404 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 2400 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| 2405 _bitmask = BooleanArray.set(_bitmask, _LAUNCHABLE_INDEX, value as bool); | 2401 setFlag(_LAUNCHABLE_INDEX, value as bool); |
| 2406 _launchableState = CacheState.VALID; | 2402 _launchableState = CacheState.VALID; |
| 2407 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { | 2403 } else if (identical(descriptor, DartEntry.PARSE_ERRORS)) { |
| 2408 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); | 2404 _parseErrors = value == null ? AnalysisError.NO_ERRORS : (value as List<An
alysisError>); |
| 2409 _parseErrorsState = CacheState.VALID; | 2405 _parseErrorsState = CacheState.VALID; |
| 2410 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 2406 } else if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 2411 _parsedUnit = value as CompilationUnit; | 2407 _parsedUnit = value as CompilationUnit; |
| 2412 _parsedUnitAccessed = false; | 2408 _parsedUnitAccessed = false; |
| 2413 _parsedUnitState = CacheState.VALID; | 2409 _parsedUnitState = CacheState.VALID; |
| 2414 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { | 2410 } else if (identical(descriptor, DartEntry.PUBLIC_NAMESPACE)) { |
| 2415 _publicNamespace = value as Namespace; | 2411 _publicNamespace = value as Namespace; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 _importedLibrariesState = other._importedLibrariesState; | 2472 _importedLibrariesState = other._importedLibrariesState; |
| 2477 _importedLibraries = other._importedLibraries; | 2473 _importedLibraries = other._importedLibraries; |
| 2478 _containingLibraries = new List<Source>.from(other._containingLibraries); | 2474 _containingLibraries = new List<Source>.from(other._containingLibraries); |
| 2479 _resolutionState.copyFrom(other._resolutionState); | 2475 _resolutionState.copyFrom(other._resolutionState); |
| 2480 _elementState = other._elementState; | 2476 _elementState = other._elementState; |
| 2481 _element = other._element; | 2477 _element = other._element; |
| 2482 _publicNamespaceState = other._publicNamespaceState; | 2478 _publicNamespaceState = other._publicNamespaceState; |
| 2483 _publicNamespace = other._publicNamespace; | 2479 _publicNamespace = other._publicNamespace; |
| 2484 _clientServerState = other._clientServerState; | 2480 _clientServerState = other._clientServerState; |
| 2485 _launchableState = other._launchableState; | 2481 _launchableState = other._launchableState; |
| 2486 _bitmask = other._bitmask; | |
| 2487 _angularErrors = other._angularErrors; | 2482 _angularErrors = other._angularErrors; |
| 2488 } | 2483 } |
| 2489 | 2484 |
| 2490 @override | 2485 @override |
| 2491 bool get hasErrorState => super.hasErrorState || identical(_scanErrorsState, C
acheState.ERROR) || identical(_tokenStreamState, CacheState.ERROR) || identical(
_sourceKindState, CacheState.ERROR) || identical(_parsedUnitState, CacheState.ER
ROR) || identical(_parseErrorsState, CacheState.ERROR) || identical(_importedLib
rariesState, CacheState.ERROR) || identical(_exportedLibrariesState, CacheState.
ERROR) || identical(_includedPartsState, CacheState.ERROR) || identical(_element
State, CacheState.ERROR) || identical(_publicNamespaceState, CacheState.ERROR) |
| identical(_clientServerState, CacheState.ERROR) || identical(_launchableState,
CacheState.ERROR) || _resolutionState.hasErrorState; | 2486 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; |
| 2492 | 2487 |
| 2493 @override | 2488 @override |
| 2494 void writeOn(JavaStringBuilder builder) { | 2489 void writeOn(JavaStringBuilder builder) { |
| 2495 builder.append("Dart: "); | 2490 builder.append("Dart: "); |
| 2496 super.writeOn(builder); | 2491 super.writeOn(builder); |
| 2497 builder.append("; tokenStream = "); | 2492 builder.append("; tokenStream = "); |
| 2498 builder.append(_tokenStreamState); | 2493 builder.append(_tokenStreamState); |
| 2499 builder.append("; scanErrors = "); | 2494 builder.append("; scanErrors = "); |
| 2500 builder.append(_scanErrorsState); | 2495 builder.append(_scanErrorsState); |
| 2501 builder.append("; sourceKind = "); | 2496 builder.append("; sourceKind = "); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2523 // builder.append("; angularElements = "); | 2518 // builder.append("; angularElements = "); |
| 2524 _resolutionState.writeOn(builder); | 2519 _resolutionState.writeOn(builder); |
| 2525 } | 2520 } |
| 2526 | 2521 |
| 2527 /** | 2522 /** |
| 2528 * Invalidate all of the resolution information associated with the compilatio
n unit. | 2523 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 2529 */ | 2524 */ |
| 2530 void _discardCachedResolutionInformation() { | 2525 void _discardCachedResolutionInformation() { |
| 2531 _element = null; | 2526 _element = null; |
| 2532 _elementState = CacheState.INVALID; | 2527 _elementState = CacheState.INVALID; |
| 2533 _bitmask = 0; | 2528 clearFlags([_LAUNCHABLE_INDEX, _CLIENT_CODE_INDEX]); |
| 2534 _clientServerState = CacheState.INVALID; | 2529 _clientServerState = CacheState.INVALID; |
| 2535 _launchableState = CacheState.INVALID; | 2530 _launchableState = CacheState.INVALID; |
| 2536 _publicNamespace = null; | 2531 _publicNamespace = null; |
| 2537 _publicNamespaceState = CacheState.INVALID; | 2532 _publicNamespaceState = CacheState.INVALID; |
| 2538 _resolutionState.invalidateAllResolutionInformation(); | 2533 _resolutionState.invalidateAllResolutionInformation(); |
| 2539 } | 2534 } |
| 2540 | 2535 |
| 2541 /** | 2536 /** |
| 2542 * Return a resolution state for the specified library, creating one as necess
ary. | 2537 * Return a resolution state for the specified library, creating one as necess
ary. |
| 2543 * | 2538 * |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2556 newState._librarySource = librarySource; | 2551 newState._librarySource = librarySource; |
| 2557 state._nextState = newState; | 2552 state._nextState = newState; |
| 2558 return newState; | 2553 return newState; |
| 2559 } | 2554 } |
| 2560 state = state._nextState; | 2555 state = state._nextState; |
| 2561 } | 2556 } |
| 2562 return state; | 2557 return state; |
| 2563 } | 2558 } |
| 2564 | 2559 |
| 2565 /** | 2560 /** |
| 2566 * Given that one of the flags is being transitioned to the given state, retur
n the value of the | 2561 * Given that the specified flag is being transitioned to the given state, set
the value of the |
| 2567 * flags that should be kept in the cache. | 2562 * flag to the value that should be kept in the cache. |
| 2568 * | 2563 * |
| 2569 * @param state the state to which the data is being transitioned | 2564 * @param index the index of the flag whose state is being set |
| 2570 * @param currentValue the value of the flags before the transition | 2565 * @param state the state to which the value is being transitioned |
| 2571 * @param bitMask the mask used to access the bit whose state is being set | |
| 2572 * @return the value of the data that should be kept in the cache | |
| 2573 */ | 2566 */ |
| 2574 int _updatedValueOfFlag(CacheState state, int currentValue, int bitIndex) { | 2567 void _updateValueOfFlag(int index, CacheState state) { |
| 2575 if (identical(state, CacheState.VALID)) { | 2568 if (state == CacheState.VALID) { |
| 2576 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 2569 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 2577 } else if (identical(state, CacheState.IN_PROCESS)) { | 2570 } else if (state != CacheState.IN_PROCESS) { |
| 2578 // | 2571 // |
| 2579 // We can leave the current value in the cache for any 'get' methods to ac
cess. | 2572 // If the value is in process, we can leave the current value in the cache
for any 'get' |
| 2573 // methods to access. |
| 2580 // | 2574 // |
| 2581 return currentValue; | 2575 setFlag(index, false); |
| 2582 } | 2576 } |
| 2583 return BooleanArray.set(currentValue, bitIndex, false); | |
| 2584 } | 2577 } |
| 2585 } | 2578 } |
| 2586 | 2579 |
| 2587 /** | 2580 /** |
| 2588 * Instances of the class `ResolutionState` represent the information produced b
y resolving | 2581 * Instances of the class `ResolutionState` represent the information produced b
y resolving |
| 2589 * a compilation unit as part of a specific library. | 2582 * a compilation unit as part of a specific library. |
| 2590 */ | 2583 */ |
| 2591 class DartEntryImpl_ResolutionState { | 2584 class DartEntryImpl_ResolutionState { |
| 2592 /** | 2585 /** |
| 2593 * The next resolution state or `null` if none. | 2586 * The next resolution state or `null` if none. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2664 if (other._nextState != null) { | 2657 if (other._nextState != null) { |
| 2665 _nextState = new DartEntryImpl_ResolutionState(); | 2658 _nextState = new DartEntryImpl_ResolutionState(); |
| 2666 _nextState.copyFrom(other._nextState); | 2659 _nextState.copyFrom(other._nextState); |
| 2667 } | 2660 } |
| 2668 } | 2661 } |
| 2669 | 2662 |
| 2670 /** | 2663 /** |
| 2671 * Flush any AST structures being maintained by this state. | 2664 * Flush any AST structures being maintained by this state. |
| 2672 */ | 2665 */ |
| 2673 void flushAstStructures() { | 2666 void flushAstStructures() { |
| 2674 if (identical(_resolvedUnitState, CacheState.VALID)) { | 2667 if (_resolvedUnitState == CacheState.VALID) { |
| 2675 _resolvedUnitState = CacheState.FLUSHED; | 2668 _resolvedUnitState = CacheState.FLUSHED; |
| 2676 _resolvedUnit = null; | 2669 _resolvedUnit = null; |
| 2677 } | 2670 } |
| 2678 if (_nextState != null) { | 2671 if (_nextState != null) { |
| 2679 _nextState.flushAstStructures(); | 2672 _nextState.flushAstStructures(); |
| 2680 } | 2673 } |
| 2681 } | 2674 } |
| 2682 | 2675 |
| 2683 bool get hasErrorState => identical(_resolvedUnitState, CacheState.ERROR) || i
dentical(_resolutionErrorsState, CacheState.ERROR) || identical(_verificationErr
orsState, CacheState.ERROR) || identical(_hintsState, CacheState.ERROR) || (_nex
tState != null && _nextState.hasErrorState); | 2676 bool get hasErrorState => _resolvedUnitState == CacheState.ERROR || _resolutio
nErrorsState == CacheState.ERROR || _verificationErrorsState == CacheState.ERROR
|| _hintsState == CacheState.ERROR || (_nextState != null && _nextState.hasErro
rState); |
| 2684 | 2677 |
| 2685 /** | 2678 /** |
| 2686 * Invalidate all of the resolution information associated with the compilatio
n unit. | 2679 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 2687 */ | 2680 */ |
| 2688 void invalidateAllResolutionInformation() { | 2681 void invalidateAllResolutionInformation() { |
| 2689 _nextState = null; | 2682 _nextState = null; |
| 2690 _librarySource = null; | 2683 _librarySource = null; |
| 2691 _resolvedUnitState = CacheState.INVALID; | 2684 _resolvedUnitState = CacheState.INVALID; |
| 2692 _resolvedUnit = null; | 2685 _resolvedUnit = null; |
| 2693 _resolutionErrorsState = CacheState.INVALID; | 2686 _resolutionErrorsState = CacheState.INVALID; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2715 if (_nextState != null) { | 2708 if (_nextState != null) { |
| 2716 _nextState.recordResolutionError(); | 2709 _nextState.recordResolutionError(); |
| 2717 } | 2710 } |
| 2718 } | 2711 } |
| 2719 | 2712 |
| 2720 /** | 2713 /** |
| 2721 * Record that an in-process parse has stopped without recording results becau
se the results | 2714 * Record that an in-process parse has stopped without recording results becau
se the results |
| 2722 * were invalidated before they could be recorded. | 2715 * were invalidated before they could be recorded. |
| 2723 */ | 2716 */ |
| 2724 void recordResolutionNotInProcess() { | 2717 void recordResolutionNotInProcess() { |
| 2725 if (identical(_resolvedUnitState, CacheState.IN_PROCESS)) { | 2718 if (_resolvedUnitState == CacheState.IN_PROCESS) { |
| 2726 _resolvedUnitState = CacheState.INVALID; | 2719 _resolvedUnitState = CacheState.INVALID; |
| 2727 } | 2720 } |
| 2728 if (identical(_resolutionErrorsState, CacheState.IN_PROCESS)) { | 2721 if (_resolutionErrorsState == CacheState.IN_PROCESS) { |
| 2729 _resolutionErrorsState = CacheState.INVALID; | 2722 _resolutionErrorsState = CacheState.INVALID; |
| 2730 } | 2723 } |
| 2731 if (identical(_verificationErrorsState, CacheState.IN_PROCESS)) { | 2724 if (_verificationErrorsState == CacheState.IN_PROCESS) { |
| 2732 _verificationErrorsState = CacheState.INVALID; | 2725 _verificationErrorsState = CacheState.INVALID; |
| 2733 } | 2726 } |
| 2734 if (identical(_hintsState, CacheState.IN_PROCESS)) { | 2727 if (_hintsState == CacheState.IN_PROCESS) { |
| 2735 _hintsState = CacheState.INVALID; | 2728 _hintsState = CacheState.INVALID; |
| 2736 } | 2729 } |
| 2737 if (_nextState != null) { | 2730 if (_nextState != null) { |
| 2738 _nextState.recordResolutionNotInProcess(); | 2731 _nextState.recordResolutionNotInProcess(); |
| 2739 } | 2732 } |
| 2740 } | 2733 } |
| 2741 | 2734 |
| 2742 /** | 2735 /** |
| 2743 * Write a textual representation of this state to the given builder. The resu
lt will only be | 2736 * Write a textual representation of this state to the given builder. The resu
lt will only be |
| 2744 * used for debugging purposes. | 2737 * used for debugging purposes. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2763 } | 2756 } |
| 2764 | 2757 |
| 2765 /** | 2758 /** |
| 2766 * Instances of the class `DataDescriptor` are immutable constants representing
data that can | 2759 * Instances of the class `DataDescriptor` are immutable constants representing
data that can |
| 2767 * be stored in the cache. | 2760 * be stored in the cache. |
| 2768 */ | 2761 */ |
| 2769 class DataDescriptor<E> { | 2762 class DataDescriptor<E> { |
| 2770 /** | 2763 /** |
| 2771 * The name of the descriptor, used for debugging purposes. | 2764 * The name of the descriptor, used for debugging purposes. |
| 2772 */ | 2765 */ |
| 2773 String _name; | 2766 final String _name; |
| 2774 | 2767 |
| 2775 /** | 2768 /** |
| 2776 * Initialize a newly created descriptor to have the given name. | 2769 * Initialize a newly created descriptor to have the given name. |
| 2777 * | 2770 * |
| 2778 * @param name the name of the descriptor | 2771 * @param name the name of the descriptor |
| 2779 */ | 2772 */ |
| 2780 DataDescriptor(String name) { | 2773 DataDescriptor(this._name); |
| 2781 this._name = name; | |
| 2782 } | |
| 2783 | 2774 |
| 2784 @override | 2775 @override |
| 2785 String toString() => _name; | 2776 String toString() => _name; |
| 2786 } | 2777 } |
| 2787 | 2778 |
| 2788 /** | 2779 /** |
| 2789 * The interface `HtmlEntry` defines the behavior of objects that maintain the i
nformation | 2780 * The interface `HtmlEntry` defines the behavior of objects that maintain the i
nformation |
| 2790 * cached by an analysis context about an individual HTML file. | 2781 * cached by an analysis context about an individual HTML file. |
| 2791 */ | 2782 */ |
| 2792 abstract class HtmlEntry implements SourceEntry { | 2783 abstract class HtmlEntry implements SourceEntry { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2983 /** | 2974 /** |
| 2984 * The hints produced while auditing the compilation unit, or an empty array i
f the hints are not | 2975 * The hints produced while auditing the compilation unit, or an empty array i
f the hints are not |
| 2985 * currently cached. | 2976 * currently cached. |
| 2986 */ | 2977 */ |
| 2987 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; | 2978 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; |
| 2988 | 2979 |
| 2989 /** | 2980 /** |
| 2990 * Flush any AST structures being maintained by this entry. | 2981 * Flush any AST structures being maintained by this entry. |
| 2991 */ | 2982 */ |
| 2992 void flushAstStructures() { | 2983 void flushAstStructures() { |
| 2993 if (identical(_parsedUnitState, CacheState.VALID)) { | 2984 if (_parsedUnitState == CacheState.VALID) { |
| 2994 _parsedUnitState = CacheState.FLUSHED; | 2985 _parsedUnitState = CacheState.FLUSHED; |
| 2995 _parsedUnit = null; | 2986 _parsedUnit = null; |
| 2996 } | 2987 } |
| 2997 if (identical(_resolvedUnitState, CacheState.VALID)) { | 2988 if (_resolvedUnitState == CacheState.VALID) { |
| 2998 _resolvedUnitState = CacheState.FLUSHED; | 2989 _resolvedUnitState = CacheState.FLUSHED; |
| 2999 _resolvedUnit = null; | 2990 _resolvedUnit = null; |
| 3000 } | 2991 } |
| 3001 if (identical(_angularEntryState, CacheState.VALID)) { | 2992 if (_angularEntryState == CacheState.VALID) { |
| 3002 _angularEntryState = CacheState.FLUSHED; | 2993 _angularEntryState = CacheState.FLUSHED; |
| 3003 } | 2994 } |
| 3004 if (identical(_angularErrorsState, CacheState.VALID)) { | 2995 if (_angularErrorsState == CacheState.VALID) { |
| 3005 _angularErrorsState = CacheState.FLUSHED; | 2996 _angularErrorsState = CacheState.FLUSHED; |
| 3006 } | 2997 } |
| 3007 } | 2998 } |
| 3008 | 2999 |
| 3009 @override | 3000 @override |
| 3010 List<AnalysisError> get allErrors { | 3001 List<AnalysisError> get allErrors { |
| 3011 List<AnalysisError> errors = new List<AnalysisError>(); | 3002 List<AnalysisError> errors = new List<AnalysisError>(); |
| 3012 if (_parseErrors != null) { | 3003 if (_parseErrors != null) { |
| 3013 for (AnalysisError error in _parseErrors) { | 3004 for (AnalysisError error in _parseErrors) { |
| 3014 errors.add(error); | 3005 errors.add(error); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3030 } | 3021 } |
| 3031 } | 3022 } |
| 3032 if (errors.length == 0) { | 3023 if (errors.length == 0) { |
| 3033 return AnalysisError.NO_ERRORS; | 3024 return AnalysisError.NO_ERRORS; |
| 3034 } | 3025 } |
| 3035 return new List.from(errors); | 3026 return new List.from(errors); |
| 3036 } | 3027 } |
| 3037 | 3028 |
| 3038 @override | 3029 @override |
| 3039 ht.HtmlUnit get anyParsedUnit { | 3030 ht.HtmlUnit get anyParsedUnit { |
| 3040 if (identical(_parsedUnitState, CacheState.VALID)) { | 3031 if (_parsedUnitState == CacheState.VALID) { |
| 3041 // parsedUnitAccessed = true; | 3032 // parsedUnitAccessed = true; |
| 3042 return _parsedUnit; | 3033 return _parsedUnit; |
| 3043 } | 3034 } |
| 3044 if (identical(_resolvedUnitState, CacheState.VALID)) { | 3035 if (_resolvedUnitState == CacheState.VALID) { |
| 3045 // resovledUnitAccessed = true; | 3036 // resovledUnitAccessed = true; |
| 3046 return _resolvedUnit; | 3037 return _resolvedUnit; |
| 3047 } | 3038 } |
| 3048 return null; | 3039 return null; |
| 3049 } | 3040 } |
| 3050 | 3041 |
| 3051 @override | 3042 @override |
| 3052 SourceKind get kind => SourceKind.HTML; | 3043 SourceKind get kind => SourceKind.HTML; |
| 3053 | 3044 |
| 3054 @override | 3045 @override |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3276 _referencedLibraries = other._referencedLibraries; | 3267 _referencedLibraries = other._referencedLibraries; |
| 3277 _resolutionErrors = other._resolutionErrors; | 3268 _resolutionErrors = other._resolutionErrors; |
| 3278 _resolutionErrorsState = other._resolutionErrorsState; | 3269 _resolutionErrorsState = other._resolutionErrorsState; |
| 3279 _elementState = other._elementState; | 3270 _elementState = other._elementState; |
| 3280 _element = other._element; | 3271 _element = other._element; |
| 3281 _hints = other._hints; | 3272 _hints = other._hints; |
| 3282 _hintsState = other._hintsState; | 3273 _hintsState = other._hintsState; |
| 3283 } | 3274 } |
| 3284 | 3275 |
| 3285 @override | 3276 @override |
| 3286 bool get hasErrorState => super.hasErrorState || identical(_parsedUnitState, C
acheState.ERROR) || identical(_resolvedUnitState, CacheState.ERROR) || identical
(_parseErrorsState, CacheState.ERROR) || identical(_resolutionErrorsState, Cache
State.ERROR) || identical(_referencedLibrariesState, CacheState.ERROR) || identi
cal(_elementState, CacheState.ERROR) || identical(_angularErrorsState, CacheStat
e.ERROR) || identical(_hintsState, CacheState.ERROR); | 3277 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; |
| 3287 | 3278 |
| 3288 @override | 3279 @override |
| 3289 void writeOn(JavaStringBuilder builder) { | 3280 void writeOn(JavaStringBuilder builder) { |
| 3290 builder.append("Html: "); | 3281 builder.append("Html: "); |
| 3291 super.writeOn(builder); | 3282 super.writeOn(builder); |
| 3292 builder.append("; parseErrors = "); | 3283 builder.append("; parseErrors = "); |
| 3293 builder.append(_parseErrorsState); | 3284 builder.append(_parseErrorsState); |
| 3294 builder.append("; parsedUnit = "); | 3285 builder.append("; parsedUnit = "); |
| 3295 builder.append(_parsedUnitState); | 3286 builder.append(_parsedUnitState); |
| 3296 builder.append("; resolvedUnit = "); | 3287 builder.append("; resolvedUnit = "); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3314 | 3305 |
| 3315 /** | 3306 /** |
| 3316 * The enumerated type `RetentionPriority` represents the priority of data in th
e cache in | 3307 * The enumerated type `RetentionPriority` represents the priority of data in th
e cache in |
| 3317 * terms of the desirability of retaining some specified data about a specified
source. | 3308 * terms of the desirability of retaining some specified data about a specified
source. |
| 3318 */ | 3309 */ |
| 3319 class RetentionPriority extends Enum<RetentionPriority> { | 3310 class RetentionPriority extends Enum<RetentionPriority> { |
| 3320 /** | 3311 /** |
| 3321 * A priority indicating that a given piece of data can be removed from the ca
che without | 3312 * A priority indicating that a given piece of data can be removed from the ca
che without |
| 3322 * reservation. | 3313 * reservation. |
| 3323 */ | 3314 */ |
| 3324 static final RetentionPriority LOW = new RetentionPriority('LOW', 0); | 3315 static const RetentionPriority LOW = const RetentionPriority('LOW', 0); |
| 3325 | 3316 |
| 3326 /** | 3317 /** |
| 3327 * A priority indicating that a given piece of data should not be removed from
the cache unless | 3318 * A priority indicating that a given piece of data should not be removed from
the cache unless |
| 3328 * there are no sources for which the corresponding data has a lower priority.
Currently used for | 3319 * there are no sources for which the corresponding data has a lower priority.
Currently used for |
| 3329 * data that is needed in order to finish some outstanding analysis task. | 3320 * data that is needed in order to finish some outstanding analysis task. |
| 3330 */ | 3321 */ |
| 3331 static final RetentionPriority MEDIUM = new RetentionPriority('MEDIUM', 1); | 3322 static const RetentionPriority MEDIUM = const RetentionPriority('MEDIUM', 1); |
| 3332 | 3323 |
| 3333 /** | 3324 /** |
| 3334 * A priority indicating that a given piece of data should not be removed from
the cache. | 3325 * A priority indicating that a given piece of data should not be removed from
the cache. |
| 3335 * Currently used for data related to a priority source. | 3326 * Currently used for data related to a priority source. |
| 3336 */ | 3327 */ |
| 3337 static final RetentionPriority HIGH = new RetentionPriority('HIGH', 2); | 3328 static const RetentionPriority HIGH = const RetentionPriority('HIGH', 2); |
| 3338 | 3329 |
| 3339 static final List<RetentionPriority> values = [LOW, MEDIUM, HIGH]; | 3330 static const List<RetentionPriority> values = const [LOW, MEDIUM, HIGH]; |
| 3340 | 3331 |
| 3341 RetentionPriority(String name, int ordinal) : super(name, ordinal); | 3332 const RetentionPriority(String name, int ordinal) : super(name, ordinal); |
| 3342 } | 3333 } |
| 3343 | 3334 |
| 3344 /** | 3335 /** |
| 3345 * The interface `SourceEntry` defines the behavior of objects that maintain the
information | 3336 * The interface `SourceEntry` defines the behavior of objects that maintain the
information |
| 3346 * cached by an analysis context about an individual source, no matter what kind
of source it is. | 3337 * cached by an analysis context about an individual source, no matter what kind
of source it is. |
| 3347 * | 3338 * |
| 3348 * Source entries should be treated as if they were immutable unless a writable
copy of the entry | 3339 * Source entries should be treated as if they were immutable unless a writable
copy of the entry |
| 3349 * has been obtained and has not yet been made visible to other threads. | 3340 * has been obtained and has not yet been made visible to other threads. |
| 3350 */ | 3341 */ |
| 3351 abstract class SourceEntry { | 3342 abstract class SourceEntry { |
| 3352 /** | 3343 /** |
| 3353 * The data descriptor representing the contents of the source. | 3344 * The data descriptor representing the contents of the source. |
| 3354 */ | 3345 */ |
| 3355 static final DataDescriptor<String> CONTENT = new DataDescriptor<String>("Dart
Entry.CONTENT"); | 3346 static final DataDescriptor<String> CONTENT = new DataDescriptor<String>("Dart
Entry.CONTENT"); |
| 3356 | 3347 |
| 3357 /** | 3348 /** |
| 3358 * The data descriptor representing the line information. | 3349 * The data descriptor representing the line information. |
| 3359 */ | 3350 */ |
| 3360 static final DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>
("SourceEntry.LINE_INFO"); | 3351 static final DataDescriptor<LineInfo> LINE_INFO = new DataDescriptor<LineInfo>
("SourceEntry.LINE_INFO"); |
| 3361 | 3352 |
| 3362 /** | 3353 /** |
| 3363 * Return the exception that caused one or more values to have a state of [Cac
heState#ERROR] | 3354 * Return the exception that caused one or more values to have a state of [Cac
heState#ERROR] |
| 3364 * . | 3355 * . |
| 3365 * | 3356 * |
| 3366 * @return the exception that caused one or more values to be uncomputable | 3357 * @return the exception that caused one or more values to be uncomputable |
| 3367 */ | 3358 */ |
| 3368 AnalysisException get exception; | 3359 AnalysisException get exception; |
| 3369 | 3360 |
| 3370 /** | 3361 /** |
| 3362 * Return `true` if the source was explicitly added to the context or `false`
if the |
| 3363 * source was implicitly added because it was referenced by another source. |
| 3364 * |
| 3365 * @return `true` if the source was explicitly added to the context |
| 3366 */ |
| 3367 bool get explicitlyAdded; |
| 3368 |
| 3369 /** |
| 3371 * Return the kind of the source, or `null` if the kind is not currently cache
d. | 3370 * Return the kind of the source, or `null` if the kind is not currently cache
d. |
| 3372 * | 3371 * |
| 3373 * @return the kind of the source | 3372 * @return the kind of the source |
| 3374 */ | 3373 */ |
| 3375 SourceKind get kind; | 3374 SourceKind get kind; |
| 3376 | 3375 |
| 3377 /** | 3376 /** |
| 3378 * Return the most recent time at which the state of the source matched the st
ate represented by | 3377 * Return the most recent time at which the state of the source matched the st
ate represented by |
| 3379 * this entry. | 3378 * this entry. |
| 3380 * | 3379 * |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3413 * [SourceEntry]. | 3412 * [SourceEntry]. |
| 3414 */ | 3413 */ |
| 3415 abstract class SourceEntryImpl implements SourceEntry { | 3414 abstract class SourceEntryImpl implements SourceEntry { |
| 3416 /** | 3415 /** |
| 3417 * The most recent time at which the state of the source matched the state rep
resented by this | 3416 * The most recent time at which the state of the source matched the state rep
resented by this |
| 3418 * entry. | 3417 * entry. |
| 3419 */ | 3418 */ |
| 3420 int _modificationTime = 0; | 3419 int _modificationTime = 0; |
| 3421 | 3420 |
| 3422 /** | 3421 /** |
| 3422 * A bit-encoding of boolean flags associated with this element. |
| 3423 */ |
| 3424 int _flags = 0; |
| 3425 |
| 3426 /** |
| 3423 * The exception that caused one or more values to have a state of [CacheState
#ERROR]. | 3427 * The exception that caused one or more values to have a state of [CacheState
#ERROR]. |
| 3424 */ | 3428 */ |
| 3425 AnalysisException exception; | 3429 AnalysisException exception; |
| 3426 | 3430 |
| 3427 /** | 3431 /** |
| 3428 * The state of the cached content. | 3432 * The state of the cached content. |
| 3429 */ | 3433 */ |
| 3430 CacheState _contentState = CacheState.INVALID; | 3434 CacheState _contentState = CacheState.INVALID; |
| 3431 | 3435 |
| 3432 /** | 3436 /** |
| 3433 * The content of the source, or `null` if the content is not currently cached
. | 3437 * The content of the source, or `null` if the content is not currently cached
. |
| 3434 */ | 3438 */ |
| 3435 String _content; | 3439 String _content; |
| 3436 | 3440 |
| 3437 /** | 3441 /** |
| 3438 * The state of the cached line information. | 3442 * The state of the cached line information. |
| 3439 */ | 3443 */ |
| 3440 CacheState _lineInfoState = CacheState.INVALID; | 3444 CacheState _lineInfoState = CacheState.INVALID; |
| 3441 | 3445 |
| 3442 /** | 3446 /** |
| 3443 * The line information computed for the source, or `null` if the line informa
tion is not | 3447 * The line information computed for the source, or `null` if the line informa
tion is not |
| 3444 * currently cached. | 3448 * currently cached. |
| 3445 */ | 3449 */ |
| 3446 LineInfo _lineInfo; | 3450 LineInfo _lineInfo; |
| 3447 | 3451 |
| 3448 /** | 3452 /** |
| 3453 * The index of the flag indicating whether the source was explicitly added to
the context or |
| 3454 * whether the source was implicitly added because it was referenced by anothe
r source. |
| 3455 */ |
| 3456 static int _EXPLICITLY_ADDED_FLAG = 0; |
| 3457 |
| 3458 /** |
| 3449 * Fix the state of the [exception] to match the current state of the entry. | 3459 * Fix the state of the [exception] to match the current state of the entry. |
| 3450 */ | 3460 */ |
| 3451 void fixExceptionState() { | 3461 void fixExceptionState() { |
| 3452 if (hasErrorState) { | 3462 if (hasErrorState) { |
| 3453 if (exception == null) { | 3463 if (exception == null) { |
| 3454 // | 3464 // |
| 3455 // This code should never be reached, but is a fail-safe in case an exce
ption is not | 3465 // This code should never be reached, but is a fail-safe in case an exce
ption is not |
| 3456 // recorded when it should be. | 3466 // recorded when it should be. |
| 3457 // | 3467 // |
| 3458 exception = new AnalysisException.con1("State set to ERROR without setti
ng an exception"); | 3468 exception = new AnalysisException.con1("State set to ERROR without setti
ng an exception"); |
| 3459 } | 3469 } |
| 3460 } else { | 3470 } else { |
| 3461 exception = null; | 3471 exception = null; |
| 3462 } | 3472 } |
| 3463 } | 3473 } |
| 3464 | 3474 |
| 3475 /** |
| 3476 * Return `true` if the source was explicitly added to the context or `false`
if the |
| 3477 * source was implicitly added because it was referenced by another source. |
| 3478 * |
| 3479 * @return `true` if the source was explicitly added to the context |
| 3480 */ |
| 3481 @override |
| 3482 bool get explicitlyAdded => getFlag(_EXPLICITLY_ADDED_FLAG); |
| 3483 |
| 3465 @override | 3484 @override |
| 3466 int get modificationTime => _modificationTime; | 3485 int get modificationTime => _modificationTime; |
| 3467 | 3486 |
| 3468 @override | 3487 @override |
| 3469 CacheState getState(DataDescriptor descriptor) { | 3488 CacheState getState(DataDescriptor descriptor) { |
| 3470 if (identical(descriptor, SourceEntry.CONTENT)) { | 3489 if (identical(descriptor, SourceEntry.CONTENT)) { |
| 3471 return _contentState; | 3490 return _contentState; |
| 3472 } else if (identical(descriptor, SourceEntry.LINE_INFO)) { | 3491 } else if (identical(descriptor, SourceEntry.LINE_INFO)) { |
| 3473 return _lineInfoState; | 3492 return _lineInfoState; |
| 3474 } else { | 3493 } else { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3501 * Record that an error occurred while attempting to get the contents of the s
ource represented by | 3520 * Record that an error occurred while attempting to get the contents of the s
ource represented by |
| 3502 * this entry. This will set the state of all information, including any resol
ution-based | 3521 * this entry. This will set the state of all information, including any resol
ution-based |
| 3503 * information, as being in error. | 3522 * information, as being in error. |
| 3504 */ | 3523 */ |
| 3505 void recordContentError() { | 3524 void recordContentError() { |
| 3506 _content = null; | 3525 _content = null; |
| 3507 _contentState = CacheState.ERROR; | 3526 _contentState = CacheState.ERROR; |
| 3508 } | 3527 } |
| 3509 | 3528 |
| 3510 /** | 3529 /** |
| 3530 * Set whether the source was explicitly added to the context to match the giv
en value. |
| 3531 * |
| 3532 * @param explicitlyAdded `true` if the source was explicitly added to the con
text |
| 3533 */ |
| 3534 void set explicitlyAdded(bool explicitlyAdded) { |
| 3535 setFlag(_EXPLICITLY_ADDED_FLAG, explicitlyAdded); |
| 3536 } |
| 3537 |
| 3538 /** |
| 3511 * Set the most recent time at which the state of the source matched the state
represented by this | 3539 * Set the most recent time at which the state of the source matched the state
represented by this |
| 3512 * entry to the given time. | 3540 * entry to the given time. |
| 3513 * | 3541 * |
| 3514 * @param time the new modification time of this entry | 3542 * @param time the new modification time of this entry |
| 3515 */ | 3543 */ |
| 3516 void set modificationTime(int time) { | 3544 void set modificationTime(int time) { |
| 3517 _modificationTime = time; | 3545 _modificationTime = time; |
| 3518 } | 3546 } |
| 3519 | 3547 |
| 3520 /** | 3548 /** |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3554 } | 3582 } |
| 3555 | 3583 |
| 3556 @override | 3584 @override |
| 3557 String toString() { | 3585 String toString() { |
| 3558 JavaStringBuilder builder = new JavaStringBuilder(); | 3586 JavaStringBuilder builder = new JavaStringBuilder(); |
| 3559 writeOn(builder); | 3587 writeOn(builder); |
| 3560 return builder.toString(); | 3588 return builder.toString(); |
| 3561 } | 3589 } |
| 3562 | 3590 |
| 3563 /** | 3591 /** |
| 3592 * Set the value of all of the flags with the given indexes to false. |
| 3593 * |
| 3594 * @param indexes the indexes of the flags whose value is to be set to false |
| 3595 */ |
| 3596 void clearFlags(List<int> indexes) { |
| 3597 for (int i = 0; i < indexes.length; i++) { |
| 3598 _flags = BooleanArray.set(_flags, indexes[i], false); |
| 3599 } |
| 3600 } |
| 3601 |
| 3602 /** |
| 3564 * Copy the information from the given cache entry. | 3603 * Copy the information from the given cache entry. |
| 3565 * | 3604 * |
| 3566 * @param entry the cache entry from which information will be copied | 3605 * @param entry the cache entry from which information will be copied |
| 3567 */ | 3606 */ |
| 3568 void copyFrom(SourceEntryImpl entry) { | 3607 void copyFrom(SourceEntryImpl entry) { |
| 3569 _modificationTime = entry._modificationTime; | 3608 _modificationTime = entry._modificationTime; |
| 3609 _flags = entry._flags; |
| 3570 exception = entry.exception; | 3610 exception = entry.exception; |
| 3571 _contentState = entry._contentState; | 3611 _contentState = entry._contentState; |
| 3572 _content = entry._content; | 3612 _content = entry._content; |
| 3573 _lineInfoState = entry._lineInfoState; | 3613 _lineInfoState = entry._lineInfoState; |
| 3574 _lineInfo = entry._lineInfo; | 3614 _lineInfo = entry._lineInfo; |
| 3575 } | 3615 } |
| 3576 | 3616 |
| 3577 /** | 3617 /** |
| 3618 * Return the value of the flag with the given index. |
| 3619 * |
| 3620 * @param index the index of the flag whose value is to be returned |
| 3621 * @return the value of the flag with the given index |
| 3622 */ |
| 3623 bool getFlag(int index) => BooleanArray.get(_flags, index); |
| 3624 |
| 3625 /** |
| 3578 * Return `true` if the state of any data value is [CacheState#ERROR]. | 3626 * Return `true` if the state of any data value is [CacheState#ERROR]. |
| 3579 * | 3627 * |
| 3580 * @return `true` if the state of any data value is [CacheState#ERROR] | 3628 * @return `true` if the state of any data value is [CacheState#ERROR] |
| 3581 */ | 3629 */ |
| 3582 bool get hasErrorState => identical(_contentState, CacheState.ERROR) || identi
cal(_lineInfoState, CacheState.ERROR); | 3630 bool get hasErrorState => _contentState == CacheState.ERROR || _lineInfoState
== CacheState.ERROR; |
| 3631 |
| 3632 /** |
| 3633 * Set the value of the flag with the given index to the given value. |
| 3634 * |
| 3635 * @param index the index of the flag whose value is to be returned |
| 3636 * @param value the value of the flag with the given index |
| 3637 */ |
| 3638 void setFlag(int index, bool value) { |
| 3639 _flags = BooleanArray.set(_flags, index, value); |
| 3640 } |
| 3583 | 3641 |
| 3584 /** | 3642 /** |
| 3585 * Given that some data is being transitioned to the given state, return the v
alue that should be | 3643 * Given that some data is being transitioned to the given state, return the v
alue that should be |
| 3586 * kept in the cache. | 3644 * kept in the cache. |
| 3587 * | 3645 * |
| 3588 * @param state the state to which the data is being transitioned | 3646 * @param state the state to which the data is being transitioned |
| 3589 * @param currentValue the value of the data before the transition | 3647 * @param currentValue the value of the data before the transition |
| 3590 * @param defaultValue the value to be used if the current value is to be remo
ved from the cache | 3648 * @param defaultValue the value to be used if the current value is to be remo
ved from the cache |
| 3591 * @return the value of the data that should be kept in the cache | 3649 * @return the value of the data that should be kept in the cache |
| 3592 */ | 3650 */ |
| 3593 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { | 3651 Object updatedValue(CacheState state, Object currentValue, Object defaultValue
) { |
| 3594 if (identical(state, CacheState.VALID)) { | 3652 if (state == CacheState.VALID) { |
| 3595 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); | 3653 throw new IllegalArgumentException("Use setValue() to set the state to VAL
ID"); |
| 3596 } else if (identical(state, CacheState.IN_PROCESS)) { | 3654 } else if (state == CacheState.IN_PROCESS) { |
| 3597 // | 3655 // |
| 3598 // We can leave the current value in the cache for any 'get' methods to ac
cess. | 3656 // We can leave the current value in the cache for any 'get' methods to ac
cess. |
| 3599 // | 3657 // |
| 3600 return currentValue; | 3658 return currentValue; |
| 3601 } | 3659 } |
| 3602 return defaultValue; | 3660 return defaultValue; |
| 3603 } | 3661 } |
| 3604 | 3662 |
| 3605 /** | 3663 /** |
| 3606 * Write a textual representation of this entry to the given builder. The resu
lt will only be used | 3664 * Write a textual representation of this entry to the given builder. The resu
lt will only be used |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3653 } | 3711 } |
| 3654 | 3712 |
| 3655 void _internalPutCacheItem(SourceEntry dartEntry, DataDescriptor rowDesc, Cach
eState state) { | 3713 void _internalPutCacheItem(SourceEntry dartEntry, DataDescriptor rowDesc, Cach
eState state) { |
| 3656 String rowName = rowDesc.toString(); | 3714 String rowName = rowDesc.toString(); |
| 3657 AnalysisContentStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys
isContentStatisticsImpl_CacheRowImpl; | 3715 AnalysisContentStatisticsImpl_CacheRowImpl row = _dataMap[rowName] as Analys
isContentStatisticsImpl_CacheRowImpl; |
| 3658 if (row == null) { | 3716 if (row == null) { |
| 3659 row = new AnalysisContentStatisticsImpl_CacheRowImpl(rowName); | 3717 row = new AnalysisContentStatisticsImpl_CacheRowImpl(rowName); |
| 3660 _dataMap[rowName] = row; | 3718 _dataMap[rowName] = row; |
| 3661 } | 3719 } |
| 3662 row._incState(state); | 3720 row._incState(state); |
| 3663 if (identical(state, CacheState.ERROR)) { | 3721 if (state == CacheState.ERROR) { |
| 3664 AnalysisException exception = dartEntry.exception; | 3722 AnalysisException exception = dartEntry.exception; |
| 3665 if (exception != null) { | 3723 if (exception != null) { |
| 3666 _exceptions.add(exception); | 3724 _exceptions.add(exception); |
| 3667 } | 3725 } |
| 3668 } | 3726 } |
| 3669 } | 3727 } |
| 3670 } | 3728 } |
| 3671 | 3729 |
| 3672 class AnalysisContentStatisticsImpl_CacheRowImpl implements AnalysisContentStati
stics_CacheRow { | 3730 class AnalysisContentStatisticsImpl_CacheRowImpl implements AnalysisContentStati
stics_CacheRow { |
| 3673 String name; | 3731 final String name; |
| 3674 | 3732 |
| 3675 int _errorCount = 0; | 3733 int _errorCount = 0; |
| 3676 | 3734 |
| 3677 int _flushedCount = 0; | 3735 int _flushedCount = 0; |
| 3678 | 3736 |
| 3679 int _inProcessCount = 0; | 3737 int _inProcessCount = 0; |
| 3680 | 3738 |
| 3681 int _invalidCount = 0; | 3739 int _invalidCount = 0; |
| 3682 | 3740 |
| 3683 int _validCount = 0; | 3741 int _validCount = 0; |
| 3684 | 3742 |
| 3685 AnalysisContentStatisticsImpl_CacheRowImpl(String name) { | 3743 AnalysisContentStatisticsImpl_CacheRowImpl(this.name); |
| 3686 this.name = name; | |
| 3687 } | |
| 3688 | 3744 |
| 3689 @override | 3745 @override |
| 3690 bool operator ==(Object obj) => obj is AnalysisContentStatisticsImpl_CacheRowI
mpl && obj.name == name; | 3746 bool operator ==(Object obj) => obj is AnalysisContentStatisticsImpl_CacheRowI
mpl && obj.name == name; |
| 3691 | 3747 |
| 3692 @override | 3748 @override |
| 3693 int get errorCount => _errorCount; | 3749 int get errorCount => _errorCount; |
| 3694 | 3750 |
| 3695 @override | 3751 @override |
| 3696 int get flushedCount => _flushedCount; | 3752 int get flushedCount => _flushedCount; |
| 3697 | 3753 |
| 3698 @override | 3754 @override |
| 3699 int get inProcessCount => _inProcessCount; | 3755 int get inProcessCount => _inProcessCount; |
| 3700 | 3756 |
| 3701 @override | 3757 @override |
| 3702 int get invalidCount => _invalidCount; | 3758 int get invalidCount => _invalidCount; |
| 3703 | 3759 |
| 3704 @override | 3760 @override |
| 3705 int get validCount => _validCount; | 3761 int get validCount => _validCount; |
| 3706 | 3762 |
| 3707 @override | 3763 @override |
| 3708 int get hashCode => name.hashCode; | 3764 int get hashCode => name.hashCode; |
| 3709 | 3765 |
| 3710 void _incState(CacheState state) { | 3766 void _incState(CacheState state) { |
| 3711 if (identical(state, CacheState.ERROR)) { | 3767 if (state == CacheState.ERROR) { |
| 3712 _errorCount++; | 3768 _errorCount++; |
| 3713 } | 3769 } |
| 3714 if (identical(state, CacheState.FLUSHED)) { | 3770 if (state == CacheState.FLUSHED) { |
| 3715 _flushedCount++; | 3771 _flushedCount++; |
| 3716 } | 3772 } |
| 3717 if (identical(state, CacheState.IN_PROCESS)) { | 3773 if (state == CacheState.IN_PROCESS) { |
| 3718 _inProcessCount++; | 3774 _inProcessCount++; |
| 3719 } | 3775 } |
| 3720 if (identical(state, CacheState.INVALID)) { | 3776 if (state == CacheState.INVALID) { |
| 3721 _invalidCount++; | 3777 _invalidCount++; |
| 3722 } | 3778 } |
| 3723 if (identical(state, CacheState.VALID)) { | 3779 if (state == CacheState.VALID) { |
| 3724 _validCount++; | 3780 _validCount++; |
| 3725 } | 3781 } |
| 3726 } | 3782 } |
| 3727 } | 3783 } |
| 3728 | 3784 |
| 3729 /** | 3785 /** |
| 3730 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext]. | 3786 * Instances of the class `AnalysisContextImpl` implement an [AnalysisContext]. |
| 3731 */ | 3787 */ |
| 3732 class AnalysisContextImpl implements InternalAnalysisContext { | 3788 class AnalysisContextImpl implements InternalAnalysisContext { |
| 3733 /** | 3789 /** |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3894 int count = sourcesToInvalidate.length; | 3950 int count = sourcesToInvalidate.length; |
| 3895 for (int i = 0; i < count; i++) { | 3951 for (int i = 0; i < count; i++) { |
| 3896 Source source = sourcesToInvalidate[i]; | 3952 Source source = sourcesToInvalidate[i]; |
| 3897 DartEntry dartEntry = _getReadableDartEntry(source); | 3953 DartEntry dartEntry = _getReadableDartEntry(source); |
| 3898 _removeFromParts(source, dartEntry); | 3954 _removeFromParts(source, dartEntry); |
| 3899 DartEntryImpl dartCopy = dartEntry.writableCopy; | 3955 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3900 dartCopy.invalidateAllResolutionInformation(); | 3956 dartCopy.invalidateAllResolutionInformation(); |
| 3901 _cache.put(source, dartCopy); | 3957 _cache.put(source, dartCopy); |
| 3902 SourcePriority priority = SourcePriority.UNKNOWN; | 3958 SourcePriority priority = SourcePriority.UNKNOWN; |
| 3903 SourceKind kind = dartCopy.kind; | 3959 SourceKind kind = dartCopy.kind; |
| 3904 if (identical(kind, SourceKind.LIBRARY)) { | 3960 if (kind == SourceKind.LIBRARY) { |
| 3905 priority = SourcePriority.LIBRARY; | 3961 priority = SourcePriority.LIBRARY; |
| 3906 } else if (identical(kind, SourceKind.PART)) { | 3962 } else if (kind == SourceKind.PART) { |
| 3907 priority = SourcePriority.NORMAL_PART; | 3963 priority = SourcePriority.NORMAL_PART; |
| 3908 } | 3964 } |
| 3909 _workManager.add(source, priority); | 3965 _workManager.add(source, priority); |
| 3910 } | 3966 } |
| 3911 } | 3967 } |
| 3912 } | 3968 } |
| 3913 | 3969 |
| 3914 @override | 3970 @override |
| 3915 String computeDocumentationComment(Element element) { | 3971 String computeDocumentationComment(Element element) { |
| 3916 if (element == null) { | 3972 if (element == null) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3952 bool enableHints = _options.hint; | 4008 bool enableHints = _options.hint; |
| 3953 SourceEntry sourceEntry = _getReadableSourceEntry(source); | 4009 SourceEntry sourceEntry = _getReadableSourceEntry(source); |
| 3954 if (sourceEntry is DartEntry) { | 4010 if (sourceEntry is DartEntry) { |
| 3955 List<AnalysisError> errors = new List<AnalysisError>(); | 4011 List<AnalysisError> errors = new List<AnalysisError>(); |
| 3956 try { | 4012 try { |
| 3957 DartEntry dartEntry = sourceEntry; | 4013 DartEntry dartEntry = sourceEntry; |
| 3958 ListUtilities.addAll(errors, _getDartScanData(source, dartEntry, DartEnt
ry.SCAN_ERRORS)); | 4014 ListUtilities.addAll(errors, _getDartScanData(source, dartEntry, DartEnt
ry.SCAN_ERRORS)); |
| 3959 dartEntry = _getReadableDartEntry(source); | 4015 dartEntry = _getReadableDartEntry(source); |
| 3960 ListUtilities.addAll(errors, _getDartParseData(source, dartEntry, DartEn
try.PARSE_ERRORS)); | 4016 ListUtilities.addAll(errors, _getDartParseData(source, dartEntry, DartEn
try.PARSE_ERRORS)); |
| 3961 dartEntry = _getReadableDartEntry(source); | 4017 dartEntry = _getReadableDartEntry(source); |
| 3962 if (identical(dartEntry.getValue(DartEntry.SOURCE_KIND), SourceKind.LIBR
ARY)) { | 4018 if (dartEntry.getValue(DartEntry.SOURCE_KIND) == SourceKind.LIBRARY) { |
| 3963 ListUtilities.addAll(errors, _getDartResolutionData(source, source, da
rtEntry, DartEntry.RESOLUTION_ERRORS)); | 4019 ListUtilities.addAll(errors, _getDartResolutionData(source, source, da
rtEntry, DartEntry.RESOLUTION_ERRORS)); |
| 3964 dartEntry = _getReadableDartEntry(source); | 4020 dartEntry = _getReadableDartEntry(source); |
| 3965 ListUtilities.addAll(errors, _getDartVerificationData(source, source,
dartEntry, DartEntry.VERIFICATION_ERRORS)); | 4021 ListUtilities.addAll(errors, _getDartVerificationData(source, source,
dartEntry, DartEntry.VERIFICATION_ERRORS)); |
| 3966 if (enableHints) { | 4022 if (enableHints) { |
| 3967 dartEntry = _getReadableDartEntry(source); | 4023 dartEntry = _getReadableDartEntry(source); |
| 3968 ListUtilities.addAll(errors, _getDartHintData(source, source, dartEn
try, DartEntry.HINTS)); | 4024 ListUtilities.addAll(errors, _getDartHintData(source, source, dartEn
try, DartEntry.HINTS)); |
| 3969 } | 4025 } |
| 3970 } else { | 4026 } else { |
| 3971 List<Source> libraries = getLibrariesContaining(source); | 4027 List<Source> libraries = getLibrariesContaining(source); |
| 3972 for (Source librarySource in libraries) { | 4028 for (Source librarySource in libraries) { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4180 if (sourceKind == null) { | 4236 if (sourceKind == null) { |
| 4181 return Source.EMPTY_ARRAY; | 4237 return Source.EMPTY_ARRAY; |
| 4182 } | 4238 } |
| 4183 List<Source> htmlSources = new List<Source>(); | 4239 List<Source> htmlSources = new List<Source>(); |
| 4184 while (true) { | 4240 while (true) { |
| 4185 if (sourceKind == SourceKind.LIBRARY) { | 4241 if (sourceKind == SourceKind.LIBRARY) { |
| 4186 } else if (sourceKind == SourceKind.PART) { | 4242 } else if (sourceKind == SourceKind.PART) { |
| 4187 List<Source> librarySources = getLibrariesContaining(source); | 4243 List<Source> librarySources = getLibrariesContaining(source); |
| 4188 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4244 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4189 SourceEntry sourceEntry = entry.getValue(); | 4245 SourceEntry sourceEntry = entry.getValue(); |
| 4190 if (identical(sourceEntry.kind, SourceKind.HTML)) { | 4246 if (sourceEntry.kind == SourceKind.HTML) { |
| 4191 List<Source> referencedLibraries = (sourceEntry as HtmlEntry).getVal
ue(HtmlEntry.REFERENCED_LIBRARIES); | 4247 List<Source> referencedLibraries = (sourceEntry as HtmlEntry).getVal
ue(HtmlEntry.REFERENCED_LIBRARIES); |
| 4192 if (_containsAny(referencedLibraries, librarySources)) { | 4248 if (_containsAny(referencedLibraries, librarySources)) { |
| 4193 htmlSources.add(entry.getKey()); | 4249 htmlSources.add(entry.getKey()); |
| 4194 } | 4250 } |
| 4195 } | 4251 } |
| 4196 } | 4252 } |
| 4197 } | 4253 } |
| 4198 break; | 4254 break; |
| 4199 } | 4255 } |
| 4200 if (htmlSources.isEmpty) { | 4256 if (htmlSources.isEmpty) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 4216 } | 4272 } |
| 4217 | 4273 |
| 4218 @override | 4274 @override |
| 4219 List<Source> get launchableClientLibrarySources { | 4275 List<Source> get launchableClientLibrarySources { |
| 4220 // TODO(brianwilkerson) This needs to filter out libraries that do not refer
ence dart:html, | 4276 // TODO(brianwilkerson) This needs to filter out libraries that do not refer
ence dart:html, |
| 4221 // either directly or indirectly. | 4277 // either directly or indirectly. |
| 4222 List<Source> sources = new List<Source>(); | 4278 List<Source> sources = new List<Source>(); |
| 4223 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4279 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4224 Source source = entry.getKey(); | 4280 Source source = entry.getKey(); |
| 4225 SourceEntry sourceEntry = entry.getValue(); | 4281 SourceEntry sourceEntry = entry.getValue(); |
| 4226 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSystemL
ibrary) { | 4282 if (sourceEntry.kind == SourceKind.LIBRARY && !source.isInSystemLibrary) { |
| 4227 // DartEntry dartEntry = (DartEntry) sourceEntry; | 4283 // DartEntry dartEntry = (DartEntry) sourceEntry; |
| 4228 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && dartEntry
.getValue(DartEntry.IS_CLIENT)) { | 4284 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && dartEntry
.getValue(DartEntry.IS_CLIENT)) { |
| 4229 sources.add(source); | 4285 sources.add(source); |
| 4230 } | 4286 } |
| 4231 } | 4287 } |
| 4232 return new List.from(sources); | 4288 return new List.from(sources); |
| 4233 } | 4289 } |
| 4234 | 4290 |
| 4235 @override | 4291 @override |
| 4236 List<Source> get launchableServerLibrarySources { | 4292 List<Source> get launchableServerLibrarySources { |
| 4237 // TODO(brianwilkerson) This needs to filter out libraries that reference da
rt:html, either | 4293 // TODO(brianwilkerson) This needs to filter out libraries that reference da
rt:html, either |
| 4238 // directly or indirectly. | 4294 // directly or indirectly. |
| 4239 List<Source> sources = new List<Source>(); | 4295 List<Source> sources = new List<Source>(); |
| 4240 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4296 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4241 Source source = entry.getKey(); | 4297 Source source = entry.getKey(); |
| 4242 SourceEntry sourceEntry = entry.getValue(); | 4298 SourceEntry sourceEntry = entry.getValue(); |
| 4243 if (identical(sourceEntry.kind, SourceKind.LIBRARY) && !source.isInSystemL
ibrary) { | 4299 if (sourceEntry.kind == SourceKind.LIBRARY && !source.isInSystemLibrary) { |
| 4244 // DartEntry dartEntry = (DartEntry) sourceEntry; | 4300 // DartEntry dartEntry = (DartEntry) sourceEntry; |
| 4245 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEntr
y.getValue(DartEntry.IS_CLIENT)) { | 4301 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEntr
y.getValue(DartEntry.IS_CLIENT)) { |
| 4246 sources.add(source); | 4302 sources.add(source); |
| 4247 } | 4303 } |
| 4248 } | 4304 } |
| 4249 return new List.from(sources); | 4305 return new List.from(sources); |
| 4250 } | 4306 } |
| 4251 | 4307 |
| 4252 @override | 4308 @override |
| 4253 List<Source> getLibrariesContaining(Source source) { | 4309 List<Source> getLibrariesContaining(Source source) { |
| 4254 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); | 4310 SourceEntry sourceEntry = _getReadableSourceEntryOrNull(source); |
| 4255 if (sourceEntry is DartEntry) { | 4311 if (sourceEntry is DartEntry) { |
| 4256 return sourceEntry.getValue(DartEntry.CONTAINING_LIBRARIES); | 4312 return sourceEntry.getValue(DartEntry.CONTAINING_LIBRARIES); |
| 4257 } | 4313 } |
| 4258 return Source.EMPTY_ARRAY; | 4314 return Source.EMPTY_ARRAY; |
| 4259 } | 4315 } |
| 4260 | 4316 |
| 4261 @override | 4317 @override |
| 4262 List<Source> getLibrariesDependingOn(Source librarySource) { | 4318 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 4263 List<Source> dependentLibraries = new List<Source>(); | 4319 List<Source> dependentLibraries = new List<Source>(); |
| 4264 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4320 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4265 SourceEntry sourceEntry = entry.getValue(); | 4321 SourceEntry sourceEntry = entry.getValue(); |
| 4266 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { | 4322 if (sourceEntry.kind == SourceKind.LIBRARY) { |
| 4267 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LIB
RARIES), librarySource)) { | 4323 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LIB
RARIES), librarySource)) { |
| 4268 dependentLibraries.add(entry.getKey()); | 4324 dependentLibraries.add(entry.getKey()); |
| 4269 } | 4325 } |
| 4270 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LIB
RARIES), librarySource)) { | 4326 if (_contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LIB
RARIES), librarySource)) { |
| 4271 dependentLibraries.add(entry.getKey()); | 4327 dependentLibraries.add(entry.getKey()); |
| 4272 } | 4328 } |
| 4273 } | 4329 } |
| 4274 } | 4330 } |
| 4275 if (dependentLibraries.isEmpty) { | 4331 if (dependentLibraries.isEmpty) { |
| 4276 return Source.EMPTY_ARRAY; | 4332 return Source.EMPTY_ARRAY; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4426 SourceEntry entry = mapEntry.getValue(); | 4482 SourceEntry entry = mapEntry.getValue(); |
| 4427 if (entry is DartEntry) { | 4483 if (entry is DartEntry) { |
| 4428 Source source = mapEntry.getKey(); | 4484 Source source = mapEntry.getKey(); |
| 4429 DartEntry dartEntry = entry; | 4485 DartEntry dartEntry = entry; |
| 4430 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); | 4486 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); |
| 4431 // get library independent values | 4487 // get library independent values |
| 4432 statistics.putCacheItem(dartEntry, SourceEntry.LINE_INFO); | 4488 statistics.putCacheItem(dartEntry, SourceEntry.LINE_INFO); |
| 4433 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS); | 4489 statistics.putCacheItem(dartEntry, DartEntry.PARSE_ERRORS); |
| 4434 statistics.putCacheItem(dartEntry, DartEntry.PARSED_UNIT); | 4490 statistics.putCacheItem(dartEntry, DartEntry.PARSED_UNIT); |
| 4435 statistics.putCacheItem(dartEntry, DartEntry.SOURCE_KIND); | 4491 statistics.putCacheItem(dartEntry, DartEntry.SOURCE_KIND); |
| 4436 if (identical(kind, SourceKind.LIBRARY)) { | 4492 if (kind == SourceKind.LIBRARY) { |
| 4437 statistics.putCacheItem(dartEntry, DartEntry.ELEMENT); | 4493 statistics.putCacheItem(dartEntry, DartEntry.ELEMENT); |
| 4438 statistics.putCacheItem(dartEntry, DartEntry.EXPORTED_LIBRARIES); | 4494 statistics.putCacheItem(dartEntry, DartEntry.EXPORTED_LIBRARIES); |
| 4439 statistics.putCacheItem(dartEntry, DartEntry.IMPORTED_LIBRARIES); | 4495 statistics.putCacheItem(dartEntry, DartEntry.IMPORTED_LIBRARIES); |
| 4440 statistics.putCacheItem(dartEntry, DartEntry.INCLUDED_PARTS); | 4496 statistics.putCacheItem(dartEntry, DartEntry.INCLUDED_PARTS); |
| 4441 statistics.putCacheItem(dartEntry, DartEntry.IS_CLIENT); | 4497 statistics.putCacheItem(dartEntry, DartEntry.IS_CLIENT); |
| 4442 statistics.putCacheItem(dartEntry, DartEntry.IS_LAUNCHABLE); | 4498 statistics.putCacheItem(dartEntry, DartEntry.IS_LAUNCHABLE); |
| 4443 } | 4499 } |
| 4444 // get library-specific values | 4500 // get library-specific values |
| 4445 List<Source> librarySources = getLibrariesContaining(source); | 4501 List<Source> librarySources = getLibrariesContaining(source); |
| 4446 for (Source librarySource in librarySources) { | 4502 for (Source librarySource in librarySources) { |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4782 _cache.remove(source); | 4838 _cache.remove(source); |
| 4783 } | 4839 } |
| 4784 dartCopy.exception = thrownException; | 4840 dartCopy.exception = thrownException; |
| 4785 _cache.put(source, dartCopy); | 4841 _cache.put(source, dartCopy); |
| 4786 if (source != librarySource) { | 4842 if (source != librarySource) { |
| 4787 _workManager.add(source, SourcePriority.PRIORITY_PART); | 4843 _workManager.add(source, SourcePriority.PRIORITY_PART); |
| 4788 } | 4844 } |
| 4789 if (source == unitSource) { | 4845 if (source == unitSource) { |
| 4790 unitEntry = dartCopy; | 4846 unitEntry = dartCopy; |
| 4791 } | 4847 } |
| 4792 if (_generateSdkErrors || !source.isInSystemLibrary) { | 4848 ChangeNoticeImpl notice = _getNotice(source); |
| 4793 ChangeNoticeImpl notice = _getNotice(source); | 4849 notice.compilationUnit = unit; |
| 4794 notice.compilationUnit = unit; | 4850 notice.setErrors(dartCopy.allErrors, lineInfo); |
| 4795 notice.setErrors(dartCopy.allErrors, lineInfo); | |
| 4796 } | |
| 4797 } | 4851 } |
| 4798 } | 4852 } |
| 4799 } else { | 4853 } else { |
| 4800 PrintStringWriter writer = new PrintStringWriter(); | 4854 PrintStringWriter writer = new PrintStringWriter(); |
| 4801 writer.println("Library resolution results discarded for"); | 4855 writer.println("Library resolution results discarded for"); |
| 4802 for (ResolvableLibrary library in resolvedLibraries) { | 4856 for (ResolvableLibrary library in resolvedLibraries) { |
| 4803 for (Source source in library.compilationUnitSources) { | 4857 for (Source source in library.compilationUnitSources) { |
| 4804 DartEntry dartEntry = _getReadableDartEntry(source); | 4858 DartEntry dartEntry = _getReadableDartEntry(source); |
| 4805 if (dartEntry != null) { | 4859 if (dartEntry != null) { |
| 4806 int resultTime = library.getModificationTime(source); | 4860 int resultTime = library.getModificationTime(source); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4909 _cache.remove(source); | 4963 _cache.remove(source); |
| 4910 } | 4964 } |
| 4911 dartCopy.exception = thrownException; | 4965 dartCopy.exception = thrownException; |
| 4912 _cache.put(source, dartCopy); | 4966 _cache.put(source, dartCopy); |
| 4913 if (source != librarySource) { | 4967 if (source != librarySource) { |
| 4914 _workManager.add(source, SourcePriority.PRIORITY_PART); | 4968 _workManager.add(source, SourcePriority.PRIORITY_PART); |
| 4915 } | 4969 } |
| 4916 if (source == unitSource) { | 4970 if (source == unitSource) { |
| 4917 unitEntry = dartCopy; | 4971 unitEntry = dartCopy; |
| 4918 } | 4972 } |
| 4919 if (_generateSdkErrors || !source.isInSystemLibrary) { | 4973 ChangeNoticeImpl notice = _getNotice(source); |
| 4920 ChangeNoticeImpl notice = _getNotice(source); | 4974 notice.compilationUnit = unit; |
| 4921 notice.compilationUnit = unit; | 4975 notice.setErrors(dartCopy.allErrors, lineInfo); |
| 4922 notice.setErrors(dartCopy.allErrors, lineInfo); | |
| 4923 } | |
| 4924 } | 4976 } |
| 4925 } | 4977 } |
| 4926 } else { | 4978 } else { |
| 4927 PrintStringWriter writer = new PrintStringWriter(); | 4979 PrintStringWriter writer = new PrintStringWriter(); |
| 4928 writer.println("Library resolution results discarded for"); | 4980 writer.println("Library resolution results discarded for"); |
| 4929 for (Library library in resolvedLibraries) { | 4981 for (Library library in resolvedLibraries) { |
| 4930 for (Source source in library.compilationUnitSources) { | 4982 for (Source source in library.compilationUnitSources) { |
| 4931 DartEntry dartEntry = _getReadableDartEntry(source); | 4983 DartEntry dartEntry = _getReadableDartEntry(source); |
| 4932 if (dartEntry != null) { | 4984 if (dartEntry != null) { |
| 4933 int resultTime = library.getModificationTime(source); | 4985 int resultTime = library.getModificationTime(source); |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5363 for (Source targetSource in targetSources) { | 5415 for (Source targetSource in targetSources) { |
| 5364 if (_contains(sources, targetSource)) { | 5416 if (_contains(sources, targetSource)) { |
| 5365 return true; | 5417 return true; |
| 5366 } | 5418 } |
| 5367 } | 5419 } |
| 5368 return false; | 5420 return false; |
| 5369 } | 5421 } |
| 5370 | 5422 |
| 5371 /** | 5423 /** |
| 5372 * Create a [GenerateDartErrorsTask] for the given source, marking the verific
ation errors | 5424 * Create a [GenerateDartErrorsTask] for the given source, marking the verific
ation errors |
| 5373 * as being in-process. | 5425 * as being in-process. The compilation unit and the library can be the same i
f the compilation |
| 5426 * unit is the defining compilation unit of the library. |
| 5374 * | 5427 * |
| 5375 * @param source the source whose content is to be verified | 5428 * @param unitSource the source for the compilation unit to be verified |
| 5376 * @param dartEntry the entry for the source | 5429 * @param unitEntry the entry for the compilation unit |
| 5377 * @param librarySource the source for the library containing the source | 5430 * @param librarySource the source for the library containing the compilation
unit |
| 5378 * @param libraryEntry the entry for the library | 5431 * @param libraryEntry the entry for the library |
| 5379 * @return task data representing the created task | 5432 * @return task data representing the created task |
| 5380 */ | 5433 */ |
| 5381 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source source, Dart
Entry dartEntry, Source librarySource, SourceEntry libraryEntry) { | 5434 AnalysisContextImpl_TaskData _createGenerateDartErrorsTask(Source unitSource,
DartEntry unitEntry, Source librarySource, DartEntry libraryEntry) { |
| 5382 if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != C
acheState.VALID || libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID)
{ | 5435 if (unitEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) != C
acheState.VALID || libraryEntry.getState(DartEntry.ELEMENT) != CacheState.VALID)
{ |
| 5436 return _createResolveDartLibraryTask(librarySource, libraryEntry); |
| 5383 } | 5437 } |
| 5384 CompilationUnit unit = dartEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT,
librarySource); | 5438 CompilationUnit unit = unitEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT,
librarySource); |
| 5385 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); | 5439 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEMENT); |
| 5386 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5440 DartEntryImpl dartCopy = unitEntry.writableCopy; |
| 5387 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, Cac
heState.IN_PROCESS); | 5441 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource, Cac
heState.IN_PROCESS); |
| 5388 _cache.put(source, dartCopy); | 5442 _cache.put(unitSource, dartCopy); |
| 5389 return new AnalysisContextImpl_TaskData(new GenerateDartErrorsTask(this, sou
rce, dartCopy.modificationTime, unit, libraryElement), false); | 5443 return new AnalysisContextImpl_TaskData(new GenerateDartErrorsTask(this, uni
tSource, dartCopy.modificationTime, unit, libraryElement), false); |
| 5390 } | 5444 } |
| 5391 | 5445 |
| 5392 /** | 5446 /** |
| 5393 * Create a [GenerateDartHintsTask] for the given source, marking the hints as
being | 5447 * Create a [GenerateDartHintsTask] for the given source, marking the hints as
being |
| 5394 * in-process. | 5448 * in-process. |
| 5395 * | 5449 * |
| 5396 * @param source the source whose content is to be verified | 5450 * @param source the source whose content is to be verified |
| 5397 * @param dartEntry the entry for the source | 5451 * @param dartEntry the entry for the source |
| 5398 * @param librarySource the source for the library containing the source | 5452 * @param librarySource the source for the library containing the source |
| 5399 * @param libraryEntry the entry for the library | 5453 * @param libraryEntry the entry for the library |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5578 dartCopy.setState(DartEntry.SCAN_ERRORS, CacheState.IN_PROCESS); | 5632 dartCopy.setState(DartEntry.SCAN_ERRORS, CacheState.IN_PROCESS); |
| 5579 _cache.put(source, dartCopy); | 5633 _cache.put(source, dartCopy); |
| 5580 return new AnalysisContextImpl_TaskData(new ScanDartTask(this, source, dartC
opy.modificationTime, content), false); | 5634 return new AnalysisContextImpl_TaskData(new ScanDartTask(this, source, dartC
opy.modificationTime, content), false); |
| 5581 } | 5635 } |
| 5582 | 5636 |
| 5583 /** | 5637 /** |
| 5584 * Create a source information object suitable for the given source. Return th
e source information | 5638 * Create a source information object suitable for the given source. Return th
e source information |
| 5585 * object that was created, or `null` if the source should not be tracked by t
his context. | 5639 * object that was created, or `null` if the source should not be tracked by t
his context. |
| 5586 * | 5640 * |
| 5587 * @param source the source for which an information object is being created | 5641 * @param source the source for which an information object is being created |
| 5642 * @param explicitlyAdded `true` if the source was explicitly added to the con
text |
| 5588 * @return the source information object that was created | 5643 * @return the source information object that was created |
| 5589 */ | 5644 */ |
| 5590 SourceEntry _createSourceEntry(Source source) { | 5645 SourceEntry _createSourceEntry(Source source, bool explicitlyAdded) { |
| 5591 String name = source.shortName; | 5646 String name = source.shortName; |
| 5592 if (AnalysisEngine.isHtmlFileName(name)) { | 5647 if (AnalysisEngine.isHtmlFileName(name)) { |
| 5593 HtmlEntryImpl htmlEntry = new HtmlEntryImpl(); | 5648 HtmlEntryImpl htmlEntry = new HtmlEntryImpl(); |
| 5594 htmlEntry.modificationTime = getModificationStamp(source); | 5649 htmlEntry.modificationTime = getModificationStamp(source); |
| 5650 htmlEntry.explicitlyAdded = explicitlyAdded; |
| 5595 _cache.put(source, htmlEntry); | 5651 _cache.put(source, htmlEntry); |
| 5596 return htmlEntry; | 5652 return htmlEntry; |
| 5597 } else { | 5653 } else { |
| 5598 DartEntryImpl dartEntry = new DartEntryImpl(); | 5654 DartEntryImpl dartEntry = new DartEntryImpl(); |
| 5599 dartEntry.modificationTime = getModificationStamp(source); | 5655 dartEntry.modificationTime = getModificationStamp(source); |
| 5656 dartEntry.explicitlyAdded = explicitlyAdded; |
| 5600 _cache.put(source, dartEntry); | 5657 _cache.put(source, dartEntry); |
| 5601 return dartEntry; | 5658 return dartEntry; |
| 5602 } | 5659 } |
| 5603 } | 5660 } |
| 5604 | 5661 |
| 5605 /** | 5662 /** |
| 5606 * Return a string with debugging information about the given source (the full
name and | 5663 * Return a string with debugging information about the given source (the full
name and |
| 5607 * modification stamp of the source). | 5664 * modification stamp of the source). |
| 5608 * | 5665 * |
| 5609 * @param source the source for which a debugging string is to be produced | 5666 * @param source the source for which a debugging string is to be produced |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5928 hasBlockedTask = true; | 5985 hasBlockedTask = true; |
| 5929 } | 5986 } |
| 5930 } | 5987 } |
| 5931 if (_neededForResolution != null) { | 5988 if (_neededForResolution != null) { |
| 5932 List<Source> sourcesToRemove = new List<Source>(); | 5989 List<Source> sourcesToRemove = new List<Source>(); |
| 5933 for (Source source in _neededForResolution) { | 5990 for (Source source in _neededForResolution) { |
| 5934 SourceEntry sourceEntry = _cache.get(source); | 5991 SourceEntry sourceEntry = _cache.get(source); |
| 5935 if (sourceEntry is DartEntry) { | 5992 if (sourceEntry is DartEntry) { |
| 5936 DartEntry dartEntry = sourceEntry; | 5993 DartEntry dartEntry = sourceEntry; |
| 5937 if (!dartEntry.hasResolvableCompilationUnit) { | 5994 if (!dartEntry.hasResolvableCompilationUnit) { |
| 5938 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.
ERROR)) { | 5995 if (dartEntry.getState(DartEntry.PARSED_UNIT) == CacheState.ERROR) { |
| 5939 sourcesToRemove.add(source); | 5996 sourcesToRemove.add(source); |
| 5940 } else { | 5997 } else { |
| 5941 AnalysisContextImpl_TaskData taskData = _createParseDartTask(sourc
e, dartEntry); | 5998 AnalysisContextImpl_TaskData taskData = _createParseDartTask(sourc
e, dartEntry); |
| 5942 AnalysisTask task = taskData.task; | 5999 AnalysisTask task = taskData.task; |
| 5943 if (task != null) { | 6000 if (task != null) { |
| 5944 return task; | 6001 return task; |
| 5945 } else if (taskData.isBlocked) { | 6002 } else if (taskData.isBlocked) { |
| 5946 hasBlockedTask = true; | 6003 hasBlockedTask = true; |
| 5947 } | 6004 } |
| 5948 } | 6005 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6009 * @param sourceEntry the cache entry associated with the source | 6066 * @param sourceEntry the cache entry associated with the source |
| 6010 * @param isPriority `true` if the source is a priority source | 6067 * @param isPriority `true` if the source is a priority source |
| 6011 * @param hintsEnabled `true` if hints are currently enabled | 6068 * @param hintsEnabled `true` if hints are currently enabled |
| 6012 * @return the next task that needs to be performed for the given source | 6069 * @return the next task that needs to be performed for the given source |
| 6013 */ | 6070 */ |
| 6014 AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(Source source, Sour
ceEntry sourceEntry, bool isPriority, bool hintsEnabled) { | 6071 AnalysisContextImpl_TaskData _getNextAnalysisTaskForSource(Source source, Sour
ceEntry sourceEntry, bool isPriority, bool hintsEnabled) { |
| 6015 if (sourceEntry == null) { | 6072 if (sourceEntry == null) { |
| 6016 return new AnalysisContextImpl_TaskData(null, false); | 6073 return new AnalysisContextImpl_TaskData(null, false); |
| 6017 } | 6074 } |
| 6018 CacheState contentState = sourceEntry.getState(SourceEntry.CONTENT); | 6075 CacheState contentState = sourceEntry.getState(SourceEntry.CONTENT); |
| 6019 if (identical(contentState, CacheState.INVALID)) { | 6076 if (contentState == CacheState.INVALID) { |
| 6020 return _createGetContentTask(source, sourceEntry); | 6077 return _createGetContentTask(source, sourceEntry); |
| 6021 } else if (identical(contentState, CacheState.IN_PROCESS)) { | 6078 } else if (contentState == CacheState.IN_PROCESS) { |
| 6022 // We are already in the process of getting the content. There's nothing e
lse we can do with | 6079 // We are already in the process of getting the content. There's nothing e
lse we can do with |
| 6023 // this source until that's complete. | 6080 // this source until that's complete. |
| 6024 return new AnalysisContextImpl_TaskData(null, true); | 6081 return new AnalysisContextImpl_TaskData(null, true); |
| 6025 } else if (identical(contentState, CacheState.ERROR)) { | 6082 } else if (contentState == CacheState.ERROR) { |
| 6026 // We have done all of the analysis we can for this source because we cann
ot get its content. | 6083 // We have done all of the analysis we can for this source because we cann
ot get its content. |
| 6027 return new AnalysisContextImpl_TaskData(null, false); | 6084 return new AnalysisContextImpl_TaskData(null, false); |
| 6028 } | 6085 } |
| 6029 if (sourceEntry is DartEntry) { | 6086 if (sourceEntry is DartEntry) { |
| 6030 DartEntry dartEntry = sourceEntry; | 6087 DartEntry dartEntry = sourceEntry; |
| 6031 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); | 6088 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); |
| 6032 if (identical(scanErrorsState, CacheState.INVALID) || (isPriority && ident
ical(scanErrorsState, CacheState.FLUSHED))) { | 6089 if (scanErrorsState == CacheState.INVALID || (isPriority && scanErrorsStat
e == CacheState.FLUSHED)) { |
| 6033 return _createScanDartTask(source, dartEntry); | 6090 return _createScanDartTask(source, dartEntry); |
| 6034 } | 6091 } |
| 6035 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); | 6092 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); |
| 6036 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { | 6093 if (parseErrorsState == CacheState.INVALID || (isPriority && parseErrorsSt
ate == CacheState.FLUSHED)) { |
| 6037 return _createParseDartTask(source, dartEntry); | 6094 return _createParseDartTask(source, dartEntry); |
| 6038 } | 6095 } |
| 6039 if (isPriority && parseErrorsState != CacheState.ERROR) { | 6096 if (isPriority && parseErrorsState != CacheState.ERROR) { |
| 6040 if (!dartEntry.hasResolvableCompilationUnit) { | 6097 if (!dartEntry.hasResolvableCompilationUnit) { |
| 6041 return _createParseDartTask(source, dartEntry); | 6098 return _createParseDartTask(source, dartEntry); |
| 6042 } | 6099 } |
| 6043 } | 6100 } |
| 6044 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); | 6101 SourceKind kind = dartEntry.getValue(DartEntry.SOURCE_KIND); |
| 6045 if (identical(kind, SourceKind.UNKNOWN)) { | 6102 if (kind == SourceKind.UNKNOWN) { |
| 6046 return _createParseDartTask(source, dartEntry); | 6103 return _createParseDartTask(source, dartEntry); |
| 6047 } else if (identical(kind, SourceKind.LIBRARY)) { | 6104 } else if (kind == SourceKind.LIBRARY) { |
| 6048 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); | 6105 CacheState elementState = dartEntry.getState(DartEntry.ELEMENT); |
| 6049 if (identical(elementState, CacheState.INVALID)) { | 6106 if (elementState == CacheState.INVALID) { |
| 6050 return _createResolveDartLibraryTask(source, dartEntry); | 6107 return _createResolveDartLibraryTask(source, dartEntry); |
| 6051 } | 6108 } |
| 6052 } | 6109 } |
| 6053 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING
_LIBRARIES); | 6110 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING
_LIBRARIES); |
| 6054 for (Source librarySource in librariesContaining) { | 6111 for (Source librarySource in librariesContaining) { |
| 6055 SourceEntry libraryEntry = _cache.get(librarySource); | 6112 SourceEntry librarySourceEntry = _cache.get(librarySource); |
| 6056 if (libraryEntry is DartEntry) { | 6113 if (librarySourceEntry is DartEntry) { |
| 6114 DartEntry libraryEntry = librarySourceEntry; |
| 6057 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); | 6115 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); |
| 6058 if (identical(elementState, CacheState.INVALID) || (isPriority && iden
tical(elementState, CacheState.FLUSHED))) { | 6116 if (elementState == CacheState.INVALID || (isPriority && elementState
== CacheState.FLUSHED)) { |
| 6059 //return createResolveDartLibraryTask(librarySource, (DartEntry) lib
raryEntry); | 6117 //return createResolveDartLibraryTask(librarySource, (DartEntry) lib
raryEntry); |
| 6060 DartEntryImpl libraryCopy = libraryEntry.writableCopy; | 6118 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
| 6061 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); | 6119 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); |
| 6062 _cache.put(librarySource, libraryCopy); | 6120 _cache.put(librarySource, libraryCopy); |
| 6063 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); | 6121 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); |
| 6064 } | 6122 } |
| 6065 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R
ESOLVED_UNIT, librarySource); | 6123 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R
ESOLVED_UNIT, librarySource); |
| 6066 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority &&
identical(resolvedUnitState, CacheState.FLUSHED))) { | 6124 if (resolvedUnitState == CacheState.INVALID || (isPriority && resolved
UnitState == CacheState.FLUSHED)) { |
| 6067 // | 6125 // |
| 6068 // The commented out lines below are an optimization that doesn't qu
ite work yet. The | 6126 // The commented out lines below are an optimization that doesn't qu
ite work yet. The |
| 6069 // problem is that if the source was not resolved because it wasn't
part of any library, | 6127 // problem is that if the source was not resolved because it wasn't
part of any library, |
| 6070 // then there won't be any elements in the element model that we can
use to resolve it. | 6128 // then there won't be any elements in the element model that we can
use to resolve it. |
| 6071 // | 6129 // |
| 6072 //LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); | 6130 //LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); |
| 6073 //if (libraryElement != null) { | 6131 //if (libraryElement != null) { |
| 6074 // return new ResolveDartUnitTask(this, source, libraryElement); | 6132 // return new ResolveDartUnitTask(this, source, libraryElement); |
| 6075 //} | 6133 //} |
| 6076 // Possibly replace with: return createResolveDartLibraryTask(librar
ySource, (DartEntry) libraryEntry); | 6134 // Possibly replace with: return createResolveDartLibraryTask(librar
ySource, (DartEntry) libraryEntry); |
| 6077 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6135 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6078 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, C
acheState.IN_PROCESS); | 6136 dartCopy.setStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource, C
acheState.IN_PROCESS); |
| 6079 _cache.put(source, dartCopy); | 6137 _cache.put(source, dartCopy); |
| 6080 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); | 6138 return new AnalysisContextImpl_TaskData(new ResolveDartLibraryTask(t
his, source, librarySource), false); |
| 6081 } | 6139 } |
| 6082 if (_generateSdkErrors || !source.isInSystemLibrary) { | 6140 if (_generateSdkErrors || !source.isInSystemLibrary) { |
| 6083 CacheState verificationErrorsState = dartEntry.getStateInLibrary(Dar
tEntry.VERIFICATION_ERRORS, librarySource); | 6141 CacheState verificationErrorsState = dartEntry.getStateInLibrary(Dar
tEntry.VERIFICATION_ERRORS, librarySource); |
| 6084 if (identical(verificationErrorsState, CacheState.INVALID) || (isPri
ority && identical(verificationErrorsState, CacheState.FLUSHED))) { | 6142 if (verificationErrorsState == CacheState.INVALID || (isPriority &&
verificationErrorsState == CacheState.FLUSHED)) { |
| 6085 return _createGenerateDartErrorsTask(source, dartEntry, librarySou
rce, libraryEntry); | 6143 return _createGenerateDartErrorsTask(source, dartEntry, librarySou
rce, libraryEntry); |
| 6086 } | 6144 } |
| 6087 if (hintsEnabled) { | 6145 if (hintsEnabled) { |
| 6088 CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINT
S, librarySource); | 6146 CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINT
S, librarySource); |
| 6089 if (identical(hintsState, CacheState.INVALID) || (isPriority && id
entical(hintsState, CacheState.FLUSHED))) { | 6147 if (hintsState == CacheState.INVALID || (isPriority && hintsState
== CacheState.FLUSHED)) { |
| 6090 return _createGenerateDartHintsTask(source, dartEntry, librarySo
urce, libraryEntry); | 6148 return _createGenerateDartHintsTask(source, dartEntry, librarySo
urce, libraryEntry); |
| 6091 } | 6149 } |
| 6092 } | 6150 } |
| 6093 } | 6151 } |
| 6094 } | 6152 } |
| 6095 } | 6153 } |
| 6096 } else if (sourceEntry is HtmlEntry) { | 6154 } else if (sourceEntry is HtmlEntry) { |
| 6097 HtmlEntry htmlEntry = sourceEntry; | 6155 HtmlEntry htmlEntry = sourceEntry; |
| 6098 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); | 6156 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); |
| 6099 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { | 6157 if (parseErrorsState == CacheState.INVALID || (isPriority && parseErrorsSt
ate == CacheState.FLUSHED)) { |
| 6100 return _createParseHtmlTask(source, htmlEntry); | 6158 return _createParseHtmlTask(source, htmlEntry); |
| 6101 } | 6159 } |
| 6102 if (isPriority && parseErrorsState != CacheState.ERROR) { | 6160 if (isPriority && parseErrorsState != CacheState.ERROR) { |
| 6103 ht.HtmlUnit parsedUnit = htmlEntry.anyParsedUnit; | 6161 ht.HtmlUnit parsedUnit = htmlEntry.anyParsedUnit; |
| 6104 if (parsedUnit == null) { | 6162 if (parsedUnit == null) { |
| 6105 return _createParseHtmlTask(source, htmlEntry); | 6163 return _createParseHtmlTask(source, htmlEntry); |
| 6106 } | 6164 } |
| 6107 } | 6165 } |
| 6108 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; | 6166 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; |
| 6109 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { | 6167 if (resolvedUnitState == CacheState.INVALID || (isPriority && resolvedUnit
State == CacheState.FLUSHED)) { |
| 6110 return _createResolveHtmlTask(source, htmlEntry); | 6168 return _createResolveHtmlTask(source, htmlEntry); |
| 6111 } | 6169 } |
| 6112 // | 6170 // |
| 6113 // Angular support | 6171 // Angular support |
| 6114 // | 6172 // |
| 6115 if (_options.analyzeAngular) { | 6173 if (_options.analyzeAngular) { |
| 6116 // Try to resolve the HTML as an Angular entry point. | 6174 // Try to resolve the HTML as an Angular entry point. |
| 6117 CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTR
Y); | 6175 CacheState angularEntryState = htmlEntry.getState(HtmlEntry.ANGULAR_ENTR
Y); |
| 6118 if (identical(angularEntryState, CacheState.INVALID) || (isPriority && i
dentical(angularEntryState, CacheState.FLUSHED))) { | 6176 if (angularEntryState == CacheState.INVALID || (isPriority && angularEnt
ryState == CacheState.FLUSHED)) { |
| 6119 return _createResolveAngularEntryHtmlTask(source, htmlEntry); | 6177 return _createResolveAngularEntryHtmlTask(source, htmlEntry); |
| 6120 } | 6178 } |
| 6121 // Try to resolve the HTML as an Angular application part. | 6179 // Try to resolve the HTML as an Angular application part. |
| 6122 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); | 6180 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); |
| 6123 if (identical(angularErrorsState, CacheState.INVALID) || (isPriority &&
identical(angularErrorsState, CacheState.FLUSHED))) { | 6181 if (angularErrorsState == CacheState.INVALID || (isPriority && angularEr
rorsState == CacheState.FLUSHED)) { |
| 6124 return _createResolveAngularComponentTemplateTask(source, htmlEntry); | 6182 return _createResolveAngularComponentTemplateTask(source, htmlEntry); |
| 6125 } | 6183 } |
| 6126 } | 6184 } |
| 6127 } | 6185 } |
| 6128 return new AnalysisContextImpl_TaskData(null, false); | 6186 return new AnalysisContextImpl_TaskData(null, false); |
| 6129 } | 6187 } |
| 6130 | 6188 |
| 6131 /** | 6189 /** |
| 6132 * Return a change notice for the given source, creating one if one does not a
lready exist. | 6190 * Return a change notice for the given source, creating one if one does not a
lready exist. |
| 6133 * | 6191 * |
| (...skipping 12 matching lines...) Expand all Loading... |
| 6146 /** | 6204 /** |
| 6147 * Return the cache entry associated with the given source, or `null` if the s
ource is not a | 6205 * Return the cache entry associated with the given source, or `null` if the s
ource is not a |
| 6148 * Dart file. | 6206 * Dart file. |
| 6149 * | 6207 * |
| 6150 * @param source the source for which a cache entry is being sought | 6208 * @param source the source for which a cache entry is being sought |
| 6151 * @return the source cache entry associated with the given source | 6209 * @return the source cache entry associated with the given source |
| 6152 */ | 6210 */ |
| 6153 DartEntry _getReadableDartEntry(Source source) { | 6211 DartEntry _getReadableDartEntry(Source source) { |
| 6154 SourceEntry sourceEntry = _cache.get(source); | 6212 SourceEntry sourceEntry = _cache.get(source); |
| 6155 if (sourceEntry == null) { | 6213 if (sourceEntry == null) { |
| 6156 sourceEntry = _createSourceEntry(source); | 6214 sourceEntry = _createSourceEntry(source, false); |
| 6157 } | 6215 } |
| 6158 if (sourceEntry is DartEntry) { | 6216 if (sourceEntry is DartEntry) { |
| 6159 return sourceEntry as DartEntry; | 6217 return sourceEntry as DartEntry; |
| 6160 } | 6218 } |
| 6161 return null; | 6219 return null; |
| 6162 } | 6220 } |
| 6163 | 6221 |
| 6164 /** | 6222 /** |
| 6165 * Return the cache entry associated with the given source, or `null` if the s
ource is not | 6223 * Return the cache entry associated with the given source, or `null` if the s
ource is not |
| 6166 * an HTML file. | 6224 * an HTML file. |
| 6167 * | 6225 * |
| 6168 * @param source the source for which a cache entry is being sought | 6226 * @param source the source for which a cache entry is being sought |
| 6169 * @return the source cache entry associated with the given source | 6227 * @return the source cache entry associated with the given source |
| 6170 */ | 6228 */ |
| 6171 HtmlEntry _getReadableHtmlEntry(Source source) { | 6229 HtmlEntry _getReadableHtmlEntry(Source source) { |
| 6172 SourceEntry sourceEntry = _cache.get(source); | 6230 SourceEntry sourceEntry = _cache.get(source); |
| 6173 if (sourceEntry == null) { | 6231 if (sourceEntry == null) { |
| 6174 sourceEntry = _createSourceEntry(source); | 6232 sourceEntry = _createSourceEntry(source, false); |
| 6175 } | 6233 } |
| 6176 if (sourceEntry is HtmlEntry) { | 6234 if (sourceEntry is HtmlEntry) { |
| 6177 return sourceEntry as HtmlEntry; | 6235 return sourceEntry as HtmlEntry; |
| 6178 } | 6236 } |
| 6179 return null; | 6237 return null; |
| 6180 } | 6238 } |
| 6181 | 6239 |
| 6182 /** | 6240 /** |
| 6183 * Return the cache entry associated with the given source, creating it if nec
essary. | 6241 * Return the cache entry associated with the given source, creating it if nec
essary. |
| 6184 * | 6242 * |
| 6185 * @param source the source for which a cache entry is being sought | 6243 * @param source the source for which a cache entry is being sought |
| 6186 * @return the source cache entry associated with the given source | 6244 * @return the source cache entry associated with the given source |
| 6187 */ | 6245 */ |
| 6188 SourceEntry _getReadableSourceEntry(Source source) { | 6246 SourceEntry _getReadableSourceEntry(Source source) { |
| 6189 SourceEntry sourceEntry = _cache.get(source); | 6247 SourceEntry sourceEntry = _cache.get(source); |
| 6190 if (sourceEntry == null) { | 6248 if (sourceEntry == null) { |
| 6191 sourceEntry = _createSourceEntry(source); | 6249 sourceEntry = _createSourceEntry(source, false); |
| 6192 } | 6250 } |
| 6193 return sourceEntry; | 6251 return sourceEntry; |
| 6194 } | 6252 } |
| 6195 | 6253 |
| 6196 /** | 6254 /** |
| 6197 * Return the cache entry associated with the given source, or `null` if there
is no entry | 6255 * Return the cache entry associated with the given source, or `null` if there
is no entry |
| 6198 * associated with the source. | 6256 * associated with the source. |
| 6199 * | 6257 * |
| 6200 * @param source the source for which a cache entry is being sought | 6258 * @param source the source for which a cache entry is being sought |
| 6201 * @return the source cache entry associated with the given source | 6259 * @return the source cache entry associated with the given source |
| 6202 */ | 6260 */ |
| 6203 SourceEntry _getReadableSourceEntryOrNull(Source source) => _cache.get(source)
; | 6261 SourceEntry _getReadableSourceEntryOrNull(Source source) => _cache.get(source)
; |
| 6204 | 6262 |
| 6205 /** | 6263 /** |
| 6206 * Return a resolved compilation unit corresponding to the given element in th
e given library, or | 6264 * Return a resolved compilation unit corresponding to the given element in th
e given library, or |
| 6207 * `null` if the information is not cached. | 6265 * `null` if the information is not cached. |
| 6208 * | 6266 * |
| 6209 * @param element the element representing the compilation unit | 6267 * @param element the element representing the compilation unit |
| 6210 * @param librarySource the source representing the library containing the uni
t | 6268 * @param librarySource the source representing the library containing the uni
t |
| 6211 * @return the specified resolved compilation unit | 6269 * @return the specified resolved compilation unit |
| 6212 */ | 6270 */ |
| 6213 TimestampedData<CompilationUnit> _getResolvedUnit(CompilationUnitElement eleme
nt, Source librarySource) { | 6271 TimestampedData<CompilationUnit> _getResolvedUnit(CompilationUnitElement eleme
nt, Source librarySource) { |
| 6214 SourceEntry sourceEntry = _cache.get(element.source); | 6272 SourceEntry sourceEntry = _cache.get(element.source); |
| 6215 if (sourceEntry is DartEntry) { | 6273 if (sourceEntry is DartEntry) { |
| 6216 DartEntry dartEntry = sourceEntry; | 6274 DartEntry dartEntry = sourceEntry; |
| 6217 if (identical(dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, library
Source), CacheState.VALID)) { | 6275 if (dartEntry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource) ==
CacheState.VALID) { |
| 6218 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime,
dartEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource)); | 6276 return new TimestampedData<CompilationUnit>(dartEntry.modificationTime,
dartEntry.getValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource)); |
| 6219 } | 6277 } |
| 6220 } | 6278 } |
| 6221 return null; | 6279 return null; |
| 6222 } | 6280 } |
| 6223 | 6281 |
| 6224 /** | 6282 /** |
| 6225 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 6283 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
| 6226 * | 6284 * |
| 6227 * @param kind the kind of sources to be returned | 6285 * @param kind the kind of sources to be returned |
| 6228 * @return all of the sources known to this context that have the given kind | 6286 * @return all of the sources known to this context that have the given kind |
| 6229 */ | 6287 */ |
| 6230 List<Source> _getSources(SourceKind kind) { | 6288 List<Source> _getSources(SourceKind kind) { |
| 6231 List<Source> sources = new List<Source>(); | 6289 List<Source> sources = new List<Source>(); |
| 6232 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 6290 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 6233 if (identical(entry.getValue().kind, kind)) { | 6291 if (entry.getValue().kind == kind) { |
| 6234 sources.add(entry.getKey()); | 6292 sources.add(entry.getKey()); |
| 6235 } | 6293 } |
| 6236 } | 6294 } |
| 6237 return new List.from(sources); | 6295 return new List.from(sources); |
| 6238 } | 6296 } |
| 6239 | 6297 |
| 6240 /** | 6298 /** |
| 6241 * Look at the given source to see whether a task needs to be performed relate
d to it. If so, add | 6299 * Look at the given source to see whether a task needs to be performed relate
d to it. If so, add |
| 6242 * the source to the set of sources that need to be processed. This method dup
licates, and must | 6300 * the source to the set of sources that need to be processed. This method dup
licates, and must |
| 6243 * therefore be kept in sync with, | 6301 * therefore be kept in sync with, |
| 6244 * [getNextAnalysisTask]. This method is intended to | 6302 * [getNextAnalysisTask]. This method is intended to |
| 6245 * be used for testing purposes only. | 6303 * be used for testing purposes only. |
| 6246 * | 6304 * |
| 6247 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 6305 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 6248 * | 6306 * |
| 6249 * @param source the source to be checked | 6307 * @param source the source to be checked |
| 6250 * @param sourceEntry the cache entry associated with the source | 6308 * @param sourceEntry the cache entry associated with the source |
| 6251 * @param isPriority `true` if the source is a priority source | 6309 * @param isPriority `true` if the source is a priority source |
| 6252 * @param hintsEnabled `true` if hints are currently enabled | 6310 * @param hintsEnabled `true` if hints are currently enabled |
| 6253 * @param sources the set to which sources should be added | 6311 * @param sources the set to which sources should be added |
| 6254 */ | 6312 */ |
| 6255 void _getSourcesNeedingProcessing(Source source, SourceEntry sourceEntry, bool
isPriority, bool hintsEnabled, Set<Source> sources) { | 6313 void _getSourcesNeedingProcessing(Source source, SourceEntry sourceEntry, bool
isPriority, bool hintsEnabled, Set<Source> sources) { |
| 6256 if (sourceEntry is DartEntry) { | 6314 if (sourceEntry is DartEntry) { |
| 6257 DartEntry dartEntry = sourceEntry; | 6315 DartEntry dartEntry = sourceEntry; |
| 6258 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); | 6316 CacheState scanErrorsState = dartEntry.getState(DartEntry.SCAN_ERRORS); |
| 6259 if (identical(scanErrorsState, CacheState.INVALID) || (isPriority && ident
ical(scanErrorsState, CacheState.FLUSHED))) { | 6317 if (scanErrorsState == CacheState.INVALID || (isPriority && scanErrorsStat
e == CacheState.FLUSHED)) { |
| 6260 sources.add(source); | 6318 sources.add(source); |
| 6261 return; | 6319 return; |
| 6262 } | 6320 } |
| 6263 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); | 6321 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); |
| 6264 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { | 6322 if (parseErrorsState == CacheState.INVALID || (isPriority && parseErrorsSt
ate == CacheState.FLUSHED)) { |
| 6265 sources.add(source); | 6323 sources.add(source); |
| 6266 return; | 6324 return; |
| 6267 } | 6325 } |
| 6268 if (isPriority) { | 6326 if (isPriority) { |
| 6269 if (!dartEntry.hasResolvableCompilationUnit) { | 6327 if (!dartEntry.hasResolvableCompilationUnit) { |
| 6270 sources.add(source); | 6328 sources.add(source); |
| 6271 return; | 6329 return; |
| 6272 } | 6330 } |
| 6273 } | 6331 } |
| 6274 for (Source librarySource in getLibrariesContaining(source)) { | 6332 for (Source librarySource in getLibrariesContaining(source)) { |
| 6275 SourceEntry libraryEntry = _cache.get(librarySource); | 6333 SourceEntry libraryEntry = _cache.get(librarySource); |
| 6276 if (libraryEntry is DartEntry) { | 6334 if (libraryEntry is DartEntry) { |
| 6277 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); | 6335 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); |
| 6278 if (identical(elementState, CacheState.INVALID) || (isPriority && iden
tical(elementState, CacheState.FLUSHED))) { | 6336 if (elementState == CacheState.INVALID || (isPriority && elementState
== CacheState.FLUSHED)) { |
| 6279 sources.add(source); | 6337 sources.add(source); |
| 6280 return; | 6338 return; |
| 6281 } | 6339 } |
| 6282 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R
ESOLVED_UNIT, librarySource); | 6340 CacheState resolvedUnitState = dartEntry.getStateInLibrary(DartEntry.R
ESOLVED_UNIT, librarySource); |
| 6283 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority &&
identical(resolvedUnitState, CacheState.FLUSHED))) { | 6341 if (resolvedUnitState == CacheState.INVALID || (isPriority && resolved
UnitState == CacheState.FLUSHED)) { |
| 6284 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEM
ENT); | 6342 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEM
ENT); |
| 6285 if (libraryElement != null) { | 6343 if (libraryElement != null) { |
| 6286 sources.add(source); | 6344 sources.add(source); |
| 6287 return; | 6345 return; |
| 6288 } | 6346 } |
| 6289 } | 6347 } |
| 6290 CacheState verificationErrorsState = dartEntry.getStateInLibrary(DartE
ntry.VERIFICATION_ERRORS, librarySource); | 6348 CacheState verificationErrorsState = dartEntry.getStateInLibrary(DartE
ntry.VERIFICATION_ERRORS, librarySource); |
| 6291 if (identical(verificationErrorsState, CacheState.INVALID) || (isPrior
ity && identical(verificationErrorsState, CacheState.FLUSHED))) { | 6349 if (verificationErrorsState == CacheState.INVALID || (isPriority && ve
rificationErrorsState == CacheState.FLUSHED)) { |
| 6292 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEM
ENT); | 6350 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.ELEM
ENT); |
| 6293 if (libraryElement != null) { | 6351 if (libraryElement != null) { |
| 6294 sources.add(source); | 6352 sources.add(source); |
| 6295 return; | 6353 return; |
| 6296 } | 6354 } |
| 6297 } | 6355 } |
| 6298 if (hintsEnabled) { | 6356 if (hintsEnabled) { |
| 6299 CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINTS,
librarySource); | 6357 CacheState hintsState = dartEntry.getStateInLibrary(DartEntry.HINTS,
librarySource); |
| 6300 if (identical(hintsState, CacheState.INVALID) || (isPriority && iden
tical(hintsState, CacheState.FLUSHED))) { | 6358 if (hintsState == CacheState.INVALID || (isPriority && hintsState ==
CacheState.FLUSHED)) { |
| 6301 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); | 6359 LibraryElement libraryElement = libraryEntry.getValue(DartEntry.EL
EMENT); |
| 6302 if (libraryElement != null) { | 6360 if (libraryElement != null) { |
| 6303 sources.add(source); | 6361 sources.add(source); |
| 6304 return; | 6362 return; |
| 6305 } | 6363 } |
| 6306 } | 6364 } |
| 6307 } | 6365 } |
| 6308 } | 6366 } |
| 6309 } | 6367 } |
| 6310 } else if (sourceEntry is HtmlEntry) { | 6368 } else if (sourceEntry is HtmlEntry) { |
| 6311 HtmlEntry htmlEntry = sourceEntry; | 6369 HtmlEntry htmlEntry = sourceEntry; |
| 6312 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); | 6370 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); |
| 6313 if (identical(parsedUnitState, CacheState.INVALID) || (isPriority && ident
ical(parsedUnitState, CacheState.FLUSHED))) { | 6371 if (parsedUnitState == CacheState.INVALID || (isPriority && parsedUnitStat
e == CacheState.FLUSHED)) { |
| 6314 sources.add(source); | 6372 sources.add(source); |
| 6315 return; | 6373 return; |
| 6316 } | 6374 } |
| 6317 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; | 6375 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; |
| 6318 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { | 6376 if (resolvedUnitState == CacheState.INVALID || (isPriority && resolvedUnit
State == CacheState.FLUSHED)) { |
| 6319 sources.add(source); | 6377 sources.add(source); |
| 6320 return; | 6378 return; |
| 6321 } | 6379 } |
| 6322 // Angular | 6380 // Angular |
| 6323 if (_options.analyzeAngular) { | 6381 if (_options.analyzeAngular) { |
| 6324 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); | 6382 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERR
ORS); |
| 6325 if (identical(angularErrorsState, CacheState.INVALID) || (isPriority &&
identical(angularErrorsState, CacheState.FLUSHED))) { | 6383 if (angularErrorsState == CacheState.INVALID || (isPriority && angularEr
rorsState == CacheState.FLUSHED)) { |
| 6326 AngularApplication entryInfo = htmlEntry.getValue(HtmlEntry.ANGULAR_EN
TRY); | 6384 AngularApplication entryInfo = htmlEntry.getValue(HtmlEntry.ANGULAR_EN
TRY); |
| 6327 if (entryInfo != null) { | 6385 if (entryInfo != null) { |
| 6328 sources.add(source); | 6386 sources.add(source); |
| 6329 return; | 6387 return; |
| 6330 } | 6388 } |
| 6331 AngularApplication applicationInfo = htmlEntry.getValue(HtmlEntry.ANGU
LAR_APPLICATION); | 6389 AngularApplication applicationInfo = htmlEntry.getValue(HtmlEntry.ANGU
LAR_APPLICATION); |
| 6332 if (applicationInfo != null) { | 6390 if (applicationInfo != null) { |
| 6333 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANG
ULAR_COMPONENT); | 6391 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANG
ULAR_COMPONENT); |
| 6334 if (component != null) { | 6392 if (component != null) { |
| 6335 sources.add(source); | 6393 sources.add(source); |
| 6336 return; | 6394 return; |
| 6337 } | 6395 } |
| 6338 } | 6396 } |
| 6339 } | 6397 } |
| 6340 } | 6398 } |
| 6341 } | 6399 } |
| 6342 } | 6400 } |
| 6343 | 6401 |
| 6344 /** | 6402 /** |
| 6345 * Invalidate all of the resolution results computed by this context. | 6403 * Invalidate all of the resolution results computed by this context. |
| 6346 * | 6404 * |
| 6347 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 6405 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 6348 */ | 6406 */ |
| 6349 void _invalidateAllResolutionInformation() { | 6407 void _invalidateAllResolutionInformation() { |
| 6408 Map<Source, List<Source>> oldPartMap = new Map<Source, List<Source>>(); |
| 6350 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 6409 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
| 6351 Source source = mapEntry.getKey(); | 6410 Source source = mapEntry.getKey(); |
| 6352 SourceEntry sourceEntry = mapEntry.getValue(); | 6411 SourceEntry sourceEntry = mapEntry.getValue(); |
| 6353 if (sourceEntry is HtmlEntry) { | 6412 if (sourceEntry is HtmlEntry) { |
| 6354 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 6413 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 6355 htmlCopy.invalidateAllResolutionInformation(); | 6414 htmlCopy.invalidateAllResolutionInformation(); |
| 6356 mapEntry.setValue(htmlCopy); | 6415 mapEntry.setValue(htmlCopy); |
| 6357 } else if (sourceEntry is DartEntry) { | 6416 } else if (sourceEntry is DartEntry) { |
| 6358 DartEntry dartEntry = sourceEntry; | 6417 DartEntry dartEntry = sourceEntry; |
| 6359 _removeFromParts(source, dartEntry); | 6418 oldPartMap[source] = dartEntry.getValue(DartEntry.INCLUDED_PARTS); |
| 6360 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6419 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6361 dartCopy.invalidateAllResolutionInformation(); | 6420 dartCopy.invalidateAllResolutionInformation(); |
| 6362 mapEntry.setValue(dartCopy); | 6421 mapEntry.setValue(dartCopy); |
| 6363 _workManager.add(source, SourcePriority.UNKNOWN); | 6422 _workManager.add(source, SourcePriority.UNKNOWN); |
| 6364 } | 6423 } |
| 6365 } | 6424 } |
| 6425 _removeFromPartsUsingMap(oldPartMap); |
| 6366 } | 6426 } |
| 6367 | 6427 |
| 6368 /** | 6428 /** |
| 6369 * In response to a change to Angular entry point [HtmlElement], invalidate an
y results that | 6429 * In response to a change to Angular entry point [HtmlElement], invalidate an
y results that |
| 6370 * depend on it. | 6430 * depend on it. |
| 6371 * | 6431 * |
| 6372 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 6432 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 6373 * | 6433 * |
| 6374 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be | 6434 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be |
| 6375 * re-accessed after this method returns. | 6435 * re-accessed after this method returns. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6402 } | 6462 } |
| 6403 } | 6463 } |
| 6404 // reset Dart sources | 6464 // reset Dart sources |
| 6405 List<Source> oldElementSources = application.elementSources; | 6465 List<Source> oldElementSources = application.elementSources; |
| 6406 for (Source elementSource in oldElementSources) { | 6466 for (Source elementSource in oldElementSources) { |
| 6407 DartEntry dartEntry = _getReadableDartEntry(elementSource); | 6467 DartEntry dartEntry = _getReadableDartEntry(elementSource); |
| 6408 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6468 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6409 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); | 6469 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); |
| 6410 _cache.put(elementSource, dartCopy); | 6470 _cache.put(elementSource, dartCopy); |
| 6411 // notify about (disappeared) Angular errors | 6471 // notify about (disappeared) Angular errors |
| 6412 if (_generateSdkErrors || !elementSource.isInSystemLibrary) { | 6472 ChangeNoticeImpl notice = _getNotice(elementSource); |
| 6413 ChangeNoticeImpl notice = _getNotice(elementSource); | 6473 notice.setErrors(dartCopy.allErrors, dartEntry.getValue(SourceEntry.LINE_I
NFO)); |
| 6414 notice.setErrors(dartCopy.allErrors, dartEntry.getValue(SourceEntry.LINE
_INFO)); | |
| 6415 } | |
| 6416 } | 6474 } |
| 6417 } | 6475 } |
| 6418 | 6476 |
| 6419 /** | 6477 /** |
| 6420 * In response to a change to at least one of the compilation units in the giv
en library, | 6478 * In response to a change to at least one of the compilation units in the giv
en library, |
| 6421 * invalidate any results that are dependent on the result of resolving that l
ibrary. | 6479 * invalidate any results that are dependent on the result of resolving that l
ibrary. |
| 6422 * | 6480 * |
| 6423 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 6481 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 6424 * | 6482 * |
| 6425 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be | 6483 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be |
| 6426 * re-accessed after this method returns. | 6484 * re-accessed after this method returns. |
| 6427 * | 6485 * |
| 6428 * @param librarySource the source of the library being invalidated | 6486 * @param librarySource the source of the library being invalidated |
| 6429 * @param writer the writer to which debugging information should be written | |
| 6430 */ | 6487 */ |
| 6431 void _invalidateLibraryResolution(Source librarySource, PrintStringWriter writ
er) { | 6488 void _invalidateLibraryResolution(Source librarySource) { |
| 6432 // TODO(brianwilkerson) This could be optimized. There's no need to flush al
l of these caches if | 6489 // TODO(brianwilkerson) This could be optimized. There's no need to flush al
l of these entries |
| 6433 // the public namespace hasn't changed, which will be a fairly common case.
The question is | 6490 // if the public namespace hasn't changed, which will be a fairly common cas
e. The question is |
| 6434 // whether we can afford the time to compute the namespace to look for diffe
rences. | 6491 // whether we can afford the time to compute the namespace to look for diffe
rences. |
| 6435 DartEntry libraryEntry = _getReadableDartEntry(librarySource); | 6492 DartEntry libraryEntry = _getReadableDartEntry(librarySource); |
| 6436 if (libraryEntry != null) { | 6493 if (libraryEntry != null) { |
| 6437 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); | 6494 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); |
| 6438 DartEntryImpl libraryCopy = libraryEntry.writableCopy; | 6495 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
| 6439 // long oldTime = libraryCopy.getModificationTime(); | |
| 6440 libraryCopy.invalidateAllResolutionInformation(); | 6496 libraryCopy.invalidateAllResolutionInformation(); |
| 6441 _cache.put(librarySource, libraryCopy); | 6497 _cache.put(librarySource, libraryCopy); |
| 6442 _workManager.add(librarySource, SourcePriority.LIBRARY); | 6498 _workManager.add(librarySource, SourcePriority.LIBRARY); |
| 6443 // if (writer != null) { | |
| 6444 // writer.println(" Invalidated library source: " + debuggingStrin
g(librarySource) | |
| 6445 // + " (previously modified at " + oldTime + ")"); | |
| 6446 // } | |
| 6447 for (Source partSource in includedParts) { | 6499 for (Source partSource in includedParts) { |
| 6448 SourceEntry partEntry = _cache.get(partSource); | 6500 SourceEntry partEntry = _cache.get(partSource); |
| 6449 if (partEntry is DartEntry) { | 6501 if (partEntry is DartEntry) { |
| 6450 DartEntryImpl partCopy = partEntry.writableCopy; | 6502 DartEntryImpl partCopy = partEntry.writableCopy; |
| 6451 // oldTime = partCopy.getModificationTime(); | |
| 6452 if (partEntry != libraryCopy) { | |
| 6453 partCopy.removeContainingLibrary(librarySource); | |
| 6454 _workManager.add(librarySource, SourcePriority.NORMAL_PART); | |
| 6455 } | |
| 6456 partCopy.invalidateAllResolutionInformation(); | 6503 partCopy.invalidateAllResolutionInformation(); |
| 6457 _cache.put(partSource, partCopy); | 6504 _cache.put(partSource, partCopy); |
| 6458 } | 6505 } |
| 6459 } | 6506 } |
| 6460 } | 6507 } |
| 6461 // invalidate Angular applications | 6508 // invalidate Angular applications |
| 6462 List<AngularApplication> angularApplicationsCopy = []; | 6509 List<AngularApplication> angularApplicationsCopy = []; |
| 6463 for (AngularApplication application in angularApplicationsCopy) { | 6510 for (AngularApplication application in angularApplicationsCopy) { |
| 6464 if (application.dependsOn(librarySource)) { | 6511 if (application.dependsOn(librarySource)) { |
| 6465 Source entryPointSource = application.entryPoint; | 6512 Source entryPointSource = application.entryPoint; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6555 } | 6602 } |
| 6556 } | 6603 } |
| 6557 // update Dart sources errors | 6604 // update Dart sources errors |
| 6558 List<Source> newElementSources = application.elementSources; | 6605 List<Source> newElementSources = application.elementSources; |
| 6559 for (Source elementSource in newElementSources) { | 6606 for (Source elementSource in newElementSources) { |
| 6560 DartEntry dartEntry = _getReadableDartEntry(elementSource); | 6607 DartEntry dartEntry = _getReadableDartEntry(elementSource); |
| 6561 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6608 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6562 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSource
)); | 6609 dartCopy.setValue(DartEntry.ANGULAR_ERRORS, task.getErrors(elementSource
)); |
| 6563 _cache.put(elementSource, dartCopy); | 6610 _cache.put(elementSource, dartCopy); |
| 6564 // notify about Dart errors | 6611 // notify about Dart errors |
| 6565 if (_generateSdkErrors || !elementSource.isInSystemLibrary) { | 6612 ChangeNoticeImpl notice = _getNotice(elementSource); |
| 6566 ChangeNoticeImpl notice = _getNotice(elementSource); | 6613 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource)); |
| 6567 notice.setErrors(dartCopy.allErrors, computeLineInfo(elementSource)); | |
| 6568 } | |
| 6569 } | 6614 } |
| 6570 } | 6615 } |
| 6571 // remember Angular entry point | 6616 // remember Angular entry point |
| 6572 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); | 6617 entry.setValue(HtmlEntry.ANGULAR_ENTRY, application); |
| 6573 } | 6618 } |
| 6574 | 6619 |
| 6575 /** | 6620 /** |
| 6576 * Given a cache entry and a library element, record the library element and o
ther information | 6621 * Given a cache entry and a library element, record the library element and o
ther information |
| 6577 * gleaned from the element in the cache entry. | 6622 * gleaned from the element in the cache entry. |
| 6578 * | 6623 * |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6617 // The source has changed without the context being notified. Simulate n
otification. | 6662 // The source has changed without the context being notified. Simulate n
otification. |
| 6618 _sourceChanged(source); | 6663 _sourceChanged(source); |
| 6619 dartEntry = _getReadableDartEntry(source); | 6664 dartEntry = _getReadableDartEntry(source); |
| 6620 if (dartEntry == null) { | 6665 if (dartEntry == null) { |
| 6621 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); | 6666 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 6622 } | 6667 } |
| 6623 } | 6668 } |
| 6624 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6669 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6625 if (thrownException == null) { | 6670 if (thrownException == null) { |
| 6626 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
task.errors); | 6671 dartCopy.setValueInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
task.errors); |
| 6627 if (_generateSdkErrors || !source.isInSystemLibrary) { | 6672 ChangeNoticeImpl notice = _getNotice(source); |
| 6628 ChangeNoticeImpl notice = _getNotice(source); | 6673 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LINE_
INFO)); |
| 6629 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN
E_INFO)); | |
| 6630 } | |
| 6631 } else { | 6674 } else { |
| 6632 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
CacheState.ERROR); | 6675 dartCopy.setStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource,
CacheState.ERROR); |
| 6633 } | 6676 } |
| 6634 dartCopy.exception = thrownException; | 6677 dartCopy.exception = thrownException; |
| 6635 _cache.put(source, dartCopy); | 6678 _cache.put(source, dartCopy); |
| 6636 dartEntry = dartCopy; | 6679 dartEntry = dartCopy; |
| 6637 } else { | 6680 } else { |
| 6638 _logInformation2("Generated errors discarded for ${_debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn
try.modificationTime}", thrownException); | 6681 _logInformation2("Generated errors discarded for ${_debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn
try.modificationTime}", thrownException); |
| 6639 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6682 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6640 if (thrownException == null || resultTime >= 0) { | 6683 if (thrownException == null || resultTime >= 0) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6719 // The source has changed without the context being notified. Simulate
notification. | 6762 // The source has changed without the context being notified. Simulate
notification. |
| 6720 _sourceChanged(unitSource); | 6763 _sourceChanged(unitSource); |
| 6721 dartEntry = _getReadableDartEntry(unitSource); | 6764 dartEntry = _getReadableDartEntry(unitSource); |
| 6722 if (dartEntry == null) { | 6765 if (dartEntry == null) { |
| 6723 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); | 6766 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); |
| 6724 } | 6767 } |
| 6725 } | 6768 } |
| 6726 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6769 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6727 if (thrownException == null) { | 6770 if (thrownException == null) { |
| 6728 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, results.dat
a); | 6771 dartCopy.setValueInLibrary(DartEntry.HINTS, librarySource, results.dat
a); |
| 6729 if (_generateSdkErrors || !unitSource.isInSystemLibrary) { | 6772 ChangeNoticeImpl notice = _getNotice(unitSource); |
| 6730 ChangeNoticeImpl notice = _getNotice(unitSource); | 6773 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.LIN
E_INFO)); |
| 6731 notice.setErrors(dartCopy.allErrors, dartCopy.getValue(SourceEntry.L
INE_INFO)); | |
| 6732 } | |
| 6733 } else { | 6774 } else { |
| 6734 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.
ERROR); | 6775 dartCopy.setStateInLibrary(DartEntry.HINTS, librarySource, CacheState.
ERROR); |
| 6735 } | 6776 } |
| 6736 dartCopy.exception = thrownException; | 6777 dartCopy.exception = thrownException; |
| 6737 _cache.put(unitSource, dartCopy); | 6778 _cache.put(unitSource, dartCopy); |
| 6738 dartEntry = dartCopy; | 6779 dartEntry = dartCopy; |
| 6739 } else { | 6780 } else { |
| 6740 _logInformation2("Generated hints discarded for ${_debuggingString(unitS
ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d
artEntry.modificationTime}", thrownException); | 6781 _logInformation2("Generated hints discarded for ${_debuggingString(unitS
ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d
artEntry.modificationTime}", thrownException); |
| 6741 if (identical(dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource
), CacheState.IN_PROCESS)) { | 6782 if (dartEntry.getStateInLibrary(DartEntry.HINTS, librarySource) == Cache
State.IN_PROCESS) { |
| 6742 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6783 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6743 if (thrownException == null || resultTime >= 0) { | 6784 if (thrownException == null || resultTime >= 0) { |
| 6744 // | 6785 // |
| 6745 // The analysis was performed on out-of-date sources. Mark the cache
so that the sources | 6786 // The analysis was performed on out-of-date sources. Mark the cache
so that the sources |
| 6746 // will be re-analyzed using the up-to-date sources. | 6787 // will be re-analyzed using the up-to-date sources. |
| 6747 // | 6788 // |
| 6748 // dartCopy.setState(DartEntry.HINTS, librarySource, Ca
cheState.INVALID); | 6789 // dartCopy.setState(DartEntry.HINTS, librarySource, Ca
cheState.INVALID); |
| 6749 _removeFromParts(unitSource, dartEntry); | 6790 _removeFromParts(unitSource, dartEntry); |
| 6750 dartCopy.invalidateAllInformation(); | 6791 dartCopy.invalidateAllInformation(); |
| 6751 dartCopy.modificationTime = sourceTime; | 6792 dartCopy.modificationTime = sourceTime; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6809 /** | 6850 /** |
| 6810 * Record the results produced by performing a [IncrementalAnalysisTask]. | 6851 * Record the results produced by performing a [IncrementalAnalysisTask]. |
| 6811 * | 6852 * |
| 6812 * @param task the task that was performed | 6853 * @param task the task that was performed |
| 6813 * @return an entry containing the computed results | 6854 * @return an entry containing the computed results |
| 6814 * @throws AnalysisException if the results could not be recorded | 6855 * @throws AnalysisException if the results could not be recorded |
| 6815 */ | 6856 */ |
| 6816 DartEntry _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task)
{ | 6857 DartEntry _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task)
{ |
| 6817 CompilationUnit unit = task.compilationUnit; | 6858 CompilationUnit unit = task.compilationUnit; |
| 6818 if (unit != null) { | 6859 if (unit != null) { |
| 6819 if (_generateSdkErrors || !task.source.isInSystemLibrary) { | 6860 ChangeNoticeImpl notice = _getNotice(task.source); |
| 6820 ChangeNoticeImpl notice = _getNotice(task.source); | 6861 notice.compilationUnit = unit; |
| 6821 notice.compilationUnit = unit; | |
| 6822 } | |
| 6823 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.cach
e, unit); | 6862 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.cach
e, unit); |
| 6824 } | 6863 } |
| 6825 return null; | 6864 return null; |
| 6826 } | 6865 } |
| 6827 | 6866 |
| 6828 /** | 6867 /** |
| 6829 * Record the results produced by performing a [ParseDartTask]. If the results
were computed | 6868 * Record the results produced by performing a [ParseDartTask]. If the results
were computed |
| 6830 * from data that is now out-of-date, then the results will not be recorded. | 6869 * from data that is now out-of-date, then the results will not be recorded. |
| 6831 * | 6870 * |
| 6832 * @param task the task that was performed | 6871 * @param task the task that was performed |
| (...skipping 20 matching lines...) Expand all Loading... |
| 6853 // The source has changed without the context being notified. Simulate n
otification. | 6892 // The source has changed without the context being notified. Simulate n
otification. |
| 6854 _sourceChanged(source); | 6893 _sourceChanged(source); |
| 6855 dartEntry = _getReadableDartEntry(source); | 6894 dartEntry = _getReadableDartEntry(source); |
| 6856 if (dartEntry == null) { | 6895 if (dartEntry == null) { |
| 6857 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); | 6896 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${source.fullName}"); |
| 6858 } | 6897 } |
| 6859 } | 6898 } |
| 6860 _removeFromParts(source, dartEntry); | 6899 _removeFromParts(source, dartEntry); |
| 6861 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6900 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 6862 if (thrownException == null) { | 6901 if (thrownException == null) { |
| 6863 if (task.hasPartOfDirective && !task.hasLibraryDirective) { | 6902 if (task.hasNonPartOfDirective) { |
| 6903 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 6904 dartCopy.containingLibrary = source; |
| 6905 _workManager.add(source, SourcePriority.LIBRARY); |
| 6906 } else if (task.hasPartOfDirective) { |
| 6864 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); | 6907 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
| 6865 dartCopy.removeContainingLibrary(source); | 6908 dartCopy.removeContainingLibrary(source); |
| 6866 _workManager.add(source, SourcePriority.NORMAL_PART); | 6909 _workManager.add(source, SourcePriority.NORMAL_PART); |
| 6867 } else { | 6910 } else { |
| 6868 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 6911 // The file contains no directives. |
| 6869 dartCopy.containingLibrary = source; | 6912 List<Source> containingLibraries = dartCopy.containingLibraries; |
| 6870 _workManager.add(source, SourcePriority.LIBRARY); | 6913 if (containingLibraries.length > 1 || (containingLibraries.length == 1
&& containingLibraries[0] != source)) { |
| 6914 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
| 6915 dartCopy.removeContainingLibrary(source); |
| 6916 _workManager.add(source, SourcePriority.NORMAL_PART); |
| 6917 } else { |
| 6918 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 6919 dartCopy.containingLibrary = source; |
| 6920 _workManager.add(source, SourcePriority.LIBRARY); |
| 6921 } |
| 6871 } | 6922 } |
| 6872 List<Source> newParts = task.includedSources; | 6923 List<Source> newParts = task.includedSources; |
| 6873 for (int i = 0; i < newParts.length; i++) { | 6924 for (int i = 0; i < newParts.length; i++) { |
| 6874 Source partSource = newParts[i]; | 6925 Source partSource = newParts[i]; |
| 6875 DartEntry partEntry = _getReadableDartEntry(partSource); | 6926 DartEntry partEntry = _getReadableDartEntry(partSource); |
| 6876 if (partEntry != null && partEntry != dartEntry) { | 6927 if (partEntry != null && !identical(partEntry, dartEntry)) { |
| 6877 DartEntryImpl partCopy = partEntry.writableCopy; | 6928 DartEntryImpl partCopy = partEntry.writableCopy; |
| 6929 // TODO(brianwilkerson) Change the kind of the "part" if it was mark
ed as a library |
| 6930 // and it has no directives. |
| 6878 partCopy.addContainingLibrary(source); | 6931 partCopy.addContainingLibrary(source); |
| 6879 _cache.put(partSource, partCopy); | 6932 _cache.put(partSource, partCopy); |
| 6880 } | 6933 } |
| 6881 } | 6934 } |
| 6882 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); | 6935 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); |
| 6883 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); | 6936 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); |
| 6884 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); | 6937 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); |
| 6885 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); | 6938 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); |
| 6886 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); | 6939 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); |
| 6887 _cache.storedAst(source); | 6940 _cache.storedAst(source); |
| 6888 if (_generateSdkErrors || !source.isInSystemLibrary) { | 6941 ChangeNoticeImpl notice = _getNotice(source); |
| 6889 ChangeNoticeImpl notice = _getNotice(source); | 6942 notice.setErrors(dartCopy.allErrors, task.lineInfo); |
| 6890 notice.setErrors(dartCopy.allErrors, task.lineInfo); | |
| 6891 } | |
| 6892 // Verify that the incrementally parsed and resolved unit in the increme
ntal cache | 6943 // Verify that the incrementally parsed and resolved unit in the increme
ntal cache |
| 6893 // is structurally equivalent to the fully parsed unit | 6944 // is structurally equivalent to the fully parsed unit |
| 6894 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in
crementalAnalysisCache, source, task.compilationUnit); | 6945 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_in
crementalAnalysisCache, source, task.compilationUnit); |
| 6895 } else { | 6946 } else { |
| 6896 _removeFromParts(source, dartEntry); | 6947 _removeFromParts(source, dartEntry); |
| 6897 dartCopy.recordParseError(); | 6948 dartCopy.recordParseError(); |
| 6898 _cache.removedAst(source); | 6949 _cache.removedAst(source); |
| 6899 } | 6950 } |
| 6900 dartCopy.exception = thrownException; | 6951 dartCopy.exception = thrownException; |
| 6901 _cache.put(source, dartCopy); | 6952 _cache.put(source, dartCopy); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6966 } | 7017 } |
| 6967 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 7018 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
| 6968 if (thrownException == null) { | 7019 if (thrownException == null) { |
| 6969 LineInfo lineInfo = task.lineInfo; | 7020 LineInfo lineInfo = task.lineInfo; |
| 6970 ht.HtmlUnit unit = task.htmlUnit; | 7021 ht.HtmlUnit unit = task.htmlUnit; |
| 6971 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 7022 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 6972 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); | 7023 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); |
| 6973 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); | 7024 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); |
| 6974 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrari
es); | 7025 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibrari
es); |
| 6975 _cache.storedAst(source); | 7026 _cache.storedAst(source); |
| 6976 if (_generateSdkErrors || !source.isInSystemLibrary) { | 7027 ChangeNoticeImpl notice = _getNotice(source); |
| 6977 ChangeNoticeImpl notice = _getNotice(source); | 7028 notice.setErrors(htmlCopy.allErrors, lineInfo); |
| 6978 notice.setErrors(htmlCopy.allErrors, lineInfo); | |
| 6979 } | |
| 6980 } else { | 7029 } else { |
| 6981 htmlCopy.recordParseError(); | 7030 htmlCopy.recordParseError(); |
| 6982 _cache.removedAst(source); | 7031 _cache.removedAst(source); |
| 6983 } | 7032 } |
| 6984 htmlCopy.exception = thrownException; | 7033 htmlCopy.exception = thrownException; |
| 6985 _cache.put(source, htmlCopy); | 7034 _cache.put(source, htmlCopy); |
| 6986 htmlEntry = htmlCopy; | 7035 htmlEntry = htmlCopy; |
| 6987 } else { | 7036 } else { |
| 6988 _logInformation2("Parse results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry
.modificationTime}", thrownException); | 7037 _logInformation2("Parse results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry
.modificationTime}", thrownException); |
| 6989 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 7038 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7053 _sourceChanged(source); | 7102 _sourceChanged(source); |
| 7054 htmlEntry = _getReadableHtmlEntry(source); | 7103 htmlEntry = _getReadableHtmlEntry(source); |
| 7055 if (htmlEntry == null) { | 7104 if (htmlEntry == null) { |
| 7056 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 7105 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 7057 } | 7106 } |
| 7058 } | 7107 } |
| 7059 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7108 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 7060 if (thrownException == null) { | 7109 if (thrownException == null) { |
| 7061 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); | 7110 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); |
| 7062 // notify about errors | 7111 // notify about errors |
| 7063 if (_generateSdkErrors || !source.isInSystemLibrary) { | 7112 ChangeNoticeImpl notice = _getNotice(source); |
| 7064 ChangeNoticeImpl notice = _getNotice(source); | 7113 notice.htmlUnit = task.resolvedUnit; |
| 7065 notice.htmlUnit = task.resolvedUnit; | 7114 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); |
| 7066 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); | |
| 7067 } | |
| 7068 } else { | 7115 } else { |
| 7069 htmlCopy.recordResolutionError(); | 7116 htmlCopy.recordResolutionError(); |
| 7070 } | 7117 } |
| 7071 htmlCopy.exception = thrownException; | 7118 htmlCopy.exception = thrownException; |
| 7072 _cache.put(source, htmlCopy); | 7119 _cache.put(source, htmlCopy); |
| 7073 htmlEntry = htmlCopy; | 7120 htmlEntry = htmlCopy; |
| 7074 } else { | 7121 } else { |
| 7075 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7122 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 7076 if (thrownException == null || resultTime >= 0) { | 7123 if (thrownException == null || resultTime >= 0) { |
| 7077 // | 7124 // |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7137 htmlEntry = _getReadableHtmlEntry(source); | 7184 htmlEntry = _getReadableHtmlEntry(source); |
| 7138 if (htmlEntry == null) { | 7185 if (htmlEntry == null) { |
| 7139 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 7186 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 7140 } | 7187 } |
| 7141 } | 7188 } |
| 7142 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7189 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 7143 if (thrownException == null) { | 7190 if (thrownException == null) { |
| 7144 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); | 7191 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); |
| 7145 _recordAngularEntryPoint(htmlCopy, task); | 7192 _recordAngularEntryPoint(htmlCopy, task); |
| 7146 _cache.storedAst(source); | 7193 _cache.storedAst(source); |
| 7147 if (_generateSdkErrors || !source.isInSystemLibrary) { | 7194 ChangeNoticeImpl notice = _getNotice(source); |
| 7148 ChangeNoticeImpl notice = _getNotice(source); | 7195 notice.htmlUnit = task.resolvedUnit; |
| 7149 notice.htmlUnit = task.resolvedUnit; | 7196 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); |
| 7150 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); | |
| 7151 } | |
| 7152 } else { | 7197 } else { |
| 7153 htmlCopy.recordResolutionError(); | 7198 htmlCopy.recordResolutionError(); |
| 7154 } | 7199 } |
| 7155 htmlCopy.exception = thrownException; | 7200 htmlCopy.exception = thrownException; |
| 7156 _cache.put(source, htmlCopy); | 7201 _cache.put(source, htmlCopy); |
| 7157 htmlEntry = htmlCopy; | 7202 htmlEntry = htmlCopy; |
| 7158 } else { | 7203 } else { |
| 7159 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7204 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 7160 if (thrownException == null || resultTime >= 0) { | 7205 if (thrownException == null || resultTime >= 0) { |
| 7161 // | 7206 // |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7302 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); | 7347 throw new AnalysisException.con1("An HTML file became a non-HTML file:
${source.fullName}"); |
| 7303 } | 7348 } |
| 7304 } | 7349 } |
| 7305 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7350 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 7306 if (thrownException == null) { | 7351 if (thrownException == null) { |
| 7307 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); | 7352 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 7308 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); | 7353 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); |
| 7309 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); | 7354 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); |
| 7310 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); | 7355 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); |
| 7311 _cache.storedAst(source); | 7356 _cache.storedAst(source); |
| 7312 if (_generateSdkErrors || !source.isInSystemLibrary) { | 7357 ChangeNoticeImpl notice = _getNotice(source); |
| 7313 ChangeNoticeImpl notice = _getNotice(source); | 7358 notice.htmlUnit = task.resolvedUnit; |
| 7314 notice.htmlUnit = task.resolvedUnit; | 7359 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LINE_
INFO)); |
| 7315 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); | |
| 7316 } | |
| 7317 } else { | 7360 } else { |
| 7318 htmlCopy.recordResolutionError(); | 7361 htmlCopy.recordResolutionError(); |
| 7319 _cache.removedAst(source); | 7362 _cache.removedAst(source); |
| 7320 } | 7363 } |
| 7321 htmlCopy.exception = thrownException; | 7364 htmlCopy.exception = thrownException; |
| 7322 _cache.put(source, htmlCopy); | 7365 _cache.put(source, htmlCopy); |
| 7323 htmlEntry = htmlCopy; | 7366 htmlEntry = htmlCopy; |
| 7324 } else { | 7367 } else { |
| 7325 _logInformation2("Resolution results discarded for ${_debuggingString(sour
ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html
Entry.modificationTime}", thrownException); | 7368 _logInformation2("Resolution results discarded for ${_debuggingString(sour
ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html
Entry.modificationTime}", thrownException); |
| 7326 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 7369 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7389 } | 7432 } |
| 7390 } | 7433 } |
| 7391 DartEntryImpl dartCopy = dartEntry.writableCopy; | 7434 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 7392 if (thrownException == null) { | 7435 if (thrownException == null) { |
| 7393 LineInfo lineInfo = task.lineInfo; | 7436 LineInfo lineInfo = task.lineInfo; |
| 7394 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 7437 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 7395 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); | 7438 dartCopy.setValue(DartEntry.TOKEN_STREAM, task.tokenStream); |
| 7396 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors); | 7439 dartCopy.setValue(DartEntry.SCAN_ERRORS, task.errors); |
| 7397 _cache.storedAst(source); | 7440 _cache.storedAst(source); |
| 7398 _workManager.add(source, SourcePriority.NORMAL_PART); | 7441 _workManager.add(source, SourcePriority.NORMAL_PART); |
| 7399 if (_generateSdkErrors || !source.isInSystemLibrary) { | 7442 ChangeNoticeImpl notice = _getNotice(source); |
| 7400 ChangeNoticeImpl notice = _getNotice(source); | 7443 notice.setErrors(dartEntry.allErrors, lineInfo); |
| 7401 notice.setErrors(dartEntry.allErrors, lineInfo); | |
| 7402 } | |
| 7403 } else { | 7444 } else { |
| 7404 _removeFromParts(source, dartEntry); | 7445 _removeFromParts(source, dartEntry); |
| 7405 dartCopy.recordScanError(); | 7446 dartCopy.recordScanError(); |
| 7406 _cache.removedAst(source); | 7447 _cache.removedAst(source); |
| 7407 } | 7448 } |
| 7408 dartCopy.exception = thrownException; | 7449 dartCopy.exception = thrownException; |
| 7409 _cache.put(source, dartCopy); | 7450 _cache.put(source, dartCopy); |
| 7410 dartEntry = dartCopy; | 7451 dartEntry = dartCopy; |
| 7411 } else { | 7452 } else { |
| 7412 _logInformation2("Scan results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.
modificationTime}", thrownException); | 7453 _logInformation2("Scan results discarded for ${_debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry.
modificationTime}", thrownException); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7447 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7488 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7448 * | 7489 * |
| 7449 * @param librarySource the library to be removed | 7490 * @param librarySource the library to be removed |
| 7450 * @param dartEntry the entry containing the list of included parts | 7491 * @param dartEntry the entry containing the list of included parts |
| 7451 */ | 7492 */ |
| 7452 void _removeFromParts(Source librarySource, DartEntry dartEntry) { | 7493 void _removeFromParts(Source librarySource, DartEntry dartEntry) { |
| 7453 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); | 7494 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); |
| 7454 for (int i = 0; i < oldParts.length; i++) { | 7495 for (int i = 0; i < oldParts.length; i++) { |
| 7455 Source partSource = oldParts[i]; | 7496 Source partSource = oldParts[i]; |
| 7456 DartEntry partEntry = _getReadableDartEntry(partSource); | 7497 DartEntry partEntry = _getReadableDartEntry(partSource); |
| 7457 if (partEntry != null && partEntry != dartEntry) { | 7498 if (partEntry != null && !identical(partEntry, dartEntry)) { |
| 7458 DartEntryImpl partCopy = partEntry.writableCopy; | 7499 DartEntryImpl partCopy = partEntry.writableCopy; |
| 7459 partCopy.removeContainingLibrary(librarySource); | 7500 partCopy.removeContainingLibrary(librarySource); |
| 7460 if (partCopy.librariesContaining.length == 0 && !exists(partSource)) { | 7501 if (partCopy.containingLibraries.length == 0 && !exists(partSource)) { |
| 7461 _cache.remove(partSource); | 7502 _cache.remove(partSource); |
| 7462 } else { | 7503 } else { |
| 7463 _cache.put(partSource, partCopy); | 7504 _cache.put(partSource, partCopy); |
| 7464 } | 7505 } |
| 7465 } | 7506 } |
| 7466 } | 7507 } |
| 7467 } | 7508 } |
| 7468 | 7509 |
| 7469 /** | 7510 /** |
| 7511 * Remove the given libraries that are keys in the given map from the list of
containing libraries |
| 7512 * for each of the parts in the corresponding value. |
| 7513 * |
| 7514 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7515 * |
| 7516 * @param oldPartMap the table containing the parts associated with each libra
ry |
| 7517 */ |
| 7518 void _removeFromPartsUsingMap(Map<Source, List<Source>> oldPartMap) { |
| 7519 for (MapEntry<Source, List<Source>> entry in getMapEntrySet(oldPartMap)) { |
| 7520 Source librarySource = entry.getKey(); |
| 7521 List<Source> oldParts = entry.getValue(); |
| 7522 for (int i = 0; i < oldParts.length; i++) { |
| 7523 Source partSource = oldParts[i]; |
| 7524 if (partSource != librarySource) { |
| 7525 DartEntry partEntry = _getReadableDartEntry(partSource); |
| 7526 if (partEntry != null) { |
| 7527 DartEntryImpl partCopy = partEntry.writableCopy; |
| 7528 partCopy.removeContainingLibrary(librarySource); |
| 7529 if (partCopy.containingLibraries.length == 0 && !exists(partSource))
{ |
| 7530 _cache.remove(partSource); |
| 7531 } else { |
| 7532 _cache.put(partSource, partCopy); |
| 7533 } |
| 7534 } |
| 7535 } |
| 7536 } |
| 7537 } |
| 7538 } |
| 7539 |
| 7540 /** |
| 7470 * Remove the given source from the priority order if it is in the list. | 7541 * Remove the given source from the priority order if it is in the list. |
| 7471 * | 7542 * |
| 7472 * @param source the source to be removed | 7543 * @param source the source to be removed |
| 7473 */ | 7544 */ |
| 7474 void _removeFromPriorityOrder(Source source) { | 7545 void _removeFromPriorityOrder(Source source) { |
| 7475 int count = _priorityOrder.length; | 7546 int count = _priorityOrder.length; |
| 7476 List<Source> newOrder = new List<Source>(); | 7547 List<Source> newOrder = new List<Source>(); |
| 7477 for (int i = 0; i < count; i++) { | 7548 for (int i = 0; i < count; i++) { |
| 7478 if (_priorityOrder[i] != source) { | 7549 if (_priorityOrder[i] != source) { |
| 7479 newOrder.add(_priorityOrder[i]); | 7550 newOrder.add(_priorityOrder[i]); |
| 7480 } | 7551 } |
| 7481 } | 7552 } |
| 7482 if (newOrder.length < count) { | 7553 if (newOrder.length < count) { |
| 7483 analysisPriorityOrder = newOrder; | 7554 analysisPriorityOrder = newOrder; |
| 7484 } | 7555 } |
| 7485 } | 7556 } |
| 7486 | 7557 |
| 7487 /** | 7558 /** |
| 7488 * Create an entry for the newly added source. Return `true` if the new source
is a Dart | 7559 * Create an entry for the newly added source. Return `true` if the new source
is a Dart |
| 7489 * file. | 7560 * file. |
| 7490 * | 7561 * |
| 7491 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7562 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7492 * | 7563 * |
| 7493 * @param source the source that has been added | 7564 * @param source the source that has been added |
| 7494 * @return `true` if the new source is a Dart file | 7565 * @return `true` if the new source is a Dart file |
| 7495 */ | 7566 */ |
| 7496 bool _sourceAvailable(Source source) { | 7567 bool _sourceAvailable(Source source) { |
| 7497 SourceEntry sourceEntry = _cache.get(source); | 7568 SourceEntry sourceEntry = _cache.get(source); |
| 7498 if (sourceEntry == null) { | 7569 if (sourceEntry == null) { |
| 7499 sourceEntry = _createSourceEntry(source); | 7570 sourceEntry = _createSourceEntry(source, true); |
| 7500 } else { | 7571 } else { |
| 7501 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | 7572 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 7502 // long oldTime = sourceCopy.getModificationTime(); | 7573 int newTime = getModificationStamp(source); |
| 7503 sourceCopy.modificationTime = getModificationStamp(source); | 7574 sourceCopy.modificationTime = newTime; |
| 7504 // TODO(brianwilkerson) Understand why we're not invalidating the cache. | 7575 sourceCopy.explicitlyAdded = true; |
| 7576 // TODO(brianwilkerson) Understand why we're not invalidating the cached d
ata. |
| 7505 _cache.put(source, sourceCopy); | 7577 _cache.put(source, sourceCopy); |
| 7506 } | 7578 } |
| 7507 if (sourceEntry is HtmlEntry) { | 7579 if (sourceEntry is HtmlEntry) { |
| 7508 _workManager.add(source, SourcePriority.HTML); | 7580 _workManager.add(source, SourcePriority.HTML); |
| 7509 } else { | 7581 } else { |
| 7510 _workManager.add(source, SourcePriority.UNKNOWN); | 7582 _workManager.add(source, SourcePriority.UNKNOWN); |
| 7511 } | 7583 } |
| 7512 return sourceEntry is DartEntry; | 7584 return sourceEntry is DartEntry; |
| 7513 } | 7585 } |
| 7514 | 7586 |
| 7515 /** | 7587 /** |
| 7516 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7588 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7517 * | 7589 * |
| 7518 * @param source the source that has been changed | 7590 * @param source the source that has been changed |
| 7519 */ | 7591 */ |
| 7520 void _sourceChanged(Source source) { | 7592 void _sourceChanged(Source source) { |
| 7521 SourceEntry sourceEntry = _cache.get(source); | 7593 SourceEntry sourceEntry = _cache.get(source); |
| 7522 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt
amp(source)) { | 7594 if (sourceEntry == null || sourceEntry.modificationTime == getModificationSt
amp(source)) { |
| 7523 // Either we have removed this source, in which case we don't care that it
is changed, or we | 7595 // Either we have removed this source, in which case we don't care that it
is changed, or we |
| 7524 // have already invalidated the cache and don't need to invalidate it agai
n. | 7596 // have already invalidated the cache and don't need to invalidate it agai
n. |
| 7525 // if (sourceEntry == null) { | |
| 7526 // logInformation("Modified source, but there is no entry: " + debu
ggingString(source)); | |
| 7527 // } else { | |
| 7528 // logInformation("Modified source, but modification time matches:
" + debuggingString(source)); | |
| 7529 // } | |
| 7530 return; | 7597 return; |
| 7531 } | 7598 } |
| 7532 if (sourceEntry is HtmlEntry) { | 7599 if (sourceEntry is HtmlEntry) { |
| 7533 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 7600 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 7534 // long oldTime = htmlCopy.getModificationTime(); | |
| 7535 htmlCopy.modificationTime = getModificationStamp(source); | 7601 htmlCopy.modificationTime = getModificationStamp(source); |
| 7536 _invalidateAngularResolution(htmlCopy); | 7602 _invalidateAngularResolution(htmlCopy); |
| 7537 htmlCopy.invalidateAllInformation(); | 7603 htmlCopy.invalidateAllInformation(); |
| 7538 _cache.put(source, htmlCopy); | 7604 _cache.put(source, htmlCopy); |
| 7539 _cache.removedAst(source); | 7605 _cache.removedAst(source); |
| 7540 _workManager.add(source, SourcePriority.HTML); | 7606 _workManager.add(source, SourcePriority.HTML); |
| 7541 } else if (sourceEntry is DartEntry) { | 7607 } else if (sourceEntry is DartEntry) { |
| 7542 List<Source> containingLibraries = getLibrariesContaining(source); | 7608 List<Source> containingLibraries = getLibrariesContaining(source); |
| 7543 Set<Source> librariesToInvalidate = new Set<Source>(); | 7609 Set<Source> librariesToInvalidate = new Set<Source>(); |
| 7544 for (Source containingLibrary in containingLibraries) { | 7610 for (Source containingLibrary in containingLibraries) { |
| 7545 librariesToInvalidate.add(containingLibrary); | 7611 librariesToInvalidate.add(containingLibrary); |
| 7546 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar
y)) { | 7612 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar
y)) { |
| 7547 librariesToInvalidate.add(dependentLibrary); | 7613 librariesToInvalidate.add(dependentLibrary); |
| 7548 } | 7614 } |
| 7549 } | 7615 } |
| 7550 PrintStringWriter writer = new PrintStringWriter(); | |
| 7551 for (Source library in librariesToInvalidate) { | 7616 for (Source library in librariesToInvalidate) { |
| 7552 // for (Source library : containingLibraries) { | 7617 // for (Source library : containingLibraries) { |
| 7553 _invalidateLibraryResolution(library, writer); | 7618 _invalidateLibraryResolution(library); |
| 7554 } | 7619 } |
| 7555 _removeFromParts(source, _cache.get(source) as DartEntry); | 7620 _removeFromParts(source, _cache.get(source) as DartEntry); |
| 7556 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy; | 7621 DartEntryImpl dartCopy = (_cache.get(source) as DartEntry).writableCopy; |
| 7557 dartCopy.modificationTime = getModificationStamp(source); | 7622 dartCopy.modificationTime = getModificationStamp(source); |
| 7558 dartCopy.invalidateAllInformation(); | 7623 dartCopy.invalidateAllInformation(); |
| 7559 _cache.put(source, dartCopy); | 7624 _cache.put(source, dartCopy); |
| 7560 _cache.removedAst(source); | 7625 _cache.removedAst(source); |
| 7561 _workManager.add(source, SourcePriority.UNKNOWN); | 7626 _workManager.add(source, SourcePriority.UNKNOWN); |
| 7562 } | 7627 } |
| 7563 } | 7628 } |
| 7564 | 7629 |
| 7565 /** | 7630 /** |
| 7566 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 7631 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 7567 * | 7632 * |
| 7568 * @param source the source that has been deleted | 7633 * @param source the source that has been deleted |
| 7569 */ | 7634 */ |
| 7570 void _sourceRemoved(Source source) { | 7635 void _sourceRemoved(Source source) { |
| 7571 PrintStringWriter writer = new PrintStringWriter(); | |
| 7572 SourceEntry sourceEntry = _cache.get(source); | 7636 SourceEntry sourceEntry = _cache.get(source); |
| 7573 if (sourceEntry is HtmlEntry) { | 7637 if (sourceEntry is HtmlEntry) { |
| 7574 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 7638 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 7575 _invalidateAngularResolution(htmlCopy); | 7639 _invalidateAngularResolution(htmlCopy); |
| 7576 } else if (sourceEntry is DartEntry) { | 7640 } else if (sourceEntry is DartEntry) { |
| 7577 Set<Source> libraries = new Set<Source>(); | 7641 Set<Source> libraries = new Set<Source>(); |
| 7578 for (Source librarySource in getLibrariesContaining(source)) { | 7642 for (Source librarySource in getLibrariesContaining(source)) { |
| 7579 libraries.add(librarySource); | 7643 libraries.add(librarySource); |
| 7580 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ | 7644 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ |
| 7581 libraries.add(dependentLibrary); | 7645 libraries.add(dependentLibrary); |
| 7582 } | 7646 } |
| 7583 } | 7647 } |
| 7584 for (Source librarySource in libraries) { | 7648 for (Source librarySource in libraries) { |
| 7585 _invalidateLibraryResolution(librarySource, writer); | 7649 _invalidateLibraryResolution(librarySource); |
| 7586 } | 7650 } |
| 7587 } | 7651 } |
| 7588 _cache.remove(source); | 7652 _cache.remove(source); |
| 7589 _workManager.remove(source); | 7653 _workManager.remove(source); |
| 7590 _removeFromPriorityOrder(source); | 7654 _removeFromPriorityOrder(source); |
| 7591 } | 7655 } |
| 7592 | 7656 |
| 7593 /** | 7657 /** |
| 7594 * Check the cache for any invalid entries (entries whose modification time do
es not match the | 7658 * Check the cache for any invalid entries (entries whose modification time do
es not match the |
| 7595 * modification time of the source associated with the entry). Invalid entries
will be marked as | 7659 * modification time of the source associated with the entry). Invalid entries
will be marked as |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8209 * @param source the source with which the sources are associated | 8273 * @param source the source with which the sources are associated |
| 8210 * @param dartEntry the entry corresponding to the source | 8274 * @param dartEntry the entry corresponding to the source |
| 8211 * @param descriptor the descriptor indicating which sources are to be returne
d | 8275 * @param descriptor the descriptor indicating which sources are to be returne
d |
| 8212 * @return the sources described by the given descriptor | 8276 * @return the sources described by the given descriptor |
| 8213 */ | 8277 */ |
| 8214 List<Source> _getSources(Source source, DartEntry dartEntry, DataDescriptor<Li
st<Source>> descriptor) { | 8278 List<Source> _getSources(Source source, DartEntry dartEntry, DataDescriptor<Li
st<Source>> descriptor) { |
| 8215 if (dartEntry == null) { | 8279 if (dartEntry == null) { |
| 8216 return Source.EMPTY_ARRAY; | 8280 return Source.EMPTY_ARRAY; |
| 8217 } | 8281 } |
| 8218 CacheState exportState = dartEntry.getState(descriptor); | 8282 CacheState exportState = dartEntry.getState(descriptor); |
| 8219 if (identical(exportState, CacheState.ERROR)) { | 8283 if (exportState == CacheState.ERROR) { |
| 8220 return Source.EMPTY_ARRAY; | 8284 return Source.EMPTY_ARRAY; |
| 8221 } else if (exportState != CacheState.VALID) { | 8285 } else if (exportState != CacheState.VALID) { |
| 8222 if (_taskData == null) { | 8286 if (_taskData == null) { |
| 8223 _taskData = AnalysisContextImpl_this._createParseDartTask(source, dartEn
try); | 8287 _taskData = AnalysisContextImpl_this._createParseDartTask(source, dartEn
try); |
| 8224 } | 8288 } |
| 8225 return Source.EMPTY_ARRAY; | 8289 return Source.EMPTY_ARRAY; |
| 8226 } | 8290 } |
| 8227 return dartEntry.getValue(descriptor); | 8291 return dartEntry.getValue(descriptor); |
| 8228 } | 8292 } |
| 8229 } | 8293 } |
| 8230 | 8294 |
| 8231 /** | 8295 /** |
| 8232 * Instances of the class `TaskData` represent information about the next task t
o be | 8296 * Instances of the class `TaskData` represent information about the next task t
o be |
| 8233 * performed. Each data has an implicit associated source: the source that might
need to be | 8297 * performed. Each data has an implicit associated source: the source that might
need to be |
| 8234 * analyzed. There are essentially three states that can be represented: | 8298 * analyzed. There are essentially three states that can be represented: |
| 8235 * * If [getTask] returns a non-`null` value, then that is the task that should | 8299 * * If [getTask] returns a non-`null` value, then that is the task that should |
| 8236 * be executed to further analyze the associated source. | 8300 * be executed to further analyze the associated source. |
| 8237 * * Otherwise, if [isBlocked] returns `true`, then there is no work that can be | 8301 * * Otherwise, if [isBlocked] returns `true`, then there is no work that can be |
| 8238 * done, but analysis for the associated source is not complete. | 8302 * done, but analysis for the associated source is not complete. |
| 8239 * * Otherwise, [getDependentSource] should return a source that needs to be ana
lyzed | 8303 * * Otherwise, [getDependentSource] should return a source that needs to be ana
lyzed |
| 8240 * before the analysis of the associated source can be completed. | 8304 * before the analysis of the associated source can be completed. |
| 8241 */ | 8305 */ |
| 8242 class AnalysisContextImpl_TaskData { | 8306 class AnalysisContextImpl_TaskData { |
| 8243 /** | 8307 /** |
| 8244 * The task that is to be performed. | 8308 * The task that is to be performed. |
| 8245 */ | 8309 */ |
| 8246 AnalysisTask task; | 8310 final AnalysisTask task; |
| 8247 | 8311 |
| 8248 /** | 8312 /** |
| 8249 * A flag indicating whether the associated source is blocked waiting for its
contents to be | 8313 * A flag indicating whether the associated source is blocked waiting for its
contents to be |
| 8250 * loaded. | 8314 * loaded. |
| 8251 */ | 8315 */ |
| 8252 bool _blocked = false; | 8316 final bool _blocked; |
| 8253 | 8317 |
| 8254 /** | 8318 /** |
| 8255 * Initialize a newly created data holder. | 8319 * Initialize a newly created data holder. |
| 8256 * | 8320 * |
| 8257 * @param task the task that is to be performed | 8321 * @param task the task that is to be performed |
| 8258 * @param blocked `true` if the associated source is blocked waiting for its c
ontents to | 8322 * @param blocked `true` if the associated source is blocked waiting for its c
ontents to |
| 8259 * be loaded | 8323 * be loaded |
| 8260 */ | 8324 */ |
| 8261 AnalysisContextImpl_TaskData(AnalysisTask task, bool blocked) { | 8325 AnalysisContextImpl_TaskData(this.task, this._blocked); |
| 8262 this.task = task; | |
| 8263 this._blocked = blocked; | |
| 8264 } | |
| 8265 | 8326 |
| 8266 /** | 8327 /** |
| 8267 * Return `true` if the associated source is blocked waiting for its contents
to be | 8328 * Return `true` if the associated source is blocked waiting for its contents
to be |
| 8268 * loaded. | 8329 * loaded. |
| 8269 * | 8330 * |
| 8270 * @return `true` if the associated source is blocked waiting for its contents
to be | 8331 * @return `true` if the associated source is blocked waiting for its contents
to be |
| 8271 * loaded | 8332 * loaded |
| 8272 */ | 8333 */ |
| 8273 bool get isBlocked => _blocked; | 8334 bool get isBlocked => _blocked; |
| 8274 | 8335 |
| 8275 @override | 8336 @override |
| 8276 String toString() { | 8337 String toString() { |
| 8277 if (task == null) { | 8338 if (task == null) { |
| 8278 return "blocked: ${_blocked}"; | 8339 return "blocked: ${_blocked}"; |
| 8279 } | 8340 } |
| 8280 return task.toString(); | 8341 return task.toString(); |
| 8281 } | 8342 } |
| 8282 } | 8343 } |
| 8283 | 8344 |
| 8284 /** | 8345 /** |
| 8285 * Instances of the class `AnalysisErrorInfoImpl` represent the analysis errors
and line info | 8346 * Instances of the class `AnalysisErrorInfoImpl` represent the analysis errors
and line info |
| 8286 * associated with a source. | 8347 * associated with a source. |
| 8287 */ | 8348 */ |
| 8288 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { | 8349 class AnalysisErrorInfoImpl implements AnalysisErrorInfo { |
| 8289 /** | 8350 /** |
| 8290 * The analysis errors associated with a source, or `null` if there are no err
ors. | 8351 * The analysis errors associated with a source, or `null` if there are no err
ors. |
| 8291 */ | 8352 */ |
| 8292 List<AnalysisError> errors; | 8353 final List<AnalysisError> errors; |
| 8293 | 8354 |
| 8294 /** | 8355 /** |
| 8295 * The line information associated with the errors, or `null` if there are no
errors. | 8356 * The line information associated with the errors, or `null` if there are no
errors. |
| 8296 */ | 8357 */ |
| 8297 LineInfo lineInfo; | 8358 final LineInfo lineInfo; |
| 8298 | 8359 |
| 8299 /** | 8360 /** |
| 8300 * Initialize an newly created error info with the errors and line information | 8361 * Initialize an newly created error info with the errors and line information |
| 8301 * | 8362 * |
| 8302 * @param errors the errors as a result of analysis | 8363 * @param errors the errors as a result of analysis |
| 8303 * @param lineinfo the line info for the errors | 8364 * @param lineinfo the line info for the errors |
| 8304 */ | 8365 */ |
| 8305 AnalysisErrorInfoImpl(List<AnalysisError> errors, LineInfo lineInfo) { | 8366 AnalysisErrorInfoImpl(this.errors, this.lineInfo); |
| 8306 this.errors = errors; | |
| 8307 this.lineInfo = lineInfo; | |
| 8308 } | |
| 8309 } | 8367 } |
| 8310 | 8368 |
| 8311 /** | 8369 /** |
| 8312 * Instances of the class `AnalysisOptions` represent a set of analysis options
used to | 8370 * Instances of the class `AnalysisOptions` represent a set of analysis options
used to |
| 8313 * control the behavior of an analysis context. | 8371 * control the behavior of an analysis context. |
| 8314 */ | 8372 */ |
| 8315 class AnalysisOptionsImpl implements AnalysisOptions { | 8373 class AnalysisOptionsImpl implements AnalysisOptions { |
| 8316 /** | 8374 /** |
| 8317 * The maximum number of sources for which data should be kept in the cache. | 8375 * The maximum number of sources for which data should be kept in the cache. |
| 8318 */ | 8376 */ |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8394 } | 8452 } |
| 8395 | 8453 |
| 8396 /** | 8454 /** |
| 8397 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis
results | 8455 * Instances of the class `ChangeNoticeImpl` represent a change to the analysis
results |
| 8398 * associated with a given source. | 8456 * associated with a given source. |
| 8399 */ | 8457 */ |
| 8400 class ChangeNoticeImpl implements ChangeNotice { | 8458 class ChangeNoticeImpl implements ChangeNotice { |
| 8401 /** | 8459 /** |
| 8402 * The source for which the result is being reported. | 8460 * The source for which the result is being reported. |
| 8403 */ | 8461 */ |
| 8404 Source source; | 8462 final Source source; |
| 8405 | 8463 |
| 8406 /** | 8464 /** |
| 8407 * The fully resolved AST that changed as a result of the analysis, or `null`
if the AST was | 8465 * The fully resolved AST that changed as a result of the analysis, or `null`
if the AST was |
| 8408 * not changed. | 8466 * not changed. |
| 8409 */ | 8467 */ |
| 8410 CompilationUnit compilationUnit; | 8468 CompilationUnit compilationUnit; |
| 8411 | 8469 |
| 8412 /** | 8470 /** |
| 8413 * The fully resolved HTML that changed as a result of the analysis, or `null`
if the HTML | 8471 * The fully resolved HTML that changed as a result of the analysis, or `null`
if the HTML |
| 8414 * was not changed. | 8472 * was not changed. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 8429 /** | 8487 /** |
| 8430 * An empty array of change notices. | 8488 * An empty array of change notices. |
| 8431 */ | 8489 */ |
| 8432 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); | 8490 static List<ChangeNoticeImpl> EMPTY_ARRAY = new List<ChangeNoticeImpl>(0); |
| 8433 | 8491 |
| 8434 /** | 8492 /** |
| 8435 * Initialize a newly created notice associated with the given source. | 8493 * Initialize a newly created notice associated with the given source. |
| 8436 * | 8494 * |
| 8437 * @param source the source for which the change is being reported | 8495 * @param source the source for which the change is being reported |
| 8438 */ | 8496 */ |
| 8439 ChangeNoticeImpl(Source source) { | 8497 ChangeNoticeImpl(this.source); |
| 8440 this.source = source; | |
| 8441 } | |
| 8442 | 8498 |
| 8443 @override | 8499 @override |
| 8444 List<AnalysisError> get errors => _errors; | 8500 List<AnalysisError> get errors => _errors; |
| 8445 | 8501 |
| 8446 @override | 8502 @override |
| 8447 LineInfo get lineInfo => _lineInfo; | 8503 LineInfo get lineInfo => _lineInfo; |
| 8448 | 8504 |
| 8449 /** | 8505 /** |
| 8450 * Set the errors that changed as a result of the analysis to the given errors
and set the line | 8506 * Set the errors that changed as a result of the analysis to the given errors
and set the line |
| 8451 * information to the given line information. | 8507 * information to the given line information. |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8884 */ | 8940 */ |
| 8885 static IncrementalAnalysisCache verifyStructure(IncrementalAnalysisCache cache
, Source source, CompilationUnit unit) { | 8941 static IncrementalAnalysisCache verifyStructure(IncrementalAnalysisCache cache
, Source source, CompilationUnit unit) { |
| 8886 if (cache != null && unit != null && cache.source == source) { | 8942 if (cache != null && unit != null && cache.source == source) { |
| 8887 if (!AstComparator.equalUnits(cache.resolvedUnit, unit)) { | 8943 if (!AstComparator.equalUnits(cache.resolvedUnit, unit)) { |
| 8888 return null; | 8944 return null; |
| 8889 } | 8945 } |
| 8890 } | 8946 } |
| 8891 return cache; | 8947 return cache; |
| 8892 } | 8948 } |
| 8893 | 8949 |
| 8894 Source librarySource; | 8950 final Source librarySource; |
| 8895 | 8951 |
| 8896 Source source; | 8952 final Source source; |
| 8897 | 8953 |
| 8898 String oldContents; | 8954 final String oldContents; |
| 8899 | 8955 |
| 8900 CompilationUnit resolvedUnit; | 8956 final CompilationUnit resolvedUnit; |
| 8901 | 8957 |
| 8902 String _newContents; | 8958 String _newContents; |
| 8903 | 8959 |
| 8904 int _offset = 0; | 8960 int _offset = 0; |
| 8905 | 8961 |
| 8906 int _oldLength = 0; | 8962 int _oldLength = 0; |
| 8907 | 8963 |
| 8908 int _newLength = 0; | 8964 int _newLength = 0; |
| 8909 | 8965 |
| 8910 IncrementalAnalysisCache(Source librarySource, Source source, CompilationUnit
resolvedUnit, String oldContents, String newContents, int offset, int oldLength,
int newLength) { | 8966 IncrementalAnalysisCache(this.librarySource, this.source, this.resolvedUnit, t
his.oldContents, String newContents, int offset, int oldLength, int newLength) { |
| 8911 this.librarySource = librarySource; | |
| 8912 this.source = source; | |
| 8913 this.resolvedUnit = resolvedUnit; | |
| 8914 this.oldContents = oldContents; | |
| 8915 this._newContents = newContents; | 8967 this._newContents = newContents; |
| 8916 this._offset = offset; | 8968 this._offset = offset; |
| 8917 this._oldLength = oldLength; | 8969 this._oldLength = oldLength; |
| 8918 this._newLength = newLength; | 8970 this._newLength = newLength; |
| 8919 } | 8971 } |
| 8920 | 8972 |
| 8921 /** | 8973 /** |
| 8922 * Return the current contents for the receiver's source. | 8974 * Return the current contents for the receiver's source. |
| 8923 * | 8975 * |
| 8924 * @return the contents (not `null`) | 8976 * @return the contents (not `null`) |
| (...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9999 | 10051 |
| 10000 /** | 10052 /** |
| 10001 * Instances of the class `ResolvableCompilationUnit` represent a compilation un
it that is not | 10053 * Instances of the class `ResolvableCompilationUnit` represent a compilation un
it that is not |
| 10002 * referenced by any other objects and for which we have modification stamp info
rmation. It is used | 10054 * referenced by any other objects and for which we have modification stamp info
rmation. It is used |
| 10003 * by the [LibraryResolver] to resolve a library. | 10055 * by the [LibraryResolver] to resolve a library. |
| 10004 */ | 10056 */ |
| 10005 class ResolvableCompilationUnit extends TimestampedData<CompilationUnit> { | 10057 class ResolvableCompilationUnit extends TimestampedData<CompilationUnit> { |
| 10006 /** | 10058 /** |
| 10007 * The source of the compilation unit. | 10059 * The source of the compilation unit. |
| 10008 */ | 10060 */ |
| 10009 Source _source; | 10061 final Source source; |
| 10010 | 10062 |
| 10011 /** | 10063 /** |
| 10012 * Initialize a newly created holder to hold the given values. | 10064 * Initialize a newly created holder to hold the given values. |
| 10013 * | 10065 * |
| 10014 * @param modificationTime the modification time of the source from which the
AST was created | 10066 * @param modificationTime the modification time of the source from which the
AST was created |
| 10015 * @param unit the AST that was created from the source | 10067 * @param unit the AST that was created from the source |
| 10016 */ | 10068 */ |
| 10017 ResolvableCompilationUnit.con1(int modificationTime, CompilationUnit unit) : s
uper(modificationTime, unit); | 10069 ResolvableCompilationUnit.con1(int modificationTime, CompilationUnit unit) : t
his.con2(modificationTime, unit, null); |
| 10018 | 10070 |
| 10019 /** | 10071 /** |
| 10020 * Initialize a newly created holder to hold the given values. | 10072 * Initialize a newly created holder to hold the given values. |
| 10021 * | 10073 * |
| 10022 * @param modificationTime the modification time of the source from which the
AST was created | 10074 * @param modificationTime the modification time of the source from which the
AST was created |
| 10023 * @param unit the AST that was created from the source | 10075 * @param unit the AST that was created from the source |
| 10024 * @param source the source of the compilation unit | 10076 * @param source the source of the compilation unit |
| 10025 */ | 10077 */ |
| 10026 ResolvableCompilationUnit.con2(int modificationTime, CompilationUnit unit, Sou
rce source) : super(modificationTime, unit) { | 10078 ResolvableCompilationUnit.con2(int modificationTime, CompilationUnit unit, thi
s.source) : super(modificationTime, unit); |
| 10027 this._source = source; | |
| 10028 } | |
| 10029 | 10079 |
| 10030 /** | 10080 /** |
| 10031 * Return the AST that was created from the source. | 10081 * Return the AST that was created from the source. |
| 10032 * | 10082 * |
| 10033 * @return the AST that was created from the source | 10083 * @return the AST that was created from the source |
| 10034 */ | 10084 */ |
| 10035 CompilationUnit get compilationUnit => data; | 10085 CompilationUnit get compilationUnit => data; |
| 10036 | |
| 10037 /** | |
| 10038 * Return the source of the compilation unit. | |
| 10039 * | |
| 10040 * @return the source of the compilation unit | |
| 10041 */ | |
| 10042 Source get source => _source; | |
| 10043 } | 10086 } |
| 10044 | 10087 |
| 10045 /** | 10088 /** |
| 10046 * Instances of the class `ResolvableHtmlUnit` represent an HTML unit that is no
t referenced | 10089 * Instances of the class `ResolvableHtmlUnit` represent an HTML unit that is no
t referenced |
| 10047 * by any other objects and for which we have modification stamp information. It
is used by the | 10090 * by any other objects and for which we have modification stamp information. It
is used by the |
| 10048 * [ResolveHtmlTask] to resolve an HTML source. | 10091 * [ResolveHtmlTask] to resolve an HTML source. |
| 10049 */ | 10092 */ |
| 10050 class ResolvableHtmlUnit extends TimestampedData<ht.HtmlUnit> { | 10093 class ResolvableHtmlUnit extends TimestampedData<ht.HtmlUnit> { |
| 10051 /** | 10094 /** |
| 10052 * Initialize a newly created holder to hold the given values. | 10095 * Initialize a newly created holder to hold the given values. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 10067 /** | 10110 /** |
| 10068 * The enumerated type `Priority` defines the priority levels used to return sou
rces in an | 10111 * The enumerated type `Priority` defines the priority levels used to return sou
rces in an |
| 10069 * optimal order. A smaller ordinal value equates to a higher priority. | 10112 * optimal order. A smaller ordinal value equates to a higher priority. |
| 10070 */ | 10113 */ |
| 10071 class SourcePriority extends Enum<SourcePriority> { | 10114 class SourcePriority extends Enum<SourcePriority> { |
| 10072 /** | 10115 /** |
| 10073 * Used for a Dart source that is known to be a part contained in a library th
at was recently | 10116 * Used for a Dart source that is known to be a part contained in a library th
at was recently |
| 10074 * resolved. These parts are given a higher priority because there is a high p
robability that | 10117 * resolved. These parts are given a higher priority because there is a high p
robability that |
| 10075 * their AST structure is still in the cache and therefore would not need to b
e re-created. | 10118 * their AST structure is still in the cache and therefore would not need to b
e re-created. |
| 10076 */ | 10119 */ |
| 10077 static final SourcePriority PRIORITY_PART = new SourcePriority('PRIORITY_PART'
, 0); | 10120 static const SourcePriority PRIORITY_PART = const SourcePriority('PRIORITY_PAR
T', 0); |
| 10078 | 10121 |
| 10079 /** | 10122 /** |
| 10080 * Used for a Dart source that is known to be a library. | 10123 * Used for a Dart source that is known to be a library. |
| 10081 */ | 10124 */ |
| 10082 static final SourcePriority LIBRARY = new SourcePriority('LIBRARY', 1); | 10125 static const SourcePriority LIBRARY = const SourcePriority('LIBRARY', 1); |
| 10083 | 10126 |
| 10084 /** | 10127 /** |
| 10085 * Used for a Dart source whose kind is unknown. | 10128 * Used for a Dart source whose kind is unknown. |
| 10086 */ | 10129 */ |
| 10087 static final SourcePriority UNKNOWN = new SourcePriority('UNKNOWN', 2); | 10130 static const SourcePriority UNKNOWN = const SourcePriority('UNKNOWN', 2); |
| 10088 | 10131 |
| 10089 /** | 10132 /** |
| 10090 * Used for a Dart source that is known to be a part but whose library has not
yet been resolved. | 10133 * Used for a Dart source that is known to be a part but whose library has not
yet been resolved. |
| 10091 */ | 10134 */ |
| 10092 static final SourcePriority NORMAL_PART = new SourcePriority('NORMAL_PART', 3)
; | 10135 static const SourcePriority NORMAL_PART = const SourcePriority('NORMAL_PART',
3); |
| 10093 | 10136 |
| 10094 /** | 10137 /** |
| 10095 * Used for an HTML source. | 10138 * Used for an HTML source. |
| 10096 */ | 10139 */ |
| 10097 static final SourcePriority HTML = new SourcePriority('HTML', 4); | 10140 static const SourcePriority HTML = const SourcePriority('HTML', 4); |
| 10098 | 10141 |
| 10099 static final List<SourcePriority> values = [PRIORITY_PART, LIBRARY, UNKNOWN, N
ORMAL_PART, HTML]; | 10142 static const List<SourcePriority> values = const [PRIORITY_PART, LIBRARY, UNKN
OWN, NORMAL_PART, HTML]; |
| 10100 | 10143 |
| 10101 SourcePriority(String name, int ordinal) : super(name, ordinal); | 10144 const SourcePriority(String name, int ordinal) : super(name, ordinal); |
| 10102 } | 10145 } |
| 10103 | 10146 |
| 10104 /** | 10147 /** |
| 10105 * Instances of the class `TimestampedData` represent analysis data for which we
have a | 10148 * Instances of the class `TimestampedData` represent analysis data for which we
have a |
| 10106 * modification time. | 10149 * modification time. |
| 10107 */ | 10150 */ |
| 10108 class TimestampedData<E> { | 10151 class TimestampedData<E> { |
| 10109 /** | 10152 /** |
| 10110 * The modification time of the source from which the data was created. | 10153 * The modification time of the source from which the data was created. |
| 10111 */ | 10154 */ |
| 10112 int modificationTime = 0; | 10155 final int modificationTime; |
| 10113 | 10156 |
| 10114 /** | 10157 /** |
| 10115 * The data that was created from the source. | 10158 * The data that was created from the source. |
| 10116 */ | 10159 */ |
| 10117 E data; | 10160 final E data; |
| 10118 | 10161 |
| 10119 /** | 10162 /** |
| 10120 * Initialize a newly created holder to hold the given values. | 10163 * Initialize a newly created holder to hold the given values. |
| 10121 * | 10164 * |
| 10122 * @param modificationTime the modification time of the source from which the
data was created | 10165 * @param modificationTime the modification time of the source from which the
data was created |
| 10123 * @param unit the data that was created from the source | 10166 * @param unit the data that was created from the source |
| 10124 */ | 10167 */ |
| 10125 TimestampedData(int modificationTime, E data) { | 10168 TimestampedData(this.modificationTime, this.data); |
| 10126 this.modificationTime = modificationTime; | |
| 10127 this.data = data; | |
| 10128 } | |
| 10129 } | 10169 } |
| 10130 | 10170 |
| 10131 /** | 10171 /** |
| 10132 * Instances of the class `WorkManager` manage a list of sources that need to ha
ve analysis | 10172 * Instances of the class `WorkManager` manage a list of sources that need to ha
ve analysis |
| 10133 * work performed on them. | 10173 * work performed on them. |
| 10134 */ | 10174 */ |
| 10135 class WorkManager { | 10175 class WorkManager { |
| 10136 /** | 10176 /** |
| 10137 * An array containing the various queues is priority order. | 10177 * An array containing the various queues is priority order. |
| 10138 */ | 10178 */ |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10311 } | 10351 } |
| 10312 } | 10352 } |
| 10313 | 10353 |
| 10314 /** | 10354 /** |
| 10315 * An [Expression] with optional [AngularFilterNode]s. | 10355 * An [Expression] with optional [AngularFilterNode]s. |
| 10316 */ | 10356 */ |
| 10317 class AngularExpression { | 10357 class AngularExpression { |
| 10318 /** | 10358 /** |
| 10319 * The [Expression] to apply filters to. | 10359 * The [Expression] to apply filters to. |
| 10320 */ | 10360 */ |
| 10321 Expression expression; | 10361 final Expression expression; |
| 10322 | 10362 |
| 10323 /** | 10363 /** |
| 10324 * The filters to apply. | 10364 * The filters to apply. |
| 10325 */ | 10365 */ |
| 10326 List<AngularFilterNode> filters; | 10366 final List<AngularFilterNode> filters; |
| 10327 | 10367 |
| 10328 AngularExpression(Expression expression, List<AngularFilterNode> filters) { | 10368 AngularExpression(this.expression, this.filters); |
| 10329 this.expression = expression; | |
| 10330 this.filters = filters; | |
| 10331 } | |
| 10332 | 10369 |
| 10333 /** | 10370 /** |
| 10334 * Return the offset of the character immediately following the last character
of this node's | 10371 * Return the offset of the character immediately following the last character
of this node's |
| 10335 * source range. This is equivalent to `node.getOffset() + node.getLength()`. | 10372 * source range. This is equivalent to `node.getOffset() + node.getLength()`. |
| 10336 * | 10373 * |
| 10337 * @return the offset of the character just past the node's source range | 10374 * @return the offset of the character just past the node's source range |
| 10338 */ | 10375 */ |
| 10339 int get end { | 10376 int get end { |
| 10340 if (filters.isEmpty) { | 10377 if (filters.isEmpty) { |
| 10341 return expression.end; | 10378 return expression.end; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10375 int get offset => expression.offset; | 10412 int get offset => expression.offset; |
| 10376 } | 10413 } |
| 10377 | 10414 |
| 10378 /** | 10415 /** |
| 10379 * Angular filter argument. | 10416 * Angular filter argument. |
| 10380 */ | 10417 */ |
| 10381 class AngularFilterArgument { | 10418 class AngularFilterArgument { |
| 10382 /** | 10419 /** |
| 10383 * The [TokenType#COLON] token. | 10420 * The [TokenType#COLON] token. |
| 10384 */ | 10421 */ |
| 10385 Token token; | 10422 final Token token; |
| 10386 | 10423 |
| 10387 /** | 10424 /** |
| 10388 * The argument expression. | 10425 * The argument expression. |
| 10389 */ | 10426 */ |
| 10390 Expression expression; | 10427 final Expression expression; |
| 10391 | 10428 |
| 10392 /** | 10429 /** |
| 10393 * The optional sub-[Expression]s. | 10430 * The optional sub-[Expression]s. |
| 10394 */ | 10431 */ |
| 10395 List<Expression> subExpressions = Expression.EMPTY_ARRAY; | 10432 List<Expression> subExpressions = Expression.EMPTY_ARRAY; |
| 10396 | 10433 |
| 10397 AngularFilterArgument(Token token, Expression expression) { | 10434 AngularFilterArgument(this.token, this.expression); |
| 10398 this.token = token; | |
| 10399 this.expression = expression; | |
| 10400 } | |
| 10401 } | 10435 } |
| 10402 | 10436 |
| 10403 /** | 10437 /** |
| 10404 * Angular filter node. | 10438 * Angular filter node. |
| 10405 */ | 10439 */ |
| 10406 class AngularFilterNode { | 10440 class AngularFilterNode { |
| 10407 /** | 10441 /** |
| 10408 * The [TokenType#BAR] token. | 10442 * The [TokenType#BAR] token. |
| 10409 */ | 10443 */ |
| 10410 Token token; | 10444 final Token token; |
| 10411 | 10445 |
| 10412 /** | 10446 /** |
| 10413 * The name of the filter. | 10447 * The name of the filter. |
| 10414 */ | 10448 */ |
| 10415 SimpleIdentifier name; | 10449 final SimpleIdentifier name; |
| 10416 | 10450 |
| 10417 /** | 10451 /** |
| 10418 * The arguments for this filter. | 10452 * The arguments for this filter. |
| 10419 */ | 10453 */ |
| 10420 List<AngularFilterArgument> arguments; | 10454 final List<AngularFilterArgument> arguments; |
| 10421 | 10455 |
| 10422 AngularFilterNode(Token token, SimpleIdentifier name, List<AngularFilterArgume
nt> arguments) { | 10456 AngularFilterNode(this.token, this.name, this.arguments); |
| 10423 this.token = token; | |
| 10424 this.name = name; | |
| 10425 this.arguments = arguments; | |
| 10426 } | |
| 10427 } | 10457 } |
| 10428 | 10458 |
| 10429 /** | 10459 /** |
| 10430 * Instances of the class [AngularHtmlUnitResolver] resolve Angular specific exp
ressions. | 10460 * Instances of the class [AngularHtmlUnitResolver] resolve Angular specific exp
ressions. |
| 10431 */ | 10461 */ |
| 10432 class AngularHtmlUnitResolver extends ht.RecursiveXmlVisitor<Object> { | 10462 class AngularHtmlUnitResolver extends ht.RecursiveXmlVisitor<Object> { |
| 10433 static String _NG_APP = "ng-app"; | 10463 static String _NG_APP = "ng-app"; |
| 10434 | 10464 |
| 10435 /** | 10465 /** |
| 10436 * Checks if given [Element] is an artificial local variable and returns corre
sponding | 10466 * Checks if given [Element] is an artificial local variable and returns corre
sponding |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10537 } | 10567 } |
| 10538 | 10568 |
| 10539 static Set<Source> _getLibrarySources(Set<LibraryElement> libraries) { | 10569 static Set<Source> _getLibrarySources(Set<LibraryElement> libraries) { |
| 10540 Set<Source> sources = new Set(); | 10570 Set<Source> sources = new Set(); |
| 10541 for (LibraryElement library in libraries) { | 10571 for (LibraryElement library in libraries) { |
| 10542 sources.add(library.source); | 10572 sources.add(library.source); |
| 10543 } | 10573 } |
| 10544 return sources; | 10574 return sources; |
| 10545 } | 10575 } |
| 10546 | 10576 |
| 10547 InternalAnalysisContext _context; | 10577 final InternalAnalysisContext _context; |
| 10548 | 10578 |
| 10549 TypeProvider _typeProvider; | 10579 TypeProvider _typeProvider; |
| 10550 | 10580 |
| 10551 AngularHtmlUnitResolver_FilteringAnalysisErrorListener _errorListener; | 10581 AngularHtmlUnitResolver_FilteringAnalysisErrorListener _errorListener; |
| 10552 | 10582 |
| 10553 Source _source; | 10583 final Source _source; |
| 10554 | 10584 |
| 10555 LineInfo _lineInfo; | 10585 final LineInfo _lineInfo; |
| 10556 | 10586 |
| 10557 ht.HtmlUnit _unit; | 10587 final ht.HtmlUnit _unit; |
| 10558 | 10588 |
| 10559 List<AngularElement> _angularElements; | 10589 List<AngularElement> _angularElements; |
| 10560 | 10590 |
| 10561 List<NgProcessor> _processors = []; | 10591 List<NgProcessor> _processors = []; |
| 10562 | 10592 |
| 10563 LibraryElementImpl _libraryElement; | 10593 LibraryElementImpl _libraryElement; |
| 10564 | 10594 |
| 10565 CompilationUnitElementImpl _unitElement; | 10595 CompilationUnitElementImpl _unitElement; |
| 10566 | 10596 |
| 10567 FunctionElementImpl _functionElement; | 10597 FunctionElementImpl _functionElement; |
| 10568 | 10598 |
| 10569 ResolverVisitor _resolver; | 10599 ResolverVisitor _resolver; |
| 10570 | 10600 |
| 10571 bool _isAngular = false; | 10601 bool _isAngular = false; |
| 10572 | 10602 |
| 10573 List<LocalVariableElementImpl> _definedVariables = []; | 10603 List<LocalVariableElementImpl> _definedVariables = []; |
| 10574 | 10604 |
| 10575 Set<LibraryElement> _injectedLibraries = new Set(); | 10605 Set<LibraryElement> _injectedLibraries = new Set(); |
| 10576 | 10606 |
| 10577 Scope _topNameScope; | 10607 Scope _topNameScope; |
| 10578 | 10608 |
| 10579 Scope _nameScope; | 10609 Scope _nameScope; |
| 10580 | 10610 |
| 10581 AngularHtmlUnitResolver(InternalAnalysisContext context, AnalysisErrorListener
errorListener, Source source, LineInfo lineInfo, ht.HtmlUnit unit) { | 10611 AngularHtmlUnitResolver(this._context, AnalysisErrorListener errorListener, th
is._source, this._lineInfo, this._unit) { |
| 10582 this._context = context; | 10612 this._typeProvider = _context.typeProvider; |
| 10583 this._typeProvider = context.typeProvider; | |
| 10584 this._errorListener = new AngularHtmlUnitResolver_FilteringAnalysisErrorList
ener(errorListener); | 10613 this._errorListener = new AngularHtmlUnitResolver_FilteringAnalysisErrorList
ener(errorListener); |
| 10585 this._source = source; | |
| 10586 this._lineInfo = lineInfo; | |
| 10587 this._unit = unit; | |
| 10588 } | 10614 } |
| 10589 | 10615 |
| 10590 /** | 10616 /** |
| 10591 * The [AngularApplication] for the Web application with this entry point, may
be | 10617 * The [AngularApplication] for the Web application with this entry point, may
be |
| 10592 * `null` if not an entry point. | 10618 * `null` if not an entry point. |
| 10593 */ | 10619 */ |
| 10594 AngularApplication calculateAngularApplication() { | 10620 AngularApplication calculateAngularApplication() { |
| 10595 // check if Angular at all | 10621 // check if Angular at all |
| 10596 if (!hasAngularAnnotation(_unit)) { | 10622 if (!hasAngularAnnotation(_unit)) { |
| 10597 return null; | 10623 return null; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10788 Token barToken = filterToken; | 10814 Token barToken = filterToken; |
| 10789 filterToken = filterToken.next; | 10815 filterToken = filterToken.next; |
| 10790 // TODO(scheglov) report missing identifier | 10816 // TODO(scheglov) report missing identifier |
| 10791 SimpleIdentifier name = _parseDartExpressionInToken(filterToken) as Simple
Identifier; | 10817 SimpleIdentifier name = _parseDartExpressionInToken(filterToken) as Simple
Identifier; |
| 10792 filterToken = name.endToken.next; | 10818 filterToken = name.endToken.next; |
| 10793 // parse arguments | 10819 // parse arguments |
| 10794 List<AngularFilterArgument> arguments = []; | 10820 List<AngularFilterArgument> arguments = []; |
| 10795 while (filterToken.type != TokenType.EOF) { | 10821 while (filterToken.type != TokenType.EOF) { |
| 10796 // skip ":" | 10822 // skip ":" |
| 10797 Token colonToken = filterToken; | 10823 Token colonToken = filterToken; |
| 10798 if (identical(colonToken.type, TokenType.COLON)) { | 10824 if (colonToken.type == TokenType.COLON) { |
| 10799 filterToken = filterToken.next; | 10825 filterToken = filterToken.next; |
| 10800 } else { | 10826 } else { |
| 10801 _reportErrorForToken(AngularCode.MISSING_FILTER_COLON, colonToken, [])
; | 10827 _reportErrorForToken(AngularCode.MISSING_FILTER_COLON, colonToken, [])
; |
| 10802 } | 10828 } |
| 10803 // parse argument | 10829 // parse argument |
| 10804 Expression argument = _parseDartExpressionInToken(filterToken); | 10830 Expression argument = _parseDartExpressionInToken(filterToken); |
| 10805 arguments.add(new AngularFilterArgument(colonToken, argument)); | 10831 arguments.add(new AngularFilterArgument(colonToken, argument)); |
| 10806 // next token | 10832 // next token |
| 10807 filterToken = argument.endToken.next; | 10833 filterToken = argument.endToken.next; |
| 10808 } | 10834 } |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10981 if (!expressions.isEmpty) { | 11007 if (!expressions.isEmpty) { |
| 10982 node.expressions = new List.from(expressions); | 11008 node.expressions = new List.from(expressions); |
| 10983 } | 11009 } |
| 10984 } | 11010 } |
| 10985 | 11011 |
| 10986 void _parseEmbeddedExpressionsInTag(ht.XmlTagNode node) { | 11012 void _parseEmbeddedExpressionsInTag(ht.XmlTagNode node) { |
| 10987 List<AngularMoustacheXmlExpression> expressions = []; | 11013 List<AngularMoustacheXmlExpression> expressions = []; |
| 10988 ht.Token token = node.attributeEnd; | 11014 ht.Token token = node.attributeEnd; |
| 10989 ht.Token endToken = node.endToken; | 11015 ht.Token endToken = node.endToken; |
| 10990 bool inChild = false; | 11016 bool inChild = false; |
| 10991 while (token != endToken) { | 11017 while (!identical(token, endToken)) { |
| 10992 for (ht.XmlTagNode child in node.tagNodes) { | 11018 for (ht.XmlTagNode child in node.tagNodes) { |
| 10993 if (identical(token, child.beginToken)) { | 11019 if (identical(token, child.beginToken)) { |
| 10994 inChild = true; | 11020 inChild = true; |
| 10995 break; | 11021 break; |
| 10996 } | 11022 } |
| 10997 if (identical(token, child.endToken)) { | 11023 if (identical(token, child.endToken)) { |
| 10998 inChild = false; | 11024 inChild = false; |
| 10999 break; | 11025 break; |
| 11000 } | 11026 } |
| 11001 } | 11027 } |
| 11002 if (!inChild && identical(token.type, ht.TokenType.TEXT)) { | 11028 if (!inChild && token.type == ht.TokenType.TEXT) { |
| 11003 _parseEmbeddedExpressions(expressions, token); | 11029 _parseEmbeddedExpressions(expressions, token); |
| 11004 } | 11030 } |
| 11005 token = token.next; | 11031 token = token.next; |
| 11006 } | 11032 } |
| 11007 node.expressions = new List.from(expressions); | 11033 node.expressions = new List.from(expressions); |
| 11008 } | 11034 } |
| 11009 | 11035 |
| 11010 void _recordDefinedVariable(LocalVariableElementImpl variable) { | 11036 void _recordDefinedVariable(LocalVariableElementImpl variable) { |
| 11011 _definedVariables.add(variable); | 11037 _definedVariables.add(variable); |
| 11012 _functionElement.localVariables = new List.from(_definedVariables); | 11038 _functionElement.localVariables = new List.from(_definedVariables); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11091 | 11117 |
| 11092 void _resolveXmlExpression(AngularXmlExpression angularXmlExpression) { | 11118 void _resolveXmlExpression(AngularXmlExpression angularXmlExpression) { |
| 11093 AngularExpression angularExpression = angularXmlExpression.expression; | 11119 AngularExpression angularExpression = angularXmlExpression.expression; |
| 11094 _resolveExpression(angularExpression); | 11120 _resolveExpression(angularExpression); |
| 11095 } | 11121 } |
| 11096 | 11122 |
| 11097 List<Token> _splitAtBar(Token token) { | 11123 List<Token> _splitAtBar(Token token) { |
| 11098 List<Token> tokens = []; | 11124 List<Token> tokens = []; |
| 11099 tokens.add(token); | 11125 tokens.add(token); |
| 11100 while (token.type != TokenType.EOF) { | 11126 while (token.type != TokenType.EOF) { |
| 11101 if (identical(token.type, TokenType.BAR)) { | 11127 if (token.type == TokenType.BAR) { |
| 11102 tokens.add(token); | 11128 tokens.add(token); |
| 11103 Token eofToken = new Token(TokenType.EOF, 0); | 11129 Token eofToken = new Token(TokenType.EOF, 0); |
| 11104 token.previous.setNext(eofToken); | 11130 token.previous.setNext(eofToken); |
| 11105 } | 11131 } |
| 11106 token = token.next; | 11132 token = token.next; |
| 11107 } | 11133 } |
| 11108 return tokens; | 11134 return tokens; |
| 11109 } | 11135 } |
| 11110 | 11136 |
| 11111 /** | 11137 /** |
| 11112 * The "ng-model" directive is special, it contributes to the top-level name s
cope. These models | 11138 * The "ng-model" directive is special, it contributes to the top-level name s
cope. These models |
| 11113 * can be used before actual "ng-model" attribute in HTML. So, we need to defi
ne them once we | 11139 * can be used before actual "ng-model" attribute in HTML. So, we need to defi
ne them once we |
| 11114 * found [NG_APP] context. | 11140 * found [NG_APP] context. |
| 11115 */ | 11141 */ |
| 11116 void _visitModelDirectives(ht.XmlTagNode appNode) { | 11142 void _visitModelDirectives(ht.XmlTagNode appNode) { |
| 11117 appNode.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDir
ectives(this)); | 11143 appNode.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDir
ectives(this)); |
| 11118 } | 11144 } |
| 11119 } | 11145 } |
| 11120 | 11146 |
| 11121 class AngularHtmlUnitResolver_FilteringAnalysisErrorListener implements Analysis
ErrorListener { | 11147 class AngularHtmlUnitResolver_FilteringAnalysisErrorListener implements Analysis
ErrorListener { |
| 11122 AnalysisErrorListener _listener; | 11148 final AnalysisErrorListener _listener; |
| 11123 | 11149 |
| 11124 AngularHtmlUnitResolver_FilteringAnalysisErrorListener(AnalysisErrorListener l
istener) { | 11150 AngularHtmlUnitResolver_FilteringAnalysisErrorListener(this._listener); |
| 11125 this._listener = listener; | |
| 11126 } | |
| 11127 | 11151 |
| 11128 @override | 11152 @override |
| 11129 void onError(AnalysisError error) { | 11153 void onError(AnalysisError error) { |
| 11130 ErrorCode errorCode = error.errorCode; | 11154 ErrorCode errorCode = error.errorCode; |
| 11131 if (identical(errorCode, StaticWarningCode.UNDEFINED_GETTER) || identical(er
rorCode, StaticWarningCode.UNDEFINED_IDENTIFIER) || identical(errorCode, StaticT
ypeWarningCode.UNDEFINED_GETTER)) { | 11155 if (identical(errorCode, StaticWarningCode.UNDEFINED_GETTER) || identical(er
rorCode, StaticWarningCode.UNDEFINED_IDENTIFIER) || identical(errorCode, StaticT
ypeWarningCode.UNDEFINED_GETTER)) { |
| 11132 return; | 11156 return; |
| 11133 } | 11157 } |
| 11134 _listener.onError(error); | 11158 _listener.onError(error); |
| 11135 } | 11159 } |
| 11136 } | 11160 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11176 | 11200 |
| 11177 static String CLOSING_DELIMITER = "}}"; | 11201 static String CLOSING_DELIMITER = "}}"; |
| 11178 | 11202 |
| 11179 static int OPENING_DELIMITER_LENGTH = OPENING_DELIMITER.length; | 11203 static int OPENING_DELIMITER_LENGTH = OPENING_DELIMITER.length; |
| 11180 | 11204 |
| 11181 static int CLOSING_DELIMITER_LENGTH = CLOSING_DELIMITER.length; | 11205 static int CLOSING_DELIMITER_LENGTH = CLOSING_DELIMITER.length; |
| 11182 | 11206 |
| 11183 /** | 11207 /** |
| 11184 * The offset of the first character of the opening delimiter. | 11208 * The offset of the first character of the opening delimiter. |
| 11185 */ | 11209 */ |
| 11186 int _openingOffset = 0; | 11210 final int _openingOffset; |
| 11187 | 11211 |
| 11188 /** | 11212 /** |
| 11189 * The offset of the first character of the closing delimiter. | 11213 * The offset of the first character of the closing delimiter. |
| 11190 */ | 11214 */ |
| 11191 int _closingOffset = 0; | 11215 final int _closingOffset; |
| 11192 | 11216 |
| 11193 AngularMoustacheXmlExpression(int openingOffset, int closingOffset, AngularExp
ression expression) : super(expression) { | 11217 AngularMoustacheXmlExpression(this._openingOffset, this._closingOffset, Angula
rExpression expression) : super(expression); |
| 11194 this._openingOffset = openingOffset; | |
| 11195 this._closingOffset = closingOffset; | |
| 11196 } | |
| 11197 | 11218 |
| 11198 @override | 11219 @override |
| 11199 int get end => _closingOffset + CLOSING_DELIMITER_LENGTH; | 11220 int get end => _closingOffset + CLOSING_DELIMITER_LENGTH; |
| 11200 | 11221 |
| 11201 @override | 11222 @override |
| 11202 int get length => _closingOffset + CLOSING_DELIMITER_LENGTH - _openingOffset; | 11223 int get length => _closingOffset + CLOSING_DELIMITER_LENGTH - _openingOffset; |
| 11203 | 11224 |
| 11204 @override | 11225 @override |
| 11205 int get offset => _openingOffset; | 11226 int get offset => _openingOffset; |
| 11206 } | 11227 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 11222 int get offset => expression.offset; | 11243 int get offset => expression.offset; |
| 11223 } | 11244 } |
| 11224 | 11245 |
| 11225 /** | 11246 /** |
| 11226 * Abstract Angular specific [XmlExpression]. | 11247 * Abstract Angular specific [XmlExpression]. |
| 11227 */ | 11248 */ |
| 11228 abstract class AngularXmlExpression extends ht.XmlExpression { | 11249 abstract class AngularXmlExpression extends ht.XmlExpression { |
| 11229 /** | 11250 /** |
| 11230 * The expression that is enclosed between the delimiters. | 11251 * The expression that is enclosed between the delimiters. |
| 11231 */ | 11252 */ |
| 11232 AngularExpression expression; | 11253 final AngularExpression expression; |
| 11233 | 11254 |
| 11234 AngularXmlExpression(AngularExpression expression) { | 11255 AngularXmlExpression(this.expression); |
| 11235 this.expression = expression; | |
| 11236 } | |
| 11237 | 11256 |
| 11238 @override | 11257 @override |
| 11239 ht.XmlExpression_Reference getReference(int offset) { | 11258 ht.XmlExpression_Reference getReference(int offset) { |
| 11240 // main expression | 11259 // main expression |
| 11241 ht.XmlExpression_Reference reference = _getReferenceAtNode(expression.expres
sion, offset); | 11260 ht.XmlExpression_Reference reference = _getReferenceAtNode(expression.expres
sion, offset); |
| 11242 if (reference != null) { | 11261 if (reference != null) { |
| 11243 return reference; | 11262 return reference; |
| 11244 } | 11263 } |
| 11245 // filters | 11264 // filters |
| 11246 for (AngularFilterNode filter in expression.filters) { | 11265 for (AngularFilterNode filter in expression.filters) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11315 } | 11334 } |
| 11316 } | 11335 } |
| 11317 } | 11336 } |
| 11318 } | 11337 } |
| 11319 | 11338 |
| 11320 /** | 11339 /** |
| 11321 * [NgComponentElementProcessor] applies [AngularComponentElement] by parsing ma
pped | 11340 * [NgComponentElementProcessor] applies [AngularComponentElement] by parsing ma
pped |
| 11322 * attributes as expressions. | 11341 * attributes as expressions. |
| 11323 */ | 11342 */ |
| 11324 class NgComponentElementProcessor extends NgDirectiveProcessor { | 11343 class NgComponentElementProcessor extends NgDirectiveProcessor { |
| 11325 AngularComponentElement _element; | 11344 final AngularComponentElement _element; |
| 11326 | 11345 |
| 11327 NgComponentElementProcessor(AngularComponentElement element) { | 11346 NgComponentElementProcessor(this._element); |
| 11328 this._element = element; | |
| 11329 } | |
| 11330 | 11347 |
| 11331 @override | 11348 @override |
| 11332 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { | 11349 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { |
| 11333 node.element = _element.selector; | 11350 node.element = _element.selector; |
| 11334 for (AngularPropertyElement property in _element.properties) { | 11351 for (AngularPropertyElement property in _element.properties) { |
| 11335 String name = property.name; | 11352 String name = property.name; |
| 11336 ht.XmlAttributeNode attribute = node.getAttribute(name); | 11353 ht.XmlAttributeNode attribute = node.getAttribute(name); |
| 11337 if (attribute != null) { | 11354 if (attribute != null) { |
| 11338 attribute.element = property; | 11355 attribute.element = property; |
| 11339 // resolve if binding | 11356 // resolve if binding |
| 11340 if (property.propertyKind != AngularPropertyKind.ATTR) { | 11357 if (property.propertyKind != AngularPropertyKind.ATTR) { |
| 11341 AngularExpression expression = parseAngularExpression(resolver, attrib
ute); | 11358 AngularExpression expression = parseAngularExpression(resolver, attrib
ute); |
| 11342 resolver._resolveExpression(expression); | 11359 resolver._resolveExpression(expression); |
| 11343 setAngularExpression(attribute, expression); | 11360 setAngularExpression(attribute, expression); |
| 11344 } | 11361 } |
| 11345 } | 11362 } |
| 11346 } | 11363 } |
| 11347 } | 11364 } |
| 11348 | 11365 |
| 11349 @override | 11366 @override |
| 11350 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); | 11367 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); |
| 11351 } | 11368 } |
| 11352 | 11369 |
| 11353 /** | 11370 /** |
| 11354 * [NgControllerElementProcessor] applies [AngularControllerElement]. | 11371 * [NgControllerElementProcessor] applies [AngularControllerElement]. |
| 11355 */ | 11372 */ |
| 11356 class NgControllerElementProcessor extends NgProcessor { | 11373 class NgControllerElementProcessor extends NgProcessor { |
| 11357 AngularControllerElement _element; | 11374 final AngularControllerElement _element; |
| 11358 | 11375 |
| 11359 NgControllerElementProcessor(AngularControllerElement element) { | 11376 NgControllerElementProcessor(this._element); |
| 11360 this._element = element; | |
| 11361 } | |
| 11362 | 11377 |
| 11363 @override | 11378 @override |
| 11364 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { | 11379 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { |
| 11365 InterfaceType type = (_element.enclosingElement as ClassElement).type; | 11380 InterfaceType type = (_element.enclosingElement as ClassElement).type; |
| 11366 String name = _element.name; | 11381 String name = _element.name; |
| 11367 LocalVariableElementImpl variable = resolver._createLocalVariableWithName(ty
pe, name); | 11382 LocalVariableElementImpl variable = resolver._createLocalVariableWithName(ty
pe, name); |
| 11368 resolver._defineVariable(variable); | 11383 resolver._defineVariable(variable); |
| 11369 variable.toolkitObjects = <AngularElement> [_element]; | 11384 variable.toolkitObjects = <AngularElement> [_element]; |
| 11370 } | 11385 } |
| 11371 | 11386 |
| 11372 @override | 11387 @override |
| 11373 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); | 11388 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); |
| 11374 } | 11389 } |
| 11375 | 11390 |
| 11376 /** | 11391 /** |
| 11377 * [NgDirectiveElementProcessor] applies [AngularDirectiveElement] by parsing ma
pped | 11392 * [NgDirectiveElementProcessor] applies [AngularDirectiveElement] by parsing ma
pped |
| 11378 * attributes as expressions. | 11393 * attributes as expressions. |
| 11379 */ | 11394 */ |
| 11380 class NgDirectiveElementProcessor extends NgDirectiveProcessor { | 11395 class NgDirectiveElementProcessor extends NgDirectiveProcessor { |
| 11381 AngularDirectiveElement _element; | 11396 final AngularDirectiveElement _element; |
| 11382 | 11397 |
| 11383 NgDirectiveElementProcessor(AngularDirectiveElement element) { | 11398 NgDirectiveElementProcessor(this._element); |
| 11384 this._element = element; | |
| 11385 } | |
| 11386 | 11399 |
| 11387 @override | 11400 @override |
| 11388 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { | 11401 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { |
| 11389 String selectorAttributeName = null; | 11402 String selectorAttributeName = null; |
| 11390 { | 11403 { |
| 11391 AngularSelectorElement selector = _element.selector; | 11404 AngularSelectorElement selector = _element.selector; |
| 11392 if (selector is HasAttributeSelectorElementImpl) { | 11405 if (selector is HasAttributeSelectorElementImpl) { |
| 11393 selectorAttributeName = selector.name; | 11406 selectorAttributeName = selector.name; |
| 11394 // resolve attribute expression | 11407 // resolve attribute expression |
| 11395 ht.XmlAttributeNode attribute = node.getAttribute(selectorAttributeName)
; | 11408 ht.XmlAttributeNode attribute = node.getAttribute(selectorAttributeName)
; |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11569 } | 11582 } |
| 11570 | 11583 |
| 11571 /** | 11584 /** |
| 11572 * The abstract class `AnalysisTask` defines the behavior of objects used to per
form an | 11585 * The abstract class `AnalysisTask` defines the behavior of objects used to per
form an |
| 11573 * analysis task. | 11586 * analysis task. |
| 11574 */ | 11587 */ |
| 11575 abstract class AnalysisTask { | 11588 abstract class AnalysisTask { |
| 11576 /** | 11589 /** |
| 11577 * The context in which the task is to be performed. | 11590 * The context in which the task is to be performed. |
| 11578 */ | 11591 */ |
| 11579 InternalAnalysisContext context; | 11592 final InternalAnalysisContext context; |
| 11580 | 11593 |
| 11581 /** | 11594 /** |
| 11582 * The exception that was thrown while performing this task, or `null` if the
task completed | 11595 * The exception that was thrown while performing this task, or `null` if the
task completed |
| 11583 * successfully. | 11596 * successfully. |
| 11584 */ | 11597 */ |
| 11585 AnalysisException _thrownException; | 11598 AnalysisException _thrownException; |
| 11586 | 11599 |
| 11587 /** | 11600 /** |
| 11588 * Initialize a newly created task to perform analysis within the given contex
t. | 11601 * Initialize a newly created task to perform analysis within the given contex
t. |
| 11589 * | 11602 * |
| 11590 * @param context the context in which the task is to be performed | 11603 * @param context the context in which the task is to be performed |
| 11591 */ | 11604 */ |
| 11592 AnalysisTask(InternalAnalysisContext context) { | 11605 AnalysisTask(this.context); |
| 11593 this.context = context; | |
| 11594 } | |
| 11595 | 11606 |
| 11596 /** | 11607 /** |
| 11597 * Use the given visitor to visit this task. | 11608 * Use the given visitor to visit this task. |
| 11598 * | 11609 * |
| 11599 * @param visitor the visitor that should be used to visit this task | 11610 * @param visitor the visitor that should be used to visit this task |
| 11600 * @return the value returned by the visitor | 11611 * @return the value returned by the visitor |
| 11601 * @throws AnalysisException if the visitor throws the exception | 11612 * @throws AnalysisException if the visitor throws the exception |
| 11602 */ | 11613 */ |
| 11603 accept(AnalysisTaskVisitor visitor); | 11614 accept(AnalysisTaskVisitor visitor); |
| 11604 | 11615 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11786 } | 11797 } |
| 11787 | 11798 |
| 11788 /** | 11799 /** |
| 11789 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings
for a single | 11800 * Instances of the class `GenerateDartErrorsTask` generate errors and warnings
for a single |
| 11790 * Dart source. | 11801 * Dart source. |
| 11791 */ | 11802 */ |
| 11792 class GenerateDartErrorsTask extends AnalysisTask { | 11803 class GenerateDartErrorsTask extends AnalysisTask { |
| 11793 /** | 11804 /** |
| 11794 * The source for which errors and warnings are to be produced. | 11805 * The source for which errors and warnings are to be produced. |
| 11795 */ | 11806 */ |
| 11796 Source source; | 11807 final Source source; |
| 11797 | 11808 |
| 11798 /** | 11809 /** |
| 11799 * The time at which the contents of the source were last modified. | 11810 * The time at which the contents of the source were last modified. |
| 11800 */ | 11811 */ |
| 11801 int modificationTime = 0; | 11812 final int modificationTime; |
| 11802 | 11813 |
| 11803 /** | 11814 /** |
| 11804 * The compilation unit used to resolve the dependencies. | 11815 * The compilation unit used to resolve the dependencies. |
| 11805 */ | 11816 */ |
| 11806 CompilationUnit _unit; | 11817 final CompilationUnit _unit; |
| 11807 | 11818 |
| 11808 /** | 11819 /** |
| 11809 * The element model for the library containing the source. | 11820 * The element model for the library containing the source. |
| 11810 */ | 11821 */ |
| 11811 LibraryElement libraryElement; | 11822 final LibraryElement libraryElement; |
| 11812 | 11823 |
| 11813 /** | 11824 /** |
| 11814 * The errors that were generated for the source. | 11825 * The errors that were generated for the source. |
| 11815 */ | 11826 */ |
| 11816 List<AnalysisError> _errors; | 11827 List<AnalysisError> _errors; |
| 11817 | 11828 |
| 11818 /** | 11829 /** |
| 11819 * Initialize a newly created task to perform analysis within the given contex
t. | 11830 * Initialize a newly created task to perform analysis within the given contex
t. |
| 11820 * | 11831 * |
| 11821 * @param context the context in which the task is to be performed | 11832 * @param context the context in which the task is to be performed |
| 11822 * @param source the source for which errors and warnings are to be produced | 11833 * @param source the source for which errors and warnings are to be produced |
| 11823 * @param modificationTime the time at which the contents of the source were l
ast modified | 11834 * @param modificationTime the time at which the contents of the source were l
ast modified |
| 11824 * @param unit the compilation unit used to resolve the dependencies | 11835 * @param unit the compilation unit used to resolve the dependencies |
| 11825 * @param libraryElement the element model for the library containing the sour
ce | 11836 * @param libraryElement the element model for the library containing the sour
ce |
| 11826 */ | 11837 */ |
| 11827 GenerateDartErrorsTask(InternalAnalysisContext context, Source source, int mod
ificationTime, CompilationUnit unit, LibraryElement libraryElement) : super(cont
ext) { | 11838 GenerateDartErrorsTask(InternalAnalysisContext context, this.source, this.modi
ficationTime, this._unit, this.libraryElement) : super(context); |
| 11828 this.source = source; | |
| 11829 this.modificationTime = modificationTime; | |
| 11830 this._unit = unit; | |
| 11831 this.libraryElement = libraryElement; | |
| 11832 } | |
| 11833 | 11839 |
| 11834 @override | 11840 @override |
| 11835 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartErrorsTask(thi
s); | 11841 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartErrorsTask(thi
s); |
| 11836 | 11842 |
| 11837 /** | 11843 /** |
| 11838 * Return the errors that were generated for the source. | 11844 * Return the errors that were generated for the source. |
| 11839 * | 11845 * |
| 11840 * @return the errors that were generated for the source | 11846 * @return the errors that were generated for the source |
| 11841 */ | 11847 */ |
| 11842 List<AnalysisError> get errors => _errors; | 11848 List<AnalysisError> get errors => _errors; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 11870 } | 11876 } |
| 11871 | 11877 |
| 11872 /** | 11878 /** |
| 11873 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. | 11879 * Instances of the class `GenerateDartHintsTask` generate hints for a single Da
rt library. |
| 11874 */ | 11880 */ |
| 11875 class GenerateDartHintsTask extends AnalysisTask { | 11881 class GenerateDartHintsTask extends AnalysisTask { |
| 11876 /** | 11882 /** |
| 11877 * The compilation units that comprise the library, with the defining compilat
ion unit appearing | 11883 * The compilation units that comprise the library, with the defining compilat
ion unit appearing |
| 11878 * first in the array. | 11884 * first in the array. |
| 11879 */ | 11885 */ |
| 11880 List<TimestampedData<CompilationUnit>> _units; | 11886 final List<TimestampedData<CompilationUnit>> _units; |
| 11881 | 11887 |
| 11882 /** | 11888 /** |
| 11883 * The element model for the library being analyzed. | 11889 * The element model for the library being analyzed. |
| 11884 */ | 11890 */ |
| 11885 LibraryElement libraryElement; | 11891 final LibraryElement libraryElement; |
| 11886 | 11892 |
| 11887 /** | 11893 /** |
| 11888 * A table mapping the sources that were analyzed to the hints that were gener
ated for the | 11894 * A table mapping the sources that were analyzed to the hints that were gener
ated for the |
| 11889 * sources. | 11895 * sources. |
| 11890 */ | 11896 */ |
| 11891 Map<Source, TimestampedData<List<AnalysisError>>> _hintMap; | 11897 Map<Source, TimestampedData<List<AnalysisError>>> _hintMap; |
| 11892 | 11898 |
| 11893 /** | 11899 /** |
| 11894 * Initialize a newly created task to perform analysis within the given contex
t. | 11900 * Initialize a newly created task to perform analysis within the given contex
t. |
| 11895 * | 11901 * |
| 11896 * @param context the context in which the task is to be performed | 11902 * @param context the context in which the task is to be performed |
| 11897 * @param units the compilation units that comprise the library, with the defi
ning compilation | 11903 * @param units the compilation units that comprise the library, with the defi
ning compilation |
| 11898 * unit appearing first in the array | 11904 * unit appearing first in the array |
| 11899 * @param libraryElement the element model for the library being analyzed | 11905 * @param libraryElement the element model for the library being analyzed |
| 11900 */ | 11906 */ |
| 11901 GenerateDartHintsTask(InternalAnalysisContext context, List<TimestampedData<Co
mpilationUnit>> units, LibraryElement libraryElement) : super(context) { | 11907 GenerateDartHintsTask(InternalAnalysisContext context, this._units, this.libra
ryElement) : super(context); |
| 11902 this._units = units; | |
| 11903 this.libraryElement = libraryElement; | |
| 11904 } | |
| 11905 | 11908 |
| 11906 @override | 11909 @override |
| 11907 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this
); | 11910 accept(AnalysisTaskVisitor visitor) => visitor.visitGenerateDartHintsTask(this
); |
| 11908 | 11911 |
| 11909 /** | 11912 /** |
| 11910 * Return a table mapping the sources that were analyzed to the hints that wer
e generated for the | 11913 * Return a table mapping the sources that were analyzed to the hints that wer
e generated for the |
| 11911 * sources, or `null` if the task has not been performed or if the analysis di
d not complete | 11914 * sources, or `null` if the task has not been performed or if the analysis di
d not complete |
| 11912 * normally. | 11915 * normally. |
| 11913 * | 11916 * |
| 11914 * @return a table mapping the sources that were analyzed to the hints that we
re generated for the | 11917 * @return a table mapping the sources that were analyzed to the hints that we
re generated for the |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11954 } | 11957 } |
| 11955 } | 11958 } |
| 11956 | 11959 |
| 11957 /** | 11960 /** |
| 11958 * Instances of the class `GetContentTask` get the contents of a source. | 11961 * Instances of the class `GetContentTask` get the contents of a source. |
| 11959 */ | 11962 */ |
| 11960 class GetContentTask extends AnalysisTask { | 11963 class GetContentTask extends AnalysisTask { |
| 11961 /** | 11964 /** |
| 11962 * The source to be read. | 11965 * The source to be read. |
| 11963 */ | 11966 */ |
| 11964 Source source; | 11967 final Source source; |
| 11965 | 11968 |
| 11966 /** | 11969 /** |
| 11967 * A flag indicating whether this task is complete. | 11970 * A flag indicating whether this task is complete. |
| 11968 */ | 11971 */ |
| 11969 bool _complete = false; | 11972 bool _complete = false; |
| 11970 | 11973 |
| 11971 /** | 11974 /** |
| 11972 * The contents of the source. | 11975 * The contents of the source. |
| 11973 */ | 11976 */ |
| 11974 String _content; | 11977 String _content; |
| 11975 | 11978 |
| 11976 /** | 11979 /** |
| 11977 * The time at which the contents of the source were last modified. | 11980 * The time at which the contents of the source were last modified. |
| 11978 */ | 11981 */ |
| 11979 int _modificationTime = -1; | 11982 int _modificationTime = -1; |
| 11980 | 11983 |
| 11981 /** | 11984 /** |
| 11982 * Initialize a newly created task to perform analysis within the given contex
t. | 11985 * Initialize a newly created task to perform analysis within the given contex
t. |
| 11983 * | 11986 * |
| 11984 * @param context the context in which the task is to be performed | 11987 * @param context the context in which the task is to be performed |
| 11985 * @param source the source to be parsed | 11988 * @param source the source to be parsed |
| 11986 * @param contentData the time-stamped contents of the source | 11989 * @param contentData the time-stamped contents of the source |
| 11987 */ | 11990 */ |
| 11988 GetContentTask(InternalAnalysisContext context, Source source) : super(context
) { | 11991 GetContentTask(InternalAnalysisContext context, this.source) : super(context)
{ |
| 11989 if (source == null) { | 11992 if (source == null) { |
| 11990 throw new IllegalArgumentException("Cannot get contents of null source"); | 11993 throw new IllegalArgumentException("Cannot get contents of null source"); |
| 11991 } | 11994 } |
| 11992 this.source = source; | |
| 11993 } | 11995 } |
| 11994 | 11996 |
| 11995 @override | 11997 @override |
| 11996 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this); | 11998 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this); |
| 11997 | 11999 |
| 11998 /** | 12000 /** |
| 11999 * Return the contents of the source, or `null` if the task has not completed
or if there | 12001 * Return the contents of the source, or `null` if the task has not completed
or if there |
| 12000 * was an exception while getting the contents. | 12002 * was an exception while getting the contents. |
| 12001 * | 12003 * |
| 12002 * @return the contents of the source | 12004 * @return the contents of the source |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12038 } | 12040 } |
| 12039 } | 12041 } |
| 12040 | 12042 |
| 12041 /** | 12043 /** |
| 12042 * Instances of the class `IncrementalAnalysisTask` incrementally update existin
g analysis. | 12044 * Instances of the class `IncrementalAnalysisTask` incrementally update existin
g analysis. |
| 12043 */ | 12045 */ |
| 12044 class IncrementalAnalysisTask extends AnalysisTask { | 12046 class IncrementalAnalysisTask extends AnalysisTask { |
| 12045 /** | 12047 /** |
| 12046 * The information used to perform incremental analysis. | 12048 * The information used to perform incremental analysis. |
| 12047 */ | 12049 */ |
| 12048 IncrementalAnalysisCache cache; | 12050 final IncrementalAnalysisCache cache; |
| 12049 | 12051 |
| 12050 /** | 12052 /** |
| 12051 * The compilation unit that was produced by incrementally updating the existi
ng unit. | 12053 * The compilation unit that was produced by incrementally updating the existi
ng unit. |
| 12052 */ | 12054 */ |
| 12053 CompilationUnit _updatedUnit; | 12055 CompilationUnit _updatedUnit; |
| 12054 | 12056 |
| 12055 /** | 12057 /** |
| 12056 * Initialize a newly created task to perform analysis within the given contex
t. | 12058 * Initialize a newly created task to perform analysis within the given contex
t. |
| 12057 * | 12059 * |
| 12058 * @param context the context in which the task is to be performed | 12060 * @param context the context in which the task is to be performed |
| 12059 * @param cache the incremental analysis cache used to perform the analysis | 12061 * @param cache the incremental analysis cache used to perform the analysis |
| 12060 */ | 12062 */ |
| 12061 IncrementalAnalysisTask(InternalAnalysisContext context, IncrementalAnalysisCa
che cache) : super(context) { | 12063 IncrementalAnalysisTask(InternalAnalysisContext context, this.cache) : super(c
ontext); |
| 12062 this.cache = cache; | |
| 12063 } | |
| 12064 | 12064 |
| 12065 @override | 12065 @override |
| 12066 accept(AnalysisTaskVisitor visitor) => visitor.visitIncrementalAnalysisTask(th
is); | 12066 accept(AnalysisTaskVisitor visitor) => visitor.visitIncrementalAnalysisTask(th
is); |
| 12067 | 12067 |
| 12068 /** | 12068 /** |
| 12069 * Return the compilation unit that was produced by incrementally updating the
existing | 12069 * Return the compilation unit that was produced by incrementally updating the
existing |
| 12070 * compilation unit, or `null` if the task has not yet been performed, could n
ot be | 12070 * compilation unit, or `null` if the task has not yet been performed, could n
ot be |
| 12071 * performed, or if an exception occurred. | 12071 * performed, or if an exception occurred. |
| 12072 * | 12072 * |
| 12073 * @return the compilation unit | 12073 * @return the compilation unit |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12130 return null; | 12130 return null; |
| 12131 } | 12131 } |
| 12132 } | 12132 } |
| 12133 } | 12133 } |
| 12134 | 12134 |
| 12135 /** | 12135 /** |
| 12136 * Instances of the class `ParseDartTask` parse a specific source as a Dart file
. | 12136 * Instances of the class `ParseDartTask` parse a specific source as a Dart file
. |
| 12137 */ | 12137 */ |
| 12138 class ParseDartTask extends AnalysisTask { | 12138 class ParseDartTask extends AnalysisTask { |
| 12139 /** | 12139 /** |
| 12140 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the |
| 12141 * given library, or `null` if the URI is not valid. |
| 12142 * |
| 12143 * @param context the context in which the resolution is to be performed |
| 12144 * @param librarySource the source representing the library containing the dir
ective |
| 12145 * @param directive the directive which URI should be resolved |
| 12146 * @param errorListener the error listener to which errors should be reported |
| 12147 * @return the result of resolving the URI against the URI of the library |
| 12148 */ |
| 12149 static Source resolveSource(AnalysisContext analysisContext, Source librarySou
rce, UriBasedDirective directive, AnalysisErrorListener errorListener) { |
| 12150 StringLiteral uriLiteral = directive.uri; |
| 12151 if (uriLiteral is StringInterpolation) { |
| 12152 errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.off
set, uriLiteral.length, CompileTimeErrorCode.URI_WITH_INTERPOLATION, [])); |
| 12153 return null; |
| 12154 } |
| 12155 String uriContent = uriLiteral.stringValue.trim(); |
| 12156 directive.uriContent = uriContent; |
| 12157 if (directive is ImportDirective && uriContent.startsWith(_DART_EXT_SCHEME))
{ |
| 12158 return null; |
| 12159 } |
| 12160 try { |
| 12161 String encodedUriContent = Uri.encodeFull(uriContent); |
| 12162 parseUriWithException(encodedUriContent); |
| 12163 Source source = analysisContext.sourceFactory.resolveUri(librarySource, en
codedUriContent); |
| 12164 if (!analysisContext.exists(source)) { |
| 12165 errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.o
ffset, uriLiteral.length, CompileTimeErrorCode.URI_DOES_NOT_EXIST, [uriContent])
); |
| 12166 } |
| 12167 directive.source = source; |
| 12168 return source; |
| 12169 } on URISyntaxException catch (exception) { |
| 12170 errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.off
set, uriLiteral.length, CompileTimeErrorCode.INVALID_URI, [uriContent])); |
| 12171 } |
| 12172 return null; |
| 12173 } |
| 12174 |
| 12175 /** |
| 12140 * The source to be parsed. | 12176 * The source to be parsed. |
| 12141 */ | 12177 */ |
| 12142 Source source; | 12178 final Source source; |
| 12143 | 12179 |
| 12144 /** | 12180 /** |
| 12145 * The time at which the contents of the source were last modified. | 12181 * The time at which the contents of the source were last modified. |
| 12146 */ | 12182 */ |
| 12147 int modificationTime = 0; | 12183 final int modificationTime; |
| 12148 | 12184 |
| 12149 /** | 12185 /** |
| 12150 * The head of the token stream used for parsing. | 12186 * The head of the token stream used for parsing. |
| 12151 */ | 12187 */ |
| 12152 Token _tokenStream; | 12188 final Token _tokenStream; |
| 12153 | 12189 |
| 12154 /** | 12190 /** |
| 12155 * The line information associated with the source. | 12191 * The line information associated with the source. |
| 12156 */ | 12192 */ |
| 12157 LineInfo lineInfo; | 12193 final LineInfo lineInfo; |
| 12158 | 12194 |
| 12159 /** | 12195 /** |
| 12160 * The compilation unit that was produced by parsing the source. | 12196 * The compilation unit that was produced by parsing the source. |
| 12161 */ | 12197 */ |
| 12162 CompilationUnit _unit; | 12198 CompilationUnit _unit; |
| 12163 | 12199 |
| 12164 /** | 12200 /** |
| 12165 * A flag indicating whether the source contains a 'library' directive. | |
| 12166 */ | |
| 12167 bool _containsLibraryDirective = false; | |
| 12168 | |
| 12169 /** | |
| 12170 * A flag indicating whether the source contains a 'part of' directive. | 12201 * A flag indicating whether the source contains a 'part of' directive. |
| 12171 */ | 12202 */ |
| 12172 bool _containsPartOfDirective = false; | 12203 bool _containsPartOfDirective = false; |
| 12173 | 12204 |
| 12174 /** | 12205 /** |
| 12206 * A flag indicating whether the source contains any directive other than a 'p
art of' directive. |
| 12207 */ |
| 12208 bool _containsNonPartOfDirective = false; |
| 12209 |
| 12210 /** |
| 12175 * A set containing the sources referenced by 'export' directives. | 12211 * A set containing the sources referenced by 'export' directives. |
| 12176 */ | 12212 */ |
| 12177 Set<Source> _exportedSources = new Set<Source>(); | 12213 Set<Source> _exportedSources = new Set<Source>(); |
| 12178 | 12214 |
| 12179 /** | 12215 /** |
| 12180 * A set containing the sources referenced by 'import' directives. | 12216 * A set containing the sources referenced by 'import' directives. |
| 12181 */ | 12217 */ |
| 12182 Set<Source> _importedSources = new Set<Source>(); | 12218 Set<Source> _importedSources = new Set<Source>(); |
| 12183 | 12219 |
| 12184 /** | 12220 /** |
| (...skipping 13 matching lines...) Expand all Loading... |
| 12198 | 12234 |
| 12199 /** | 12235 /** |
| 12200 * Initialize a newly created task to perform analysis within the given contex
t. | 12236 * Initialize a newly created task to perform analysis within the given contex
t. |
| 12201 * | 12237 * |
| 12202 * @param context the context in which the task is to be performed | 12238 * @param context the context in which the task is to be performed |
| 12203 * @param source the source to be parsed | 12239 * @param source the source to be parsed |
| 12204 * @param modificationTime the time at which the contents of the source were l
ast modified | 12240 * @param modificationTime the time at which the contents of the source were l
ast modified |
| 12205 * @param tokenStream the head of the token stream used for parsing | 12241 * @param tokenStream the head of the token stream used for parsing |
| 12206 * @param lineInfo the line information associated with the source | 12242 * @param lineInfo the line information associated with the source |
| 12207 */ | 12243 */ |
| 12208 ParseDartTask(InternalAnalysisContext context, Source source, int modification
Time, Token tokenStream, LineInfo lineInfo) : super(context) { | 12244 ParseDartTask(InternalAnalysisContext context, this.source, this.modificationT
ime, this._tokenStream, this.lineInfo) : super(context); |
| 12209 this.source = source; | |
| 12210 this.modificationTime = modificationTime; | |
| 12211 this._tokenStream = tokenStream; | |
| 12212 this.lineInfo = lineInfo; | |
| 12213 } | |
| 12214 | 12245 |
| 12215 @override | 12246 @override |
| 12216 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this); | 12247 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this); |
| 12217 | 12248 |
| 12218 /** | 12249 /** |
| 12219 * Return the compilation unit that was produced by parsing the source, or `nu
ll` if the | 12250 * Return the compilation unit that was produced by parsing the source, or `nu
ll` if the |
| 12220 * task has not yet been performed or if an exception occurred. | 12251 * task has not yet been performed or if an exception occurred. |
| 12221 * | 12252 * |
| 12222 * @return the compilation unit that was produced by parsing the source | 12253 * @return the compilation unit that was produced by parsing the source |
| 12223 */ | 12254 */ |
| (...skipping 25 matching lines...) Expand all Loading... |
| 12249 | 12280 |
| 12250 /** | 12281 /** |
| 12251 * Return an array containing the sources referenced by 'part' directives, or
an empty array if | 12282 * Return an array containing the sources referenced by 'part' directives, or
an empty array if |
| 12252 * the task has not yet been performed or if an exception occurred. | 12283 * the task has not yet been performed or if an exception occurred. |
| 12253 * | 12284 * |
| 12254 * @return an array containing the sources referenced by 'part' directives | 12285 * @return an array containing the sources referenced by 'part' directives |
| 12255 */ | 12286 */ |
| 12256 List<Source> get includedSources => _toArray(_includedSources); | 12287 List<Source> get includedSources => _toArray(_includedSources); |
| 12257 | 12288 |
| 12258 /** | 12289 /** |
| 12259 * Return `true` if the source contains a 'library' directive, or `false` if t
he task | 12290 * Return `true` if the source contains any directive other than a 'part of' d
irective, or |
| 12260 * has not yet been performed or if an exception occurred. | 12291 * `false` if the task has not yet been performed or if an exception occurred. |
| 12261 * | 12292 * |
| 12262 * @return `true` if the source contains a 'library' directive | 12293 * @return `true` if the source contains any directive other than a 'part of'
directive |
| 12263 */ | 12294 */ |
| 12264 bool get hasLibraryDirective => _containsLibraryDirective; | 12295 bool get hasNonPartOfDirective => _containsNonPartOfDirective; |
| 12265 | 12296 |
| 12266 /** | 12297 /** |
| 12267 * Return `true` if the source contains a 'part of' directive, or `false` if t
he task | 12298 * Return `true` if the source contains a 'part of' directive, or `false` if t
he task |
| 12268 * has not yet been performed or if an exception occurred. | 12299 * has not yet been performed or if an exception occurred. |
| 12269 * | 12300 * |
| 12270 * @return `true` if the source contains a 'part of' directive | 12301 * @return `true` if the source contains a 'part of' directive |
| 12271 */ | 12302 */ |
| 12272 bool get hasPartOfDirective => _containsPartOfDirective; | 12303 bool get hasPartOfDirective => _containsPartOfDirective; |
| 12273 | 12304 |
| 12274 @override | 12305 @override |
| 12275 String get taskDescription { | 12306 String get taskDescription { |
| 12276 if (source == null) { | 12307 if (source == null) { |
| 12277 return "parse as dart null source"; | 12308 return "parse as dart null source"; |
| 12278 } | 12309 } |
| 12279 return "parse as dart ${source.fullName}"; | 12310 return "parse as dart ${source.fullName}"; |
| 12280 } | 12311 } |
| 12281 | 12312 |
| 12282 @override | 12313 @override |
| 12283 void internalPerform() { | 12314 void internalPerform() { |
| 12284 // | 12315 // |
| 12285 // Then parse the token stream. | 12316 // Then parse the token stream. |
| 12286 // | 12317 // |
| 12287 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse
.start(); | 12318 TimeCounter_TimeCounterHandle timeCounterParse = PerformanceStatistics.parse
.start(); |
| 12288 try { | 12319 try { |
| 12289 RecordingErrorListener errorListener = new RecordingErrorListener(); | 12320 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 12290 Parser parser = new Parser(source, errorListener); | 12321 Parser parser = new Parser(source, errorListener); |
| 12291 parser.parseFunctionBodies = context.analysisOptions.analyzeFunctionBodies
; | 12322 parser.parseFunctionBodies = context.analysisOptions.analyzeFunctionBodies
; |
| 12292 _unit = parser.parseCompilationUnit(_tokenStream); | 12323 _unit = parser.parseCompilationUnit(_tokenStream); |
| 12293 _unit.lineInfo = lineInfo; | 12324 _unit.lineInfo = lineInfo; |
| 12294 _errors = errorListener.getErrorsForSource(source); | 12325 AnalysisContext analysisContext = context; |
| 12295 for (Directive directive in _unit.directives) { | 12326 for (Directive directive in _unit.directives) { |
| 12296 if (directive is ExportDirective) { | 12327 if (directive is PartOfDirective) { |
| 12297 Source exportSource = _resolveSource(source, directive, errorListener)
; | 12328 _containsPartOfDirective = true; |
| 12298 if (exportSource != null) { | 12329 } else { |
| 12299 _exportedSources.add(exportSource); | 12330 _containsNonPartOfDirective = true; |
| 12331 if (directive is ExportDirective) { |
| 12332 Source exportSource = resolveSource(analysisContext, source, directi
ve, errorListener); |
| 12333 if (exportSource != null) { |
| 12334 _exportedSources.add(exportSource); |
| 12335 } |
| 12336 } else if (directive is ImportDirective) { |
| 12337 Source importSource = resolveSource(analysisContext, source, directi
ve, errorListener); |
| 12338 if (importSource != null) { |
| 12339 _importedSources.add(importSource); |
| 12340 } |
| 12341 } else if (directive is PartDirective) { |
| 12342 Source partSource = resolveSource(analysisContext, source, directive
, errorListener); |
| 12343 if (partSource != null && partSource != source) { |
| 12344 _includedSources.add(partSource); |
| 12345 } |
| 12300 } | 12346 } |
| 12301 } else if (directive is ImportDirective) { | |
| 12302 Source importSource = _resolveSource(source, directive, errorListener)
; | |
| 12303 if (importSource != null) { | |
| 12304 _importedSources.add(importSource); | |
| 12305 } | |
| 12306 } else if (directive is LibraryDirective) { | |
| 12307 _containsLibraryDirective = true; | |
| 12308 } else if (directive is PartDirective) { | |
| 12309 Source partSource = _resolveSource(source, directive, errorListener); | |
| 12310 if (partSource != null && partSource != source) { | |
| 12311 _includedSources.add(partSource); | |
| 12312 } | |
| 12313 } else if (directive is PartOfDirective) { | |
| 12314 _containsPartOfDirective = true; | |
| 12315 } | 12347 } |
| 12316 } | 12348 } |
| 12349 _errors = errorListener.getErrorsForSource(source); |
| 12317 } finally { | 12350 } finally { |
| 12318 timeCounterParse.stop(); | 12351 timeCounterParse.stop(); |
| 12319 } | 12352 } |
| 12320 } | 12353 } |
| 12321 | 12354 |
| 12322 /** | 12355 /** |
| 12323 * Return the result of resolving the URI of the given URI-based directive aga
inst the URI of the | |
| 12324 * given library, or `null` if the URI is not valid. | |
| 12325 * | |
| 12326 * @param librarySource the source representing the library containing the dir
ective | |
| 12327 * @param directive the directive which URI should be resolved | |
| 12328 * @param errorListener the error listener to which errors should be reported | |
| 12329 * @return the result of resolving the URI against the URI of the library | |
| 12330 */ | |
| 12331 Source _resolveSource(Source librarySource, UriBasedDirective directive, Analy
sisErrorListener errorListener) { | |
| 12332 StringLiteral uriLiteral = directive.uri; | |
| 12333 if (uriLiteral is StringInterpolation) { | |
| 12334 errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.off
set, uriLiteral.length, CompileTimeErrorCode.URI_WITH_INTERPOLATION, [])); | |
| 12335 return null; | |
| 12336 } | |
| 12337 String uriContent = uriLiteral.stringValue.trim(); | |
| 12338 directive.uriContent = uriContent; | |
| 12339 if (directive is ImportDirective && uriContent.startsWith(_DART_EXT_SCHEME))
{ | |
| 12340 return null; | |
| 12341 } | |
| 12342 try { | |
| 12343 String encodedUriContent = Uri.encodeFull(uriContent); | |
| 12344 parseUriWithException(encodedUriContent); | |
| 12345 AnalysisContext analysisContext = context; | |
| 12346 Source source = analysisContext.sourceFactory.resolveUri(librarySource, en
codedUriContent); | |
| 12347 if (!analysisContext.exists(source)) { | |
| 12348 errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.o
ffset, uriLiteral.length, CompileTimeErrorCode.URI_DOES_NOT_EXIST, [uriContent])
); | |
| 12349 } | |
| 12350 directive.source = source; | |
| 12351 return source; | |
| 12352 } on URISyntaxException catch (exception) { | |
| 12353 errorListener.onError(new AnalysisError.con2(librarySource, uriLiteral.off
set, uriLiteral.length, CompileTimeErrorCode.INVALID_URI, [uriContent])); | |
| 12354 } | |
| 12355 return null; | |
| 12356 } | |
| 12357 | |
| 12358 /** | |
| 12359 * Efficiently convert the given set of sources to an array. | 12356 * Efficiently convert the given set of sources to an array. |
| 12360 * | 12357 * |
| 12361 * @param sources the set to be converted | 12358 * @param sources the set to be converted |
| 12362 * @return an array containing all of the sources in the given set | 12359 * @return an array containing all of the sources in the given set |
| 12363 */ | 12360 */ |
| 12364 List<Source> _toArray(Set<Source> sources) { | 12361 List<Source> _toArray(Set<Source> sources) { |
| 12365 int size = sources.length; | 12362 int size = sources.length; |
| 12366 if (size == 0) { | 12363 if (size == 0) { |
| 12367 return Source.EMPTY_ARRAY; | 12364 return Source.EMPTY_ARRAY; |
| 12368 } | 12365 } |
| 12369 return new List.from(sources); | 12366 return new List.from(sources); |
| 12370 } | 12367 } |
| 12371 } | 12368 } |
| 12372 | 12369 |
| 12373 /** | 12370 /** |
| 12374 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil
e. | 12371 * Instances of the class `ParseHtmlTask` parse a specific source as an HTML fil
e. |
| 12375 */ | 12372 */ |
| 12376 class ParseHtmlTask extends AnalysisTask { | 12373 class ParseHtmlTask extends AnalysisTask { |
| 12377 /** | 12374 /** |
| 12378 * The source to be parsed. | 12375 * The source to be parsed. |
| 12379 */ | 12376 */ |
| 12380 Source source; | 12377 final Source source; |
| 12381 | 12378 |
| 12382 /** | 12379 /** |
| 12383 * The time at which the contents of the source were last modified. | 12380 * The time at which the contents of the source were last modified. |
| 12384 */ | 12381 */ |
| 12385 int modificationTime = 0; | 12382 final int modificationTime; |
| 12386 | 12383 |
| 12387 /** | 12384 /** |
| 12388 * The contents of the source. | 12385 * The contents of the source. |
| 12389 */ | 12386 */ |
| 12390 String _content; | 12387 final String _content; |
| 12391 | 12388 |
| 12392 /** | 12389 /** |
| 12393 * The line information that was produced. | 12390 * The line information that was produced. |
| 12394 */ | 12391 */ |
| 12395 LineInfo _lineInfo; | 12392 LineInfo _lineInfo; |
| 12396 | 12393 |
| 12397 /** | 12394 /** |
| 12398 * The HTML unit that was produced by parsing the source. | 12395 * The HTML unit that was produced by parsing the source. |
| 12399 */ | 12396 */ |
| 12400 ht.HtmlUnit _unit; | 12397 ht.HtmlUnit _unit; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 12420 static String _TAG_SCRIPT = "script"; | 12417 static String _TAG_SCRIPT = "script"; |
| 12421 | 12418 |
| 12422 /** | 12419 /** |
| 12423 * Initialize a newly created task to perform analysis within the given contex
t. | 12420 * Initialize a newly created task to perform analysis within the given contex
t. |
| 12424 * | 12421 * |
| 12425 * @param context the context in which the task is to be performed | 12422 * @param context the context in which the task is to be performed |
| 12426 * @param source the source to be parsed | 12423 * @param source the source to be parsed |
| 12427 * @param modificationTime the time at which the contents of the source were l
ast modified | 12424 * @param modificationTime the time at which the contents of the source were l
ast modified |
| 12428 * @param content the contents of the source | 12425 * @param content the contents of the source |
| 12429 */ | 12426 */ |
| 12430 ParseHtmlTask(InternalAnalysisContext context, Source source, int modification
Time, String content) : super(context) { | 12427 ParseHtmlTask(InternalAnalysisContext context, this.source, this.modificationT
ime, this._content) : super(context); |
| 12431 this.source = source; | |
| 12432 this.modificationTime = modificationTime; | |
| 12433 this._content = content; | |
| 12434 } | |
| 12435 | 12428 |
| 12436 @override | 12429 @override |
| 12437 accept(AnalysisTaskVisitor visitor) => visitor.visitParseHtmlTask(this); | 12430 accept(AnalysisTaskVisitor visitor) => visitor.visitParseHtmlTask(this); |
| 12438 | 12431 |
| 12439 /** | 12432 /** |
| 12440 * Return the errors that were produced by scanning and parsing the source, or
`null` if the | 12433 * Return the errors that were produced by scanning and parsing the source, or
`null` if the |
| 12441 * task has not yet been performed or if an exception occurred. | 12434 * task has not yet been performed or if an exception occurred. |
| 12442 * | 12435 * |
| 12443 * @return the errors that were produced by scanning and parsing the source | 12436 * @return the errors that were produced by scanning and parsing the source |
| 12444 */ | 12437 */ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12476 | 12469 |
| 12477 @override | 12470 @override |
| 12478 void internalPerform() { | 12471 void internalPerform() { |
| 12479 try { | 12472 try { |
| 12480 ht.AbstractScanner scanner = new ht.StringScanner(source, _content); | 12473 ht.AbstractScanner scanner = new ht.StringScanner(source, _content); |
| 12481 scanner.passThroughElements = <String> [_TAG_SCRIPT]; | 12474 scanner.passThroughElements = <String> [_TAG_SCRIPT]; |
| 12482 ht.Token token = scanner.tokenize(); | 12475 ht.Token token = scanner.tokenize(); |
| 12483 _lineInfo = new LineInfo(scanner.lineStarts); | 12476 _lineInfo = new LineInfo(scanner.lineStarts); |
| 12484 RecordingErrorListener errorListener = new RecordingErrorListener(); | 12477 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 12485 _unit = new ht.HtmlParser(source, errorListener).parse(token, _lineInfo); | 12478 _unit = new ht.HtmlParser(source, errorListener).parse(token, _lineInfo); |
| 12479 _unit.accept(new RecursiveXmlVisitor_ParseHtmlTask_internalPerform(this, e
rrorListener)); |
| 12486 _errors = errorListener.getErrorsForSource(source); | 12480 _errors = errorListener.getErrorsForSource(source); |
| 12487 _referencedLibraries = librarySources; | 12481 _referencedLibraries = librarySources; |
| 12488 } on JavaException catch (exception) { | 12482 } on JavaException catch (exception) { |
| 12489 throw new AnalysisException.con3(exception); | 12483 throw new AnalysisException.con3(exception); |
| 12490 } | 12484 } |
| 12491 } | 12485 } |
| 12492 | 12486 |
| 12493 /** | 12487 /** |
| 12494 * Return the sources of libraries that are referenced in the specified HTML f
ile. | 12488 * Return the sources of libraries that are referenced in the specified HTML f
ile. |
| 12495 * | 12489 * |
| 12496 * @return the sources of libraries that are referenced in the HTML file | 12490 * @return the sources of libraries that are referenced in the HTML file |
| 12497 */ | 12491 */ |
| 12498 List<Source> get librarySources { | 12492 List<Source> get librarySources { |
| 12499 List<Source> libraries = new List<Source>(); | 12493 List<Source> libraries = new List<Source>(); |
| 12500 _unit.accept(new RecursiveXmlVisitor_ParseHtmlTask_getLibrarySources(this, l
ibraries)); | 12494 _unit.accept(new RecursiveXmlVisitor_ParseHtmlTask_getLibrarySources(this, l
ibraries)); |
| 12501 if (libraries.isEmpty) { | 12495 if (libraries.isEmpty) { |
| 12502 return Source.EMPTY_ARRAY; | 12496 return Source.EMPTY_ARRAY; |
| 12503 } | 12497 } |
| 12504 return new List.from(libraries); | 12498 return new List.from(libraries); |
| 12505 } | 12499 } |
| 12500 |
| 12501 /** |
| 12502 * Resolves directives in the given [CompilationUnit]. |
| 12503 */ |
| 12504 void _resolveScriptDirectives(CompilationUnit script, AnalysisErrorListener er
rorListener) { |
| 12505 if (script == null) { |
| 12506 return; |
| 12507 } |
| 12508 AnalysisContext analysisContext = context; |
| 12509 for (Directive directive in script.directives) { |
| 12510 if (directive is ExportDirective) { |
| 12511 ParseDartTask.resolveSource(analysisContext, source, directive, errorLis
tener); |
| 12512 } else if (directive is ImportDirective) { |
| 12513 ParseDartTask.resolveSource(analysisContext, source, directive, errorLis
tener); |
| 12514 } else if (directive is PartDirective) { |
| 12515 ParseDartTask.resolveSource(analysisContext, source, directive, errorLis
tener); |
| 12516 } |
| 12517 } |
| 12518 } |
| 12519 } |
| 12520 |
| 12521 class RecursiveXmlVisitor_ParseHtmlTask_internalPerform extends ht.RecursiveXmlV
isitor<Object> { |
| 12522 final ParseHtmlTask ParseHtmlTask_this; |
| 12523 |
| 12524 RecordingErrorListener errorListener; |
| 12525 |
| 12526 RecursiveXmlVisitor_ParseHtmlTask_internalPerform(this.ParseHtmlTask_this, thi
s.errorListener) : super(); |
| 12527 |
| 12528 @override |
| 12529 Object visitHtmlScriptTagNode(ht.HtmlScriptTagNode node) { |
| 12530 ParseHtmlTask_this._resolveScriptDirectives(node.script, errorListener); |
| 12531 return null; |
| 12532 } |
| 12506 } | 12533 } |
| 12507 | 12534 |
| 12508 class RecursiveXmlVisitor_ParseHtmlTask_getLibrarySources extends ht.RecursiveXm
lVisitor<Object> { | 12535 class RecursiveXmlVisitor_ParseHtmlTask_getLibrarySources extends ht.RecursiveXm
lVisitor<Object> { |
| 12509 final ParseHtmlTask ParseHtmlTask_this; | 12536 final ParseHtmlTask ParseHtmlTask_this; |
| 12510 | 12537 |
| 12511 List<Source> libraries; | 12538 List<Source> libraries; |
| 12512 | 12539 |
| 12513 RecursiveXmlVisitor_ParseHtmlTask_getLibrarySources(this.ParseHtmlTask_this, t
his.libraries) : super(); | 12540 RecursiveXmlVisitor_ParseHtmlTask_getLibrarySources(this.ParseHtmlTask_this, t
his.libraries) : super(); |
| 12514 | 12541 |
| 12515 @override | 12542 @override |
| (...skipping 20 matching lines...) Expand all Loading... |
| 12536 } | 12563 } |
| 12537 | 12564 |
| 12538 /** | 12565 /** |
| 12539 * Instances of the class `ResolveAngularComponentTemplateTask` resolve HTML tem
plate | 12566 * Instances of the class `ResolveAngularComponentTemplateTask` resolve HTML tem
plate |
| 12540 * referenced by [AngularComponentElement]. | 12567 * referenced by [AngularComponentElement]. |
| 12541 */ | 12568 */ |
| 12542 class ResolveAngularComponentTemplateTask extends AnalysisTask { | 12569 class ResolveAngularComponentTemplateTask extends AnalysisTask { |
| 12543 /** | 12570 /** |
| 12544 * The source to be resolved. | 12571 * The source to be resolved. |
| 12545 */ | 12572 */ |
| 12546 Source source; | 12573 final Source source; |
| 12547 | 12574 |
| 12548 /** | 12575 /** |
| 12549 * The time at which the contents of the source were last modified. | 12576 * The time at which the contents of the source were last modified. |
| 12550 */ | 12577 */ |
| 12551 int modificationTime = 0; | 12578 final int modificationTime; |
| 12552 | 12579 |
| 12553 /** | 12580 /** |
| 12554 * The HTML unit to be resolved. | 12581 * The HTML unit to be resolved. |
| 12555 */ | 12582 */ |
| 12556 ht.HtmlUnit _unit; | 12583 final ht.HtmlUnit _unit; |
| 12557 | 12584 |
| 12558 /** | 12585 /** |
| 12559 * The [AngularComponentElement] to resolve template for. | 12586 * The [AngularComponentElement] to resolve template for. |
| 12560 */ | 12587 */ |
| 12561 AngularComponentElement _component; | 12588 final AngularComponentElement _component; |
| 12562 | 12589 |
| 12563 /** | 12590 /** |
| 12564 * The Angular application to resolve in context of. | 12591 * The Angular application to resolve in context of. |
| 12565 */ | 12592 */ |
| 12566 AngularApplication _application; | 12593 final AngularApplication _application; |
| 12567 | 12594 |
| 12568 /** | 12595 /** |
| 12569 * The [HtmlUnit] that was resolved by this task. | 12596 * The [HtmlUnit] that was resolved by this task. |
| 12570 */ | 12597 */ |
| 12571 ht.HtmlUnit _resolvedUnit; | 12598 ht.HtmlUnit _resolvedUnit; |
| 12572 | 12599 |
| 12573 /** | 12600 /** |
| 12574 * The resolution errors that were discovered while resolving the source. | 12601 * The resolution errors that were discovered while resolving the source. |
| 12575 */ | 12602 */ |
| 12576 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 12603 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 12577 | 12604 |
| 12578 /** | 12605 /** |
| 12579 * Initialize a newly created task to perform analysis within the given contex
t. | 12606 * Initialize a newly created task to perform analysis within the given contex
t. |
| 12580 * | 12607 * |
| 12581 * @param context the context in which the task is to be performed | 12608 * @param context the context in which the task is to be performed |
| 12582 * @param source the source to be resolved | 12609 * @param source the source to be resolved |
| 12583 * @param modificationTime the time at which the contents of the source were l
ast modified | 12610 * @param modificationTime the time at which the contents of the source were l
ast modified |
| 12584 * @param unit the HTML unit to be resolved | 12611 * @param unit the HTML unit to be resolved |
| 12585 * @param component the component that uses this HTML template, not `null` | 12612 * @param component the component that uses this HTML template, not `null` |
| 12586 * @param application the Angular application to resolve in context of | 12613 * @param application the Angular application to resolve in context of |
| 12587 */ | 12614 */ |
| 12588 ResolveAngularComponentTemplateTask(InternalAnalysisContext context, Source so
urce, int modificationTime, ht.HtmlUnit unit, AngularComponentElement component,
AngularApplication application) : super(context) { | 12615 ResolveAngularComponentTemplateTask(InternalAnalysisContext context, this.sour
ce, this.modificationTime, this._unit, this._component, this._application) : sup
er(context); |
| 12589 this.source = source; | |
| 12590 this.modificationTime = modificationTime; | |
| 12591 this._unit = unit; | |
| 12592 this._component = component; | |
| 12593 this._application = application; | |
| 12594 } | |
| 12595 | 12616 |
| 12596 @override | 12617 @override |
| 12597 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularComponentTem
plateTask(this); | 12618 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularComponentTem
plateTask(this); |
| 12598 | 12619 |
| 12599 List<AnalysisError> get resolutionErrors => _resolutionErrors; | 12620 List<AnalysisError> get resolutionErrors => _resolutionErrors; |
| 12600 | 12621 |
| 12601 /** | 12622 /** |
| 12602 * Return the [HtmlUnit] that was resolved by this task. | 12623 * Return the [HtmlUnit] that was resolved by this task. |
| 12603 * | 12624 * |
| 12604 * @return the [HtmlUnit] that was resolved by this task | 12625 * @return the [HtmlUnit] that was resolved by this task |
| (...skipping 26 matching lines...) Expand all Loading... |
| 12631 } | 12652 } |
| 12632 | 12653 |
| 12633 /** | 12654 /** |
| 12634 * Instances of the class `ResolveAngularEntryHtmlTask` resolve a specific HTML
file as an | 12655 * Instances of the class `ResolveAngularEntryHtmlTask` resolve a specific HTML
file as an |
| 12635 * Angular entry point. | 12656 * Angular entry point. |
| 12636 */ | 12657 */ |
| 12637 class ResolveAngularEntryHtmlTask extends AnalysisTask { | 12658 class ResolveAngularEntryHtmlTask extends AnalysisTask { |
| 12638 /** | 12659 /** |
| 12639 * The source to be resolved. | 12660 * The source to be resolved. |
| 12640 */ | 12661 */ |
| 12641 Source source; | 12662 final Source source; |
| 12642 | 12663 |
| 12643 /** | 12664 /** |
| 12644 * The time at which the contents of the source were last modified. | 12665 * The time at which the contents of the source were last modified. |
| 12645 */ | 12666 */ |
| 12646 int modificationTime = 0; | 12667 final int modificationTime; |
| 12647 | 12668 |
| 12648 /** | 12669 /** |
| 12649 * The HTML unit to be resolved. | 12670 * The HTML unit to be resolved. |
| 12650 */ | 12671 */ |
| 12651 ht.HtmlUnit _unit; | 12672 final ht.HtmlUnit _unit; |
| 12652 | 12673 |
| 12653 /** | 12674 /** |
| 12654 * The listener to record errors. | 12675 * The listener to record errors. |
| 12655 */ | 12676 */ |
| 12656 RecordingErrorListener _errorListener = new RecordingErrorListener(); | 12677 RecordingErrorListener _errorListener = new RecordingErrorListener(); |
| 12657 | 12678 |
| 12658 /** | 12679 /** |
| 12659 * The [HtmlUnit] that was resolved by this task. | 12680 * The [HtmlUnit] that was resolved by this task. |
| 12660 */ | 12681 */ |
| 12661 ht.HtmlUnit _resolvedUnit; | 12682 ht.HtmlUnit _resolvedUnit; |
| 12662 | 12683 |
| 12663 /** | 12684 /** |
| 12664 * The element produced by resolving the source. | 12685 * The element produced by resolving the source. |
| 12665 */ | 12686 */ |
| 12666 HtmlElement _element = null; | 12687 HtmlElement _element = null; |
| 12667 | 12688 |
| 12668 /** | 12689 /** |
| 12669 * The Angular application to resolve in context of. | 12690 * The Angular application to resolve in context of. |
| 12670 */ | 12691 */ |
| 12671 AngularApplication _application; | 12692 AngularApplication _application; |
| 12672 | 12693 |
| 12673 /** | 12694 /** |
| 12674 * Initialize a newly created task to perform analysis within the given contex
t. | 12695 * Initialize a newly created task to perform analysis within the given contex
t. |
| 12675 * | 12696 * |
| 12676 * @param context the context in which the task is to be performed | 12697 * @param context the context in which the task is to be performed |
| 12677 * @param source the source to be resolved | 12698 * @param source the source to be resolved |
| 12678 * @param modificationTime the time at which the contents of the source were l
ast modified | 12699 * @param modificationTime the time at which the contents of the source were l
ast modified |
| 12679 * @param unit the HTML unit to be resolved | 12700 * @param unit the HTML unit to be resolved |
| 12680 */ | 12701 */ |
| 12681 ResolveAngularEntryHtmlTask(InternalAnalysisContext context, Source source, in
t modificationTime, ht.HtmlUnit unit) : super(context) { | 12702 ResolveAngularEntryHtmlTask(InternalAnalysisContext context, this.source, this
.modificationTime, this._unit) : super(context); |
| 12682 this.source = source; | |
| 12683 this.modificationTime = modificationTime; | |
| 12684 this._unit = unit; | |
| 12685 } | |
| 12686 | 12703 |
| 12687 @override | 12704 @override |
| 12688 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularEntryHtmlTas
k(this); | 12705 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularEntryHtmlTas
k(this); |
| 12689 | 12706 |
| 12690 /** | 12707 /** |
| 12691 * Returns the [AngularApplication] for the Web application with this Angular
entry point, | 12708 * Returns the [AngularApplication] for the Web application with this Angular
entry point, |
| 12692 * maybe `null` if not an Angular entry point. | 12709 * maybe `null` if not an Angular entry point. |
| 12693 */ | 12710 */ |
| 12694 AngularApplication get application => _application; | 12711 AngularApplication get application => _application; |
| 12695 | 12712 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12744 } | 12761 } |
| 12745 | 12762 |
| 12746 /** | 12763 /** |
| 12747 * Instances of the class `ResolveDartLibraryTask` resolve a specific Dart libra
ry. | 12764 * Instances of the class `ResolveDartLibraryTask` resolve a specific Dart libra
ry. |
| 12748 */ | 12765 */ |
| 12749 class ResolveDartLibraryCycleTask extends AnalysisTask { | 12766 class ResolveDartLibraryCycleTask extends AnalysisTask { |
| 12750 /** | 12767 /** |
| 12751 * The source representing the file whose compilation unit is to be returned.
TODO(brianwilkerson) | 12768 * The source representing the file whose compilation unit is to be returned.
TODO(brianwilkerson) |
| 12752 * This should probably be removed, but is being left in for now to ease the t
ransition. | 12769 * This should probably be removed, but is being left in for now to ease the t
ransition. |
| 12753 */ | 12770 */ |
| 12754 Source unitSource; | 12771 final Source unitSource; |
| 12755 | 12772 |
| 12756 /** | 12773 /** |
| 12757 * The source representing the library to be resolved. | 12774 * The source representing the library to be resolved. |
| 12758 */ | 12775 */ |
| 12759 Source librarySource; | 12776 final Source librarySource; |
| 12760 | 12777 |
| 12761 /** | 12778 /** |
| 12762 * The libraries that are part of the cycle containing the library to be resol
ved. | 12779 * The libraries that are part of the cycle containing the library to be resol
ved. |
| 12763 */ | 12780 */ |
| 12764 List<ResolvableLibrary> _librariesInCycle; | 12781 final List<ResolvableLibrary> _librariesInCycle; |
| 12765 | 12782 |
| 12766 /** | 12783 /** |
| 12767 * The library resolver holding information about the libraries that were reso
lved. | 12784 * The library resolver holding information about the libraries that were reso
lved. |
| 12768 */ | 12785 */ |
| 12769 LibraryResolver2 _resolver; | 12786 LibraryResolver2 _resolver; |
| 12770 | 12787 |
| 12771 /** | 12788 /** |
| 12772 * Initialize a newly created task to perform analysis within the given contex
t. | 12789 * Initialize a newly created task to perform analysis within the given contex
t. |
| 12773 * | 12790 * |
| 12774 * @param context the context in which the task is to be performed | 12791 * @param context the context in which the task is to be performed |
| 12775 * @param unitSource the source representing the file whose compilation unit i
s to be returned | 12792 * @param unitSource the source representing the file whose compilation unit i
s to be returned |
| 12776 * @param librarySource the source representing the library to be resolved | 12793 * @param librarySource the source representing the library to be resolved |
| 12777 * @param librariesInCycle the libraries that are part of the cycle containing
the library to be | 12794 * @param librariesInCycle the libraries that are part of the cycle containing
the library to be |
| 12778 * resolved | 12795 * resolved |
| 12779 */ | 12796 */ |
| 12780 ResolveDartLibraryCycleTask(InternalAnalysisContext context, Source unitSource
, Source librarySource, List<ResolvableLibrary> librariesInCycle) : super(contex
t) { | 12797 ResolveDartLibraryCycleTask(InternalAnalysisContext context, this.unitSource,
this.librarySource, this._librariesInCycle) : super(context); |
| 12781 this.unitSource = unitSource; | |
| 12782 this.librarySource = librarySource; | |
| 12783 this._librariesInCycle = librariesInCycle; | |
| 12784 } | |
| 12785 | 12798 |
| 12786 @override | 12799 @override |
| 12787 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartLibraryCycleTas
k(this); | 12800 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartLibraryCycleTas
k(this); |
| 12788 | 12801 |
| 12789 /** | 12802 /** |
| 12790 * Return the library resolver holding information about the libraries that we
re resolved. | 12803 * Return the library resolver holding information about the libraries that we
re resolved. |
| 12791 * | 12804 * |
| 12792 * @return the library resolver holding information about the libraries that w
ere resolved | 12805 * @return the library resolver holding information about the libraries that w
ere resolved |
| 12793 */ | 12806 */ |
| 12794 LibraryResolver2 get libraryResolver => _resolver; | 12807 LibraryResolver2 get libraryResolver => _resolver; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 12808 } | 12821 } |
| 12809 } | 12822 } |
| 12810 | 12823 |
| 12811 /** | 12824 /** |
| 12812 * Instances of the class `ResolveDartLibraryTask` resolve a specific Dart libra
ry. | 12825 * Instances of the class `ResolveDartLibraryTask` resolve a specific Dart libra
ry. |
| 12813 */ | 12826 */ |
| 12814 class ResolveDartLibraryTask extends AnalysisTask { | 12827 class ResolveDartLibraryTask extends AnalysisTask { |
| 12815 /** | 12828 /** |
| 12816 * The source representing the file whose compilation unit is to be returned. | 12829 * The source representing the file whose compilation unit is to be returned. |
| 12817 */ | 12830 */ |
| 12818 Source unitSource; | 12831 final Source unitSource; |
| 12819 | 12832 |
| 12820 /** | 12833 /** |
| 12821 * The source representing the library to be resolved. | 12834 * The source representing the library to be resolved. |
| 12822 */ | 12835 */ |
| 12823 Source librarySource; | 12836 final Source librarySource; |
| 12824 | 12837 |
| 12825 /** | 12838 /** |
| 12826 * The library resolver holding information about the libraries that were reso
lved. | 12839 * The library resolver holding information about the libraries that were reso
lved. |
| 12827 */ | 12840 */ |
| 12828 LibraryResolver _resolver; | 12841 LibraryResolver _resolver; |
| 12829 | 12842 |
| 12830 /** | 12843 /** |
| 12831 * Initialize a newly created task to perform analysis within the given contex
t. | 12844 * Initialize a newly created task to perform analysis within the given contex
t. |
| 12832 * | 12845 * |
| 12833 * @param context the context in which the task is to be performed | 12846 * @param context the context in which the task is to be performed |
| 12834 * @param unitSource the source representing the file whose compilation unit i
s to be returned | 12847 * @param unitSource the source representing the file whose compilation unit i
s to be returned |
| 12835 * @param librarySource the source representing the library to be resolved | 12848 * @param librarySource the source representing the library to be resolved |
| 12836 */ | 12849 */ |
| 12837 ResolveDartLibraryTask(InternalAnalysisContext context, Source unitSource, Sou
rce librarySource) : super(context) { | 12850 ResolveDartLibraryTask(InternalAnalysisContext context, this.unitSource, this.
librarySource) : super(context); |
| 12838 this.unitSource = unitSource; | |
| 12839 this.librarySource = librarySource; | |
| 12840 } | |
| 12841 | 12851 |
| 12842 @override | 12852 @override |
| 12843 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartLibraryTask(thi
s); | 12853 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartLibraryTask(thi
s); |
| 12844 | 12854 |
| 12845 /** | 12855 /** |
| 12846 * Return the library resolver holding information about the libraries that we
re resolved. | 12856 * Return the library resolver holding information about the libraries that we
re resolved. |
| 12847 * | 12857 * |
| 12848 * @return the library resolver holding information about the libraries that w
ere resolved | 12858 * @return the library resolver holding information about the libraries that w
ere resolved |
| 12849 */ | 12859 */ |
| 12850 LibraryResolver get libraryResolver => _resolver; | 12860 LibraryResolver get libraryResolver => _resolver; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 12865 } | 12875 } |
| 12866 | 12876 |
| 12867 /** | 12877 /** |
| 12868 * Instances of the class `ResolveDartUnitTask` resolve a single Dart file based
on a existing | 12878 * Instances of the class `ResolveDartUnitTask` resolve a single Dart file based
on a existing |
| 12869 * element model. | 12879 * element model. |
| 12870 */ | 12880 */ |
| 12871 class ResolveDartUnitTask extends AnalysisTask { | 12881 class ResolveDartUnitTask extends AnalysisTask { |
| 12872 /** | 12882 /** |
| 12873 * The source that is to be resolved. | 12883 * The source that is to be resolved. |
| 12874 */ | 12884 */ |
| 12875 Source source; | 12885 final Source source; |
| 12876 | 12886 |
| 12877 /** | 12887 /** |
| 12878 * The element model for the library containing the source. | 12888 * The element model for the library containing the source. |
| 12879 */ | 12889 */ |
| 12880 LibraryElement _libraryElement; | 12890 final LibraryElement _libraryElement; |
| 12881 | 12891 |
| 12882 /** | 12892 /** |
| 12883 * The time at which the contents of the source were last modified. | 12893 * The time at which the contents of the source were last modified. |
| 12884 */ | 12894 */ |
| 12885 int _modificationTime = -1; | 12895 int _modificationTime = -1; |
| 12886 | 12896 |
| 12887 /** | 12897 /** |
| 12888 * The compilation unit that was resolved by this task. | 12898 * The compilation unit that was resolved by this task. |
| 12889 */ | 12899 */ |
| 12890 CompilationUnit _resolvedUnit; | 12900 CompilationUnit _resolvedUnit; |
| 12891 | 12901 |
| 12892 /** | 12902 /** |
| 12893 * Initialize a newly created task to perform analysis within the given contex
t. | 12903 * Initialize a newly created task to perform analysis within the given contex
t. |
| 12894 * | 12904 * |
| 12895 * @param context the context in which the task is to be performed | 12905 * @param context the context in which the task is to be performed |
| 12896 * @param source the source to be parsed | 12906 * @param source the source to be parsed |
| 12897 * @param libraryElement the element model for the library containing the sour
ce | 12907 * @param libraryElement the element model for the library containing the sour
ce |
| 12898 */ | 12908 */ |
| 12899 ResolveDartUnitTask(InternalAnalysisContext context, Source source, LibraryEle
ment libraryElement) : super(context) { | 12909 ResolveDartUnitTask(InternalAnalysisContext context, this.source, this._librar
yElement) : super(context); |
| 12900 this.source = source; | |
| 12901 this._libraryElement = libraryElement; | |
| 12902 } | |
| 12903 | 12910 |
| 12904 @override | 12911 @override |
| 12905 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this); | 12912 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this); |
| 12906 | 12913 |
| 12907 /** | 12914 /** |
| 12908 * Return the source for the library containing the source that is to be resol
ved. | 12915 * Return the source for the library containing the source that is to be resol
ved. |
| 12909 * | 12916 * |
| 12910 * @return the source for the library containing the source that is to be reso
lved | 12917 * @return the source for the library containing the source that is to be reso
lved |
| 12911 */ | 12918 */ |
| 12912 Source get librarySource => _libraryElement.source; | 12919 Source get librarySource => _libraryElement.source; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13008 } | 13015 } |
| 13009 } | 13016 } |
| 13010 | 13017 |
| 13011 /** | 13018 /** |
| 13012 * Instances of the class `ResolveHtmlTask` resolve a specific source as an HTML
file. | 13019 * Instances of the class `ResolveHtmlTask` resolve a specific source as an HTML
file. |
| 13013 */ | 13020 */ |
| 13014 class ResolveHtmlTask extends AnalysisTask { | 13021 class ResolveHtmlTask extends AnalysisTask { |
| 13015 /** | 13022 /** |
| 13016 * The source to be resolved. | 13023 * The source to be resolved. |
| 13017 */ | 13024 */ |
| 13018 Source source; | 13025 final Source source; |
| 13019 | 13026 |
| 13020 /** | 13027 /** |
| 13021 * The time at which the contents of the source were last modified. | 13028 * The time at which the contents of the source were last modified. |
| 13022 */ | 13029 */ |
| 13023 int modificationTime = 0; | 13030 final int modificationTime; |
| 13024 | 13031 |
| 13025 /** | 13032 /** |
| 13026 * The HTML unit to be resolved. | 13033 * The HTML unit to be resolved. |
| 13027 */ | 13034 */ |
| 13028 ht.HtmlUnit _unit; | 13035 final ht.HtmlUnit _unit; |
| 13029 | 13036 |
| 13030 /** | 13037 /** |
| 13031 * The [HtmlUnit] that was resolved by this task. | 13038 * The [HtmlUnit] that was resolved by this task. |
| 13032 */ | 13039 */ |
| 13033 ht.HtmlUnit _resolvedUnit; | 13040 ht.HtmlUnit _resolvedUnit; |
| 13034 | 13041 |
| 13035 /** | 13042 /** |
| 13036 * The element produced by resolving the source. | 13043 * The element produced by resolving the source. |
| 13037 */ | 13044 */ |
| 13038 HtmlElement _element = null; | 13045 HtmlElement _element = null; |
| 13039 | 13046 |
| 13040 /** | 13047 /** |
| 13041 * The resolution errors that were discovered while resolving the source. | 13048 * The resolution errors that were discovered while resolving the source. |
| 13042 */ | 13049 */ |
| 13043 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 13050 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 13044 | 13051 |
| 13045 /** | 13052 /** |
| 13046 * Initialize a newly created task to perform analysis within the given contex
t. | 13053 * Initialize a newly created task to perform analysis within the given contex
t. |
| 13047 * | 13054 * |
| 13048 * @param context the context in which the task is to be performed | 13055 * @param context the context in which the task is to be performed |
| 13049 * @param source the source to be resolved | 13056 * @param source the source to be resolved |
| 13050 * @param modificationTime the time at which the contents of the source were l
ast modified | 13057 * @param modificationTime the time at which the contents of the source were l
ast modified |
| 13051 * @param unit the HTML unit to be resolved | 13058 * @param unit the HTML unit to be resolved |
| 13052 */ | 13059 */ |
| 13053 ResolveHtmlTask(InternalAnalysisContext context, Source source, int modificati
onTime, ht.HtmlUnit unit) : super(context) { | 13060 ResolveHtmlTask(InternalAnalysisContext context, this.source, this.modificatio
nTime, this._unit) : super(context); |
| 13054 this.source = source; | |
| 13055 this.modificationTime = modificationTime; | |
| 13056 this._unit = unit; | |
| 13057 } | |
| 13058 | 13061 |
| 13059 @override | 13062 @override |
| 13060 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this); | 13063 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this); |
| 13061 | 13064 |
| 13062 HtmlElement get element => _element; | 13065 HtmlElement get element => _element; |
| 13063 | 13066 |
| 13064 List<AnalysisError> get resolutionErrors => _resolutionErrors; | 13067 List<AnalysisError> get resolutionErrors => _resolutionErrors; |
| 13065 | 13068 |
| 13066 /** | 13069 /** |
| 13067 * Return the [HtmlUnit] that was resolved by this task. | 13070 * Return the [HtmlUnit] that was resolved by this task. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 13097 } | 13100 } |
| 13098 } | 13101 } |
| 13099 | 13102 |
| 13100 /** | 13103 /** |
| 13101 * Instances of the class `ScanDartTask` scan a specific source as a Dart file. | 13104 * Instances of the class `ScanDartTask` scan a specific source as a Dart file. |
| 13102 */ | 13105 */ |
| 13103 class ScanDartTask extends AnalysisTask { | 13106 class ScanDartTask extends AnalysisTask { |
| 13104 /** | 13107 /** |
| 13105 * The source to be scanned. | 13108 * The source to be scanned. |
| 13106 */ | 13109 */ |
| 13107 Source source; | 13110 final Source source; |
| 13108 | 13111 |
| 13109 /** | 13112 /** |
| 13110 * The time at which the contents of the source were last modified. | 13113 * The time at which the contents of the source were last modified. |
| 13111 */ | 13114 */ |
| 13112 int modificationTime = 0; | 13115 final int modificationTime; |
| 13113 | 13116 |
| 13114 /** | 13117 /** |
| 13115 * The contents of the source. | 13118 * The contents of the source. |
| 13116 */ | 13119 */ |
| 13117 String _content; | 13120 final String _content; |
| 13118 | 13121 |
| 13119 /** | 13122 /** |
| 13120 * The token stream that was produced by scanning the source. | 13123 * The token stream that was produced by scanning the source. |
| 13121 */ | 13124 */ |
| 13122 Token _tokenStream; | 13125 Token _tokenStream; |
| 13123 | 13126 |
| 13124 /** | 13127 /** |
| 13125 * The line information that was produced. | 13128 * The line information that was produced. |
| 13126 */ | 13129 */ |
| 13127 LineInfo _lineInfo; | 13130 LineInfo _lineInfo; |
| 13128 | 13131 |
| 13129 /** | 13132 /** |
| 13130 * The errors that were produced by scanning the source. | 13133 * The errors that were produced by scanning the source. |
| 13131 */ | 13134 */ |
| 13132 List<AnalysisError> _errors = AnalysisError.NO_ERRORS; | 13135 List<AnalysisError> _errors = AnalysisError.NO_ERRORS; |
| 13133 | 13136 |
| 13134 /** | 13137 /** |
| 13135 * Initialize a newly created task to perform analysis within the given contex
t. | 13138 * Initialize a newly created task to perform analysis within the given contex
t. |
| 13136 * | 13139 * |
| 13137 * @param context the context in which the task is to be performed | 13140 * @param context the context in which the task is to be performed |
| 13138 * @param source the source to be parsed | 13141 * @param source the source to be parsed |
| 13139 * @param modificationTime the time at which the contents of the source were l
ast modified | 13142 * @param modificationTime the time at which the contents of the source were l
ast modified |
| 13140 * @param content the contents of the source | 13143 * @param content the contents of the source |
| 13141 */ | 13144 */ |
| 13142 ScanDartTask(InternalAnalysisContext context, Source source, int modificationT
ime, String content) : super(context) { | 13145 ScanDartTask(InternalAnalysisContext context, this.source, this.modificationTi
me, this._content) : super(context); |
| 13143 this.source = source; | |
| 13144 this.modificationTime = modificationTime; | |
| 13145 this._content = content; | |
| 13146 } | |
| 13147 | 13146 |
| 13148 @override | 13147 @override |
| 13149 accept(AnalysisTaskVisitor visitor) => visitor.visitScanDartTask(this); | 13148 accept(AnalysisTaskVisitor visitor) => visitor.visitScanDartTask(this); |
| 13150 | 13149 |
| 13151 /** | 13150 /** |
| 13152 * Return the errors that were produced by scanning the source, or `null` if t
he task has | 13151 * Return the errors that were produced by scanning the source, or `null` if t
he task has |
| 13153 * not yet been performed or if an exception occurred. | 13152 * not yet been performed or if an exception occurred. |
| 13154 * | 13153 * |
| 13155 * @return the errors that were produced by scanning the source | 13154 * @return the errors that were produced by scanning the source |
| 13156 */ | 13155 */ |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13286 } | 13285 } |
| 13287 | 13286 |
| 13288 @override | 13287 @override |
| 13289 void logInformation(String message) { | 13288 void logInformation(String message) { |
| 13290 } | 13289 } |
| 13291 | 13290 |
| 13292 @override | 13291 @override |
| 13293 void logInformation2(String message, Exception exception) { | 13292 void logInformation2(String message, Exception exception) { |
| 13294 } | 13293 } |
| 13295 } | 13294 } |
| OLD | NEW |