| 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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 * Return the sources for the defining compilation units of any libraries that
depend on the given | 401 * Return the sources for the defining compilation units of any libraries that
depend on the given |
| 402 * library. One library depends on another if it either imports or exports tha
t library. | 402 * library. One library depends on another if it either imports or exports tha
t library. |
| 403 * | 403 * |
| 404 * @param librarySource the source for the defining compilation unit of the li
brary being depended | 404 * @param librarySource the source for the defining compilation unit of the li
brary being depended |
| 405 * on | 405 * on |
| 406 * @return the sources for the libraries that depend on the given library | 406 * @return the sources for the libraries that depend on the given library |
| 407 */ | 407 */ |
| 408 List<Source> getLibrariesDependingOn(Source librarySource); | 408 List<Source> getLibrariesDependingOn(Source librarySource); |
| 409 | 409 |
| 410 /** | 410 /** |
| 411 * Return the [AngularElement]s accessible in the library defined by the given
source, or an | |
| 412 * empty array if given source is not a library, not resolved or cannot be ana
lyzed for some | |
| 413 * reason. | |
| 414 * | |
| 415 * @param source the source defining the library whose [AngularElement]s is to
be returned | |
| 416 * @return the [AngularElement]s accessible in the library defined by the give
n source | |
| 417 */ | |
| 418 List<AngularElement> getLibraryAngularElements(Source source); | |
| 419 | |
| 420 /** | |
| 421 * Return the element model corresponding to the library defined by the given
source, or | 411 * Return the element model corresponding to the library defined by the given
source, or |
| 422 * `null` if the element model does not currently exist or if the library cann
ot be analyzed | 412 * `null` if the element model does not currently exist or if the library cann
ot be analyzed |
| 423 * for some reason. | 413 * for some reason. |
| 424 * | 414 * |
| 425 * @param source the source defining the library whose element model is to be
returned | 415 * @param source the source defining the library whose element model is to be
returned |
| 426 * @return the element model corresponding to the library defined by the given
source | 416 * @return the element model corresponding to the library defined by the given
source |
| 427 */ | 417 */ |
| 428 LibraryElement getLibraryElement(Source source); | 418 LibraryElement getLibraryElement(Source source); |
| 429 | 419 |
| 430 /** | 420 /** |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 * @param retentionPolicy the policy used to determine which pieces of data to
remove from the | 998 * @param retentionPolicy the policy used to determine which pieces of data to
remove from the |
| 1009 * cache | 999 * cache |
| 1010 */ | 1000 */ |
| 1011 AnalysisCache(int maxCacheSize, CacheRetentionPolicy retentionPolicy) { | 1001 AnalysisCache(int maxCacheSize, CacheRetentionPolicy retentionPolicy) { |
| 1012 this._maxCacheSize = maxCacheSize; | 1002 this._maxCacheSize = maxCacheSize; |
| 1013 this._retentionPolicy = retentionPolicy; | 1003 this._retentionPolicy = retentionPolicy; |
| 1014 _recentlyUsed = new List<Source>(); | 1004 _recentlyUsed = new List<Source>(); |
| 1015 } | 1005 } |
| 1016 | 1006 |
| 1017 /** | 1007 /** |
| 1018 * Record that the given source was just accessed. | 1008 * Record that the AST associated with the given source was just read from the
cache. |
| 1019 * | 1009 * |
| 1020 * @param source the source that was accessed | 1010 * @param source the source whose AST was accessed |
| 1021 */ | 1011 */ |
| 1022 void accessed(Source source) { | 1012 void accessedAst(Source source) { |
| 1023 if (_recentlyUsed.remove(source)) { | 1013 if (_recentlyUsed.remove(source)) { |
| 1024 _recentlyUsed.add(source); | 1014 _recentlyUsed.add(source); |
| 1025 return; | 1015 return; |
| 1026 } | 1016 } |
| 1027 while (_recentlyUsed.length >= _maxCacheSize) { | 1017 while (_recentlyUsed.length >= _maxCacheSize) { |
| 1028 if (!flushAstFromCache()) { | 1018 if (!flushAstFromCache()) { |
| 1029 break; | 1019 break; |
| 1030 } | 1020 } |
| 1031 } | 1021 } |
| 1032 _recentlyUsed.add(source); | 1022 _recentlyUsed.add(source); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1058 (entry as SourceEntryImpl).fixExceptionState(); | 1048 (entry as SourceEntryImpl).fixExceptionState(); |
| 1059 _sourceMap[source] = entry; | 1049 _sourceMap[source] = entry; |
| 1060 } | 1050 } |
| 1061 | 1051 |
| 1062 /** | 1052 /** |
| 1063 * Remove all information related to the given source from this cache. | 1053 * Remove all information related to the given source from this cache. |
| 1064 * | 1054 * |
| 1065 * @param source the source to be removed | 1055 * @param source the source to be removed |
| 1066 */ | 1056 */ |
| 1067 void remove(Source source) { | 1057 void remove(Source source) { |
| 1058 _recentlyUsed.remove(source); |
| 1068 _sourceMap.remove(source); | 1059 _sourceMap.remove(source); |
| 1069 } | 1060 } |
| 1070 | 1061 |
| 1071 /** | 1062 /** |
| 1063 * Record that the AST associated with the given source was just removed from
the cache. |
| 1064 * |
| 1065 * @param source the source whose AST was removed |
| 1066 */ |
| 1067 void removedAst(Source source) { |
| 1068 _recentlyUsed.remove(source); |
| 1069 } |
| 1070 |
| 1071 /** |
| 1072 * Set the maximum size of the cache to the given size. | 1072 * Set the maximum size of the cache to the given size. |
| 1073 * | 1073 * |
| 1074 * @param size the maximum number of sources for which AST structures should b
e kept in the cache | 1074 * @param size the maximum number of sources for which AST structures should b
e kept in the cache |
| 1075 */ | 1075 */ |
| 1076 void set maxCacheSize(int size) { | 1076 void set maxCacheSize(int size) { |
| 1077 _maxCacheSize = size; | 1077 _maxCacheSize = size; |
| 1078 while (_recentlyUsed.length > _maxCacheSize) { | 1078 while (_recentlyUsed.length > _maxCacheSize) { |
| 1079 if (!flushAstFromCache()) { | 1079 if (!flushAstFromCache()) { |
| 1080 break; | 1080 break; |
| 1081 } | 1081 } |
| 1082 } | 1082 } |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 /** | 1085 /** |
| 1086 * Return the number of sources that are mapped to cache entries. | 1086 * Return the number of sources that are mapped to cache entries. |
| 1087 * | 1087 * |
| 1088 * @return the number of sources that are mapped to cache entries | 1088 * @return the number of sources that are mapped to cache entries |
| 1089 */ | 1089 */ |
| 1090 int size() => _sourceMap.length; | 1090 int size() => _sourceMap.length; |
| 1091 | 1091 |
| 1092 /** | 1092 /** |
| 1093 * Record that the AST associated with the given source was just stored to the
cache. |
| 1094 * |
| 1095 * @param source the source whose AST was stored |
| 1096 */ |
| 1097 void storedAst(Source source) { |
| 1098 if (_recentlyUsed.contains(source)) { |
| 1099 return; |
| 1100 } |
| 1101 while (_recentlyUsed.length >= _maxCacheSize) { |
| 1102 if (!flushAstFromCache()) { |
| 1103 break; |
| 1104 } |
| 1105 } |
| 1106 _recentlyUsed.add(source); |
| 1107 } |
| 1108 |
| 1109 /** |
| 1093 * Attempt to flush one AST structure from the cache. | 1110 * Attempt to flush one AST structure from the cache. |
| 1094 * | 1111 * |
| 1095 * @return `true` if a structure was flushed | 1112 * @return `true` if a structure was flushed |
| 1096 */ | 1113 */ |
| 1097 bool flushAstFromCache() { | 1114 bool flushAstFromCache() { |
| 1098 Source removedSource = removeAstToFlush(); | 1115 Source removedSource = removeAstToFlush(); |
| 1099 if (removedSource == null) { | 1116 if (removedSource == null) { |
| 1100 return false; | 1117 return false; |
| 1101 } | 1118 } |
| 1102 SourceEntry sourceEntry = _sourceMap[removedSource]; | 1119 SourceEntry sourceEntry = _sourceMap[removedSource]; |
| 1103 if (sourceEntry is HtmlEntry) { | 1120 if (sourceEntry is HtmlEntry) { |
| 1104 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 1121 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 1105 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); | 1122 htmlCopy.flushAstStructures(); |
| 1106 _sourceMap[removedSource] = htmlCopy; | 1123 _sourceMap[removedSource] = htmlCopy; |
| 1107 } else if (sourceEntry is DartEntry) { | 1124 } else if (sourceEntry is DartEntry) { |
| 1108 DartEntryImpl dartCopy = sourceEntry.writableCopy; | 1125 DartEntryImpl dartCopy = sourceEntry.writableCopy; |
| 1109 dartCopy.flushAstStructures(); | 1126 dartCopy.flushAstStructures(); |
| 1110 _sourceMap[removedSource] = dartCopy; | 1127 _sourceMap[removedSource] = dartCopy; |
| 1111 } | 1128 } |
| 1112 return true; | 1129 return true; |
| 1113 } | 1130 } |
| 1114 | 1131 |
| 1115 /** | 1132 /** |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1132 } | 1149 } |
| 1133 if (sourceToRemove < 0) { | 1150 if (sourceToRemove < 0) { |
| 1134 AnalysisEngine.instance.logger.logError2("Internal error: Could not flush
data from the cache", new JavaException()); | 1151 AnalysisEngine.instance.logger.logError2("Internal error: Could not flush
data from the cache", new JavaException()); |
| 1135 return null; | 1152 return null; |
| 1136 } | 1153 } |
| 1137 return _recentlyUsed.removeAt(sourceToRemove); | 1154 return _recentlyUsed.removeAt(sourceToRemove); |
| 1138 } | 1155 } |
| 1139 } | 1156 } |
| 1140 | 1157 |
| 1141 /** | 1158 /** |
| 1159 * Information about Angular application. |
| 1160 */ |
| 1161 class AngularApplicationInfo { |
| 1162 final Source entryPoint; |
| 1163 |
| 1164 final List<AngularElement> elements; |
| 1165 |
| 1166 AngularApplicationInfo(this.entryPoint, this.elements); |
| 1167 } |
| 1168 |
| 1169 /** |
| 1142 * Instances of the class `CacheRetentionPolicy` define the behavior of objects
that determine | 1170 * Instances of the class `CacheRetentionPolicy` define the behavior of objects
that determine |
| 1143 * how important it is for data to be retained in the analysis cache. | 1171 * how important it is for data to be retained in the analysis cache. |
| 1144 */ | 1172 */ |
| 1145 abstract class CacheRetentionPolicy { | 1173 abstract class CacheRetentionPolicy { |
| 1146 /** | 1174 /** |
| 1147 * Return the priority of retaining the AST structure for the given source. | 1175 * Return the priority of retaining the AST structure for the given source. |
| 1148 * | 1176 * |
| 1149 * @param source the source whose AST structure is being considered for remova
l | 1177 * @param source the source whose AST structure is being considered for remova
l |
| 1150 * @param sourceEntry the entry representing the source | 1178 * @param sourceEntry the entry representing the source |
| 1151 * @return the priority of retaining the AST structure for the given source | 1179 * @return the priority of retaining the AST structure for the given source |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 } | 1246 } |
| 1219 | 1247 |
| 1220 /** | 1248 /** |
| 1221 * The interface `DartEntry` defines the behavior of objects that maintain the i
nformation | 1249 * The interface `DartEntry` defines the behavior of objects that maintain the i
nformation |
| 1222 * cached by an analysis context about an individual Dart file. | 1250 * cached by an analysis context about an individual Dart file. |
| 1223 * | 1251 * |
| 1224 * @coverage dart.engine | 1252 * @coverage dart.engine |
| 1225 */ | 1253 */ |
| 1226 abstract class DartEntry implements SourceEntry { | 1254 abstract class DartEntry implements SourceEntry { |
| 1227 /** | 1255 /** |
| 1228 * The data descriptor representing the Angular elements accessible in the lib
rary. This data is | 1256 * The data descriptor representing the list of libraries that contain this co
mpilation unit. |
| 1229 * only available for Dart files that are the defining compilation unit of a l
ibrary. | |
| 1230 */ | 1257 */ |
| 1231 static final DataDescriptor<List<AngularElement>> ANGULAR_ELEMENTS = new DataD
escriptor<List<AngularElement>>("DartEntry.ANGULAR_ELEMENTS"); | 1258 static final DataDescriptor<List<Source>> CONTAINING_LIBRARIES = new DataDescr
iptor<List<Source>>("DartEntry.CONTAINING_LIBRARIES"); |
| 1232 | 1259 |
| 1233 /** | 1260 /** |
| 1234 * The data descriptor representing the library element for the library. This
data is only | 1261 * The data descriptor representing the library element for the library. This
data is only |
| 1235 * available for Dart files that are the defining compilation unit of a librar
y. | 1262 * available for Dart files that are the defining compilation unit of a librar
y. |
| 1236 */ | 1263 */ |
| 1237 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra
ryElement>("DartEntry.ELEMENT"); | 1264 static final DataDescriptor<LibraryElement> ELEMENT = new DataDescriptor<Libra
ryElement>("DartEntry.ELEMENT"); |
| 1238 | 1265 |
| 1239 /** | 1266 /** |
| 1240 * The data descriptor representing the list of exported libraries. This data
is only available | 1267 * The data descriptor representing the list of exported libraries. This data
is only available |
| 1241 * for Dart files that are the defining compilation unit of a library. | 1268 * for Dart files that are the defining compilation unit of a library. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1442 */ | 1469 */ |
| 1443 CacheState _includedPartsState = CacheState.INVALID; | 1470 CacheState _includedPartsState = CacheState.INVALID; |
| 1444 | 1471 |
| 1445 /** | 1472 /** |
| 1446 * The list of parts included in the library, or an empty array if the list is
not currently | 1473 * The list of parts included in the library, or an empty array if the list is
not currently |
| 1447 * cached. The list will be empty if the Dart file is a part rather than a lib
rary. | 1474 * cached. The list will be empty if the Dart file is a part rather than a lib
rary. |
| 1448 */ | 1475 */ |
| 1449 List<Source> _includedParts = Source.EMPTY_ARRAY; | 1476 List<Source> _includedParts = Source.EMPTY_ARRAY; |
| 1450 | 1477 |
| 1451 /** | 1478 /** |
| 1479 * The list of libraries that contain this compilation unit. The list will be
empty if there are |
| 1480 * no known libraries that contain this compilation unit. |
| 1481 */ |
| 1482 List<Source> _containingLibraries = new List<Source>(); |
| 1483 |
| 1484 /** |
| 1452 * The information known as a result of resolving this compilation unit as par
t of the library | 1485 * The information known as a result of resolving this compilation unit as par
t of the library |
| 1453 * that contains this unit. This field will never be `null`. | 1486 * that contains this unit. This field will never be `null`. |
| 1454 */ | 1487 */ |
| 1455 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS
tate(); | 1488 DartEntryImpl_ResolutionState _resolutionState = new DartEntryImpl_ResolutionS
tate(); |
| 1456 | 1489 |
| 1457 /** | 1490 /** |
| 1458 * The state of the cached library element. | 1491 * The state of the cached library element. |
| 1459 */ | 1492 */ |
| 1460 CacheState _elementState = CacheState.INVALID; | 1493 CacheState _elementState = CacheState.INVALID; |
| 1461 | 1494 |
| 1462 /** | 1495 /** |
| 1463 * The element representing the library, or `null` if the element is not curre
ntly cached. | 1496 * The element representing the library, or `null` if the element is not curre
ntly cached. |
| 1464 */ | 1497 */ |
| 1465 LibraryElement _element; | 1498 LibraryElement _element; |
| 1466 | 1499 |
| 1467 /** | 1500 /** |
| 1468 * The state of the cached [angularElements]. | |
| 1469 */ | |
| 1470 CacheState _angularElementsState = CacheState.INVALID; | |
| 1471 | |
| 1472 /** | |
| 1473 * The array of Angular elements accessible in the library, or an empty array
if the elements are | |
| 1474 * not currently cached. | |
| 1475 */ | |
| 1476 List<AngularElement> _angularElements = AngularElement.EMPTY_ARRAY; | |
| 1477 | |
| 1478 /** | |
| 1479 * The state of the cached public namespace. | 1501 * The state of the cached public namespace. |
| 1480 */ | 1502 */ |
| 1481 CacheState _publicNamespaceState = CacheState.INVALID; | 1503 CacheState _publicNamespaceState = CacheState.INVALID; |
| 1482 | 1504 |
| 1483 /** | 1505 /** |
| 1484 * The public namespace of the library, or `null` if the namespace is not curr
ently cached. | 1506 * The public namespace of the library, or `null` if the namespace is not curr
ently cached. |
| 1485 */ | 1507 */ |
| 1486 Namespace _publicNamespace; | 1508 Namespace _publicNamespace; |
| 1487 | 1509 |
| 1488 /** | 1510 /** |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1507 static int _LAUNCHABLE_INDEX = 1; | 1529 static int _LAUNCHABLE_INDEX = 1; |
| 1508 | 1530 |
| 1509 /** | 1531 /** |
| 1510 * The index of the bit in the [bitmask] indicating that the library is client
code: that | 1532 * The index of the bit in the [bitmask] indicating that the library is client
code: that |
| 1511 * the library depends on the html library. If the library is not "client code
", then it is | 1533 * the library depends on the html library. If the library is not "client code
", then it is |
| 1512 * referred to as "server code". | 1534 * referred to as "server code". |
| 1513 */ | 1535 */ |
| 1514 static int _CLIENT_CODE_INDEX = 2; | 1536 static int _CLIENT_CODE_INDEX = 2; |
| 1515 | 1537 |
| 1516 /** | 1538 /** |
| 1539 * Add the given library to the list of libraries that contain this part. This
method should only |
| 1540 * be invoked on entries that represent a part. |
| 1541 * |
| 1542 * @param librarySource the source of the library to be added |
| 1543 */ |
| 1544 void addContainingLibrary(Source librarySource) { |
| 1545 _containingLibraries.add(librarySource); |
| 1546 } |
| 1547 |
| 1548 /** |
| 1517 * Flush any AST structures being maintained by this entry. | 1549 * Flush any AST structures being maintained by this entry. |
| 1518 */ | 1550 */ |
| 1519 void flushAstStructures() { | 1551 void flushAstStructures() { |
| 1520 if (identical(_parsedUnitState, CacheState.VALID)) { | 1552 if (identical(_parsedUnitState, CacheState.VALID)) { |
| 1521 _parsedUnitState = CacheState.FLUSHED; | 1553 _parsedUnitState = CacheState.FLUSHED; |
| 1522 _parsedUnitAccessed = false; | 1554 _parsedUnitAccessed = false; |
| 1523 _parsedUnit = null; | 1555 _parsedUnit = null; |
| 1524 } | 1556 } |
| 1525 _resolutionState.flushAstStructures(); | 1557 _resolutionState.flushAstStructures(); |
| 1526 } | 1558 } |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 if (identical(state._resolvedUnitState, CacheState.VALID)) { | 1641 if (identical(state._resolvedUnitState, CacheState.VALID)) { |
| 1610 return state._resolvedUnit.accept(new ASTCloner()) as CompilationUnit; | 1642 return state._resolvedUnit.accept(new ASTCloner()) as CompilationUnit; |
| 1611 } | 1643 } |
| 1612 state = state._nextState; | 1644 state = state._nextState; |
| 1613 } | 1645 } |
| 1614 ; | 1646 ; |
| 1615 return null; | 1647 return null; |
| 1616 } | 1648 } |
| 1617 | 1649 |
| 1618 CacheState getState(DataDescriptor descriptor) { | 1650 CacheState getState(DataDescriptor descriptor) { |
| 1619 if (identical(descriptor, DartEntry.ANGULAR_ELEMENTS)) { | 1651 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 1620 return _angularElementsState; | |
| 1621 } else if (identical(descriptor, DartEntry.ELEMENT)) { | |
| 1622 return _elementState; | 1652 return _elementState; |
| 1623 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 1653 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 1624 return _exportedLibrariesState; | 1654 return _exportedLibrariesState; |
| 1625 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | 1655 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 1626 return _importedLibrariesState; | 1656 return _importedLibrariesState; |
| 1627 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1657 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 1628 return _includedPartsState; | 1658 return _includedPartsState; |
| 1629 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 1659 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 1630 return _clientServerState; | 1660 return _clientServerState; |
| 1631 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { | 1661 } else if (identical(descriptor, DartEntry.IS_LAUNCHABLE)) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 } | 1693 } |
| 1664 ; | 1694 ; |
| 1665 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript
or, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERR
ORS) || identical(descriptor, DartEntry.HINTS)) { | 1695 if (identical(descriptor, DartEntry.RESOLUTION_ERRORS) || identical(descript
or, DartEntry.RESOLVED_UNIT) || identical(descriptor, DartEntry.VERIFICATION_ERR
ORS) || identical(descriptor, DartEntry.HINTS)) { |
| 1666 return CacheState.INVALID; | 1696 return CacheState.INVALID; |
| 1667 } else { | 1697 } else { |
| 1668 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 1698 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 1669 } | 1699 } |
| 1670 } | 1700 } |
| 1671 | 1701 |
| 1672 Object getValue(DataDescriptor descriptor) { | 1702 Object getValue(DataDescriptor descriptor) { |
| 1673 if (identical(descriptor, DartEntry.ANGULAR_ELEMENTS)) { | 1703 if (identical(descriptor, DartEntry.CONTAINING_LIBRARIES)) { |
| 1674 return _angularElements; | 1704 return new List.from(_containingLibraries); |
| 1675 } else if (identical(descriptor, DartEntry.ELEMENT)) { | 1705 } else if (identical(descriptor, DartEntry.ELEMENT)) { |
| 1676 return _element; | 1706 return _element; |
| 1677 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 1707 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 1678 return _exportedLibraries; | 1708 return _exportedLibraries; |
| 1679 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | 1709 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 1680 return _importedLibraries; | 1710 return _importedLibraries; |
| 1681 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 1711 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 1682 return _includedParts; | 1712 return _includedParts; |
| 1683 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { | 1713 } else if (identical(descriptor, DartEntry.IS_CLIENT)) { |
| 1684 return BooleanArray.get2(_bitmask, _CLIENT_CODE_INDEX); | 1714 return BooleanArray.get2(_bitmask, _CLIENT_CODE_INDEX); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 _parsedUnitState = CacheState.INVALID; | 1944 _parsedUnitState = CacheState.INVALID; |
| 1915 } | 1945 } |
| 1916 } | 1946 } |
| 1917 | 1947 |
| 1918 /** | 1948 /** |
| 1919 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this | 1949 * Record that an error occurred while attempting to scan or parse the entry r
epresented by this |
| 1920 * entry. This will set the state of all resolution-based information as being
in error, but will | 1950 * entry. This will set the state of all resolution-based information as being
in error, but will |
| 1921 * not change the state of any parse results. | 1951 * not change the state of any parse results. |
| 1922 */ | 1952 */ |
| 1923 void recordResolutionError() { | 1953 void recordResolutionError() { |
| 1924 _angularElements = AngularElement.EMPTY_ARRAY; | |
| 1925 _angularElementsState = CacheState.ERROR; | |
| 1926 _element = null; | 1954 _element = null; |
| 1927 _elementState = CacheState.ERROR; | 1955 _elementState = CacheState.ERROR; |
| 1928 _bitmask = 0; | 1956 _bitmask = 0; |
| 1929 _clientServerState = CacheState.ERROR; | 1957 _clientServerState = CacheState.ERROR; |
| 1930 _launchableState = CacheState.ERROR; | 1958 _launchableState = CacheState.ERROR; |
| 1931 _publicNamespace = null; | 1959 _publicNamespace = null; |
| 1932 _publicNamespaceState = CacheState.ERROR; | 1960 _publicNamespaceState = CacheState.ERROR; |
| 1933 _resolutionState.recordResolutionError(); | 1961 _resolutionState.recordResolutionError(); |
| 1934 } | 1962 } |
| 1935 | 1963 |
| 1936 /** | 1964 /** |
| 1937 * Record that an in-process parse has stopped without recording results becau
se the results were | 1965 * Record that an in-process parse has stopped without recording results becau
se the results were |
| 1938 * invalidated before they could be recorded. | 1966 * invalidated before they could be recorded. |
| 1939 */ | 1967 */ |
| 1940 void recordResolutionNotInProcess() { | 1968 void recordResolutionNotInProcess() { |
| 1941 if (identical(_angularElementsState, CacheState.IN_PROCESS)) { | |
| 1942 _angularElementsState = CacheState.INVALID; | |
| 1943 } | |
| 1944 if (identical(_elementState, CacheState.IN_PROCESS)) { | 1969 if (identical(_elementState, CacheState.IN_PROCESS)) { |
| 1945 _elementState = CacheState.INVALID; | 1970 _elementState = CacheState.INVALID; |
| 1946 } | 1971 } |
| 1947 if (identical(_clientServerState, CacheState.IN_PROCESS)) { | 1972 if (identical(_clientServerState, CacheState.IN_PROCESS)) { |
| 1948 _clientServerState = CacheState.INVALID; | 1973 _clientServerState = CacheState.INVALID; |
| 1949 } | 1974 } |
| 1950 if (identical(_launchableState, CacheState.IN_PROCESS)) { | 1975 if (identical(_launchableState, CacheState.IN_PROCESS)) { |
| 1951 _launchableState = CacheState.INVALID; | 1976 _launchableState = CacheState.INVALID; |
| 1952 } | 1977 } |
| 1953 if (identical(_publicNamespaceState, CacheState.IN_PROCESS)) { | 1978 if (identical(_publicNamespaceState, CacheState.IN_PROCESS)) { |
| 1954 _publicNamespaceState = CacheState.INVALID; | 1979 _publicNamespaceState = CacheState.INVALID; |
| 1955 } | 1980 } |
| 1956 _resolutionState.recordResolutionNotInProcess(); | 1981 _resolutionState.recordResolutionNotInProcess(); |
| 1957 } | 1982 } |
| 1958 | 1983 |
| 1959 /** | 1984 /** |
| 1985 * Remove the given library from the list of libraries that contain this part.
This method should |
| 1986 * only be invoked on entries that represent a part. |
| 1987 * |
| 1988 * @param librarySource the source of the library to be removed |
| 1989 */ |
| 1990 void removeContainingLibrary(Source librarySource) { |
| 1991 _containingLibraries.remove(librarySource); |
| 1992 } |
| 1993 |
| 1994 /** |
| 1960 * Remove any resolution information associated with this compilation unit bei
ng part of the given | 1995 * Remove any resolution information associated with this compilation unit bei
ng part of the given |
| 1961 * library, presumably because it is no longer part of the library. | 1996 * library, presumably because it is no longer part of the library. |
| 1962 * | 1997 * |
| 1963 * @param librarySource the source of the defining compilation unit of the lib
rary that used to | 1998 * @param librarySource the source of the defining compilation unit of the lib
rary that used to |
| 1964 * contain this part but no longer does | 1999 * contain this part but no longer does |
| 1965 */ | 2000 */ |
| 1966 void removeResolution(Source librarySource) { | 2001 void removeResolution(Source librarySource) { |
| 1967 if (librarySource != null) { | 2002 if (librarySource != null) { |
| 1968 if (librarySource == _resolutionState._librarySource) { | 2003 if (librarySource == _resolutionState._librarySource) { |
| 1969 if (_resolutionState._nextState == null) { | 2004 if (_resolutionState._nextState == null) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1980 break; | 2015 break; |
| 1981 } | 2016 } |
| 1982 priorState = state; | 2017 priorState = state; |
| 1983 state = state._nextState; | 2018 state = state._nextState; |
| 1984 } | 2019 } |
| 1985 } | 2020 } |
| 1986 } | 2021 } |
| 1987 } | 2022 } |
| 1988 | 2023 |
| 1989 /** | 2024 /** |
| 2025 * Set the list of libraries that contain this compilation unit to contain onl
y the given source. |
| 2026 * This method should only be invoked on entries that represent a library. |
| 2027 * |
| 2028 * @param librarySource the source of the single library that the list should
contain |
| 2029 */ |
| 2030 void set containingLibrary(Source librarySource) { |
| 2031 _containingLibraries.clear(); |
| 2032 _containingLibraries.add(librarySource); |
| 2033 } |
| 2034 |
| 2035 /** |
| 1990 * Set the results of parsing the compilation unit at the given time to the gi
ven values. | 2036 * Set the results of parsing the compilation unit at the given time to the gi
ven values. |
| 1991 * | 2037 * |
| 1992 * @param modificationStamp the earliest time at which the source was last mod
ified before the | 2038 * @param modificationStamp the earliest time at which the source was last mod
ified before the |
| 1993 * parsing was started | 2039 * parsing was started |
| 1994 * @param lineInfo the line information resulting from parsing the compilation
unit | 2040 * @param lineInfo the line information resulting from parsing the compilation
unit |
| 1995 * @param unit the AST structure resulting from parsing the compilation unit | 2041 * @param unit the AST structure resulting from parsing the compilation unit |
| 1996 * @param errors the parse errors resulting from parsing the compilation unit | 2042 * @param errors the parse errors resulting from parsing the compilation unit |
| 1997 */ | 2043 */ |
| 1998 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit
unit, List<AnalysisError> errors) { | 2044 void setParseResults(int modificationStamp, LineInfo lineInfo, CompilationUnit
unit, List<AnalysisError> errors) { |
| 1999 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { | 2045 if (getState(SourceEntry.LINE_INFO) != CacheState.VALID) { |
| 2000 setValue(SourceEntry.LINE_INFO, lineInfo); | 2046 setValue(SourceEntry.LINE_INFO, lineInfo); |
| 2001 } | 2047 } |
| 2002 if (_parsedUnitState != CacheState.VALID) { | 2048 if (_parsedUnitState != CacheState.VALID) { |
| 2003 _parsedUnit = unit; | 2049 _parsedUnit = unit; |
| 2004 _parsedUnitAccessed = false; | 2050 _parsedUnitAccessed = false; |
| 2005 _parsedUnitState = CacheState.VALID; | 2051 _parsedUnitState = CacheState.VALID; |
| 2006 } | 2052 } |
| 2007 if (_parseErrorsState != CacheState.VALID) { | 2053 if (_parseErrorsState != CacheState.VALID) { |
| 2008 _parseErrors = errors == null ? AnalysisError.NO_ERRORS : errors; | 2054 _parseErrors = errors == null ? AnalysisError.NO_ERRORS : errors; |
| 2009 _parseErrorsState = CacheState.VALID; | 2055 _parseErrorsState = CacheState.VALID; |
| 2010 } | 2056 } |
| 2011 } | 2057 } |
| 2012 | 2058 |
| 2013 void setState(DataDescriptor descriptor, CacheState state) { | 2059 void setState(DataDescriptor descriptor, CacheState state) { |
| 2014 if (identical(descriptor, DartEntry.ANGULAR_ELEMENTS)) { | 2060 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 2015 _angularElements = updatedValue(state, _angularElements, AngularElement.EM
PTY_ARRAY); | |
| 2016 _angularElementsState = state; | |
| 2017 } else if (identical(descriptor, DartEntry.ELEMENT)) { | |
| 2018 _element = updatedValue(state, _element, null); | 2061 _element = updatedValue(state, _element, null); |
| 2019 _elementState = state; | 2062 _elementState = state; |
| 2020 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 2063 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 2021 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_
ARRAY); | 2064 _exportedLibraries = updatedValue(state, _exportedLibraries, Source.EMPTY_
ARRAY); |
| 2022 _exportedLibrariesState = state; | 2065 _exportedLibrariesState = state; |
| 2023 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | 2066 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 2024 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_
ARRAY); | 2067 _importedLibraries = updatedValue(state, _importedLibraries, Source.EMPTY_
ARRAY); |
| 2025 _importedLibrariesState = state; | 2068 _importedLibrariesState = state; |
| 2026 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 2069 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 2027 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); | 2070 _includedParts = updatedValue(state, _includedParts, Source.EMPTY_ARRAY); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2075 state._verificationErrorsState = cacheState; | 2118 state._verificationErrorsState = cacheState; |
| 2076 } else if (identical(descriptor, DartEntry.HINTS)) { | 2119 } else if (identical(descriptor, DartEntry.HINTS)) { |
| 2077 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR
ORS); | 2120 state._hints = updatedValue(cacheState, state._hints, AnalysisError.NO_ERR
ORS); |
| 2078 state._hintsState = cacheState; | 2121 state._hintsState = cacheState; |
| 2079 } else { | 2122 } else { |
| 2080 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); | 2123 throw new IllegalArgumentException("Invalid descriptor: ${descriptor}"); |
| 2081 } | 2124 } |
| 2082 } | 2125 } |
| 2083 | 2126 |
| 2084 void setValue(DataDescriptor descriptor, Object value) { | 2127 void setValue(DataDescriptor descriptor, Object value) { |
| 2085 if (identical(descriptor, DartEntry.ANGULAR_ELEMENTS)) { | 2128 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 2086 _angularElements = value as List<AngularElement>; | |
| 2087 _angularElementsState = CacheState.VALID; | |
| 2088 } else if (identical(descriptor, DartEntry.ELEMENT)) { | |
| 2089 _element = value as LibraryElement; | 2129 _element = value as LibraryElement; |
| 2090 _elementState = CacheState.VALID; | 2130 _elementState = CacheState.VALID; |
| 2091 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { | 2131 } else if (identical(descriptor, DartEntry.EXPORTED_LIBRARIES)) { |
| 2092 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); | 2132 _exportedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); |
| 2093 _exportedLibrariesState = CacheState.VALID; | 2133 _exportedLibrariesState = CacheState.VALID; |
| 2094 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { | 2134 } else if (identical(descriptor, DartEntry.IMPORTED_LIBRARIES)) { |
| 2095 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); | 2135 _importedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List<S
ource>); |
| 2096 _importedLibrariesState = CacheState.VALID; | 2136 _importedLibrariesState = CacheState.VALID; |
| 2097 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { | 2137 } else if (identical(descriptor, DartEntry.INCLUDED_PARTS)) { |
| 2098 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); | 2138 _includedParts = value == null ? Source.EMPTY_ARRAY : (value as List<Sourc
e>); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 _parsedUnit = other._parsedUnit; | 2196 _parsedUnit = other._parsedUnit; |
| 2157 _parsedUnitAccessed = other._parsedUnitAccessed; | 2197 _parsedUnitAccessed = other._parsedUnitAccessed; |
| 2158 _parseErrorsState = other._parseErrorsState; | 2198 _parseErrorsState = other._parseErrorsState; |
| 2159 _parseErrors = other._parseErrors; | 2199 _parseErrors = other._parseErrors; |
| 2160 _includedPartsState = other._includedPartsState; | 2200 _includedPartsState = other._includedPartsState; |
| 2161 _includedParts = other._includedParts; | 2201 _includedParts = other._includedParts; |
| 2162 _exportedLibrariesState = other._exportedLibrariesState; | 2202 _exportedLibrariesState = other._exportedLibrariesState; |
| 2163 _exportedLibraries = other._exportedLibraries; | 2203 _exportedLibraries = other._exportedLibraries; |
| 2164 _importedLibrariesState = other._importedLibrariesState; | 2204 _importedLibrariesState = other._importedLibrariesState; |
| 2165 _importedLibraries = other._importedLibraries; | 2205 _importedLibraries = other._importedLibraries; |
| 2206 _containingLibraries = new List<Source>.from(other._containingLibraries); |
| 2166 _resolutionState.copyFrom(other._resolutionState); | 2207 _resolutionState.copyFrom(other._resolutionState); |
| 2167 _elementState = other._elementState; | 2208 _elementState = other._elementState; |
| 2168 _element = other._element; | 2209 _element = other._element; |
| 2169 _publicNamespaceState = other._publicNamespaceState; | 2210 _publicNamespaceState = other._publicNamespaceState; |
| 2170 _publicNamespace = other._publicNamespace; | 2211 _publicNamespace = other._publicNamespace; |
| 2171 _clientServerState = other._clientServerState; | 2212 _clientServerState = other._clientServerState; |
| 2172 _launchableState = other._launchableState; | 2213 _launchableState = other._launchableState; |
| 2173 _angularElementsState = other._angularElementsState; | |
| 2174 _angularElements = other._angularElements; | |
| 2175 _bitmask = other._bitmask; | 2214 _bitmask = other._bitmask; |
| 2176 } | 2215 } |
| 2177 | 2216 |
| 2178 bool hasErrorState() => super.hasErrorState() || identical(_sourceKindState, C
acheState.ERROR) || identical(_parsedUnitState, CacheState.ERROR) || identical(_
parseErrorsState, CacheState.ERROR) || identical(_importedLibrariesState, CacheS
tate.ERROR) || identical(_exportedLibrariesState, CacheState.ERROR) || identical
(_includedPartsState, CacheState.ERROR) || identical(_elementState, CacheState.E
RROR) || identical(_angularElementsState, CacheState.ERROR) || identical(_public
NamespaceState, CacheState.ERROR) || identical(_clientServerState, CacheState.ER
ROR) || identical(_launchableState, CacheState.ERROR) || _resolutionState.hasErr
orState(); | 2217 bool hasErrorState() => super.hasErrorState() || identical(_sourceKindState, C
acheState.ERROR) || identical(_parsedUnitState, CacheState.ERROR) || identical(_
parseErrorsState, CacheState.ERROR) || identical(_importedLibrariesState, CacheS
tate.ERROR) || identical(_exportedLibrariesState, CacheState.ERROR) || identical
(_includedPartsState, CacheState.ERROR) || identical(_elementState, CacheState.E
RROR) || identical(_publicNamespaceState, CacheState.ERROR) || identical(_client
ServerState, CacheState.ERROR) || identical(_launchableState, CacheState.ERROR)
|| _resolutionState.hasErrorState(); |
| 2179 | 2218 |
| 2180 void writeOn(JavaStringBuilder builder) { | 2219 void writeOn(JavaStringBuilder builder) { |
| 2181 builder.append("Dart: "); | 2220 builder.append("Dart: "); |
| 2182 super.writeOn(builder); | 2221 super.writeOn(builder); |
| 2183 builder.append("; sourceKind = "); | 2222 builder.append("; sourceKind = "); |
| 2184 builder.append(_sourceKindState); | 2223 builder.append(_sourceKindState); |
| 2185 builder.append("; parsedUnit = "); | 2224 builder.append("; parsedUnit = "); |
| 2186 builder.append(_parsedUnitState); | 2225 builder.append(_parsedUnitState); |
| 2187 builder.append(" ("); | 2226 builder.append(" ("); |
| 2188 builder.append(_parsedUnitAccessed ? "T" : "F"); | 2227 builder.append(_parsedUnitAccessed ? "T" : "F"); |
| 2189 builder.append("); parseErrors = "); | 2228 builder.append("); parseErrors = "); |
| 2190 builder.append(_parseErrorsState); | 2229 builder.append(_parseErrorsState); |
| 2191 builder.append("; exportedLibraries = "); | 2230 builder.append("; exportedLibraries = "); |
| 2192 builder.append(_exportedLibrariesState); | 2231 builder.append(_exportedLibrariesState); |
| 2193 builder.append("; importedLibraries = "); | 2232 builder.append("; importedLibraries = "); |
| 2194 builder.append(_importedLibrariesState); | 2233 builder.append(_importedLibrariesState); |
| 2195 builder.append("; includedParts = "); | 2234 builder.append("; includedParts = "); |
| 2196 builder.append(_includedPartsState); | 2235 builder.append(_includedPartsState); |
| 2197 builder.append("; element = "); | 2236 builder.append("; element = "); |
| 2198 builder.append(_elementState); | 2237 builder.append(_elementState); |
| 2199 builder.append("; publicNamespace = "); | 2238 builder.append("; publicNamespace = "); |
| 2200 builder.append(_publicNamespaceState); | 2239 builder.append(_publicNamespaceState); |
| 2201 builder.append("; clientServer = "); | 2240 builder.append("; clientServer = "); |
| 2202 builder.append(_clientServerState); | 2241 builder.append(_clientServerState); |
| 2203 builder.append("; launchable = "); | 2242 builder.append("; launchable = "); |
| 2204 builder.append(_launchableState); | 2243 builder.append(_launchableState); |
| 2205 builder.append("; angularElements = "); | 2244 builder.append("; angularElements = "); |
| 2206 builder.append(_angularElementsState); | |
| 2207 _resolutionState.writeOn(builder); | 2245 _resolutionState.writeOn(builder); |
| 2208 } | 2246 } |
| 2209 | 2247 |
| 2210 /** | 2248 /** |
| 2211 * Invalidate all of the resolution information associated with the compilatio
n unit. | 2249 * Invalidate all of the resolution information associated with the compilatio
n unit. |
| 2212 */ | 2250 */ |
| 2213 void discardCachedResolutionInformation() { | 2251 void discardCachedResolutionInformation() { |
| 2214 _angularElements = AngularElement.EMPTY_ARRAY; | |
| 2215 _angularElementsState = CacheState.INVALID; | |
| 2216 _element = null; | 2252 _element = null; |
| 2217 _elementState = CacheState.INVALID; | 2253 _elementState = CacheState.INVALID; |
| 2218 _includedParts = Source.EMPTY_ARRAY; | 2254 _includedParts = Source.EMPTY_ARRAY; |
| 2219 _includedPartsState = CacheState.INVALID; | 2255 _includedPartsState = CacheState.INVALID; |
| 2220 _exportedLibraries = Source.EMPTY_ARRAY; | 2256 _exportedLibraries = Source.EMPTY_ARRAY; |
| 2221 _exportedLibrariesState = CacheState.INVALID; | 2257 _exportedLibrariesState = CacheState.INVALID; |
| 2222 _importedLibraries = Source.EMPTY_ARRAY; | 2258 _importedLibraries = Source.EMPTY_ARRAY; |
| 2223 _importedLibrariesState = CacheState.INVALID; | 2259 _importedLibrariesState = CacheState.INVALID; |
| 2224 _bitmask = 0; | 2260 _bitmask = 0; |
| 2225 _clientServerState = CacheState.INVALID; | 2261 _clientServerState = CacheState.INVALID; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 } | 2512 } |
| 2477 | 2513 |
| 2478 /** | 2514 /** |
| 2479 * The interface `HtmlEntry` defines the behavior of objects that maintain the i
nformation | 2515 * The interface `HtmlEntry` defines the behavior of objects that maintain the i
nformation |
| 2480 * cached by an analysis context about an individual HTML file. | 2516 * cached by an analysis context about an individual HTML file. |
| 2481 * | 2517 * |
| 2482 * @coverage dart.engine | 2518 * @coverage dart.engine |
| 2483 */ | 2519 */ |
| 2484 abstract class HtmlEntry implements SourceEntry { | 2520 abstract class HtmlEntry implements SourceEntry { |
| 2485 /** | 2521 /** |
| 2522 * The data descriptor representing the information about an Angular applicati
on this source is |
| 2523 * used in. |
| 2524 */ |
| 2525 static final DataDescriptor<AngularApplicationInfo> ANGULAR_APPLICATION = new
DataDescriptor<AngularApplicationInfo>("HtmlEntry.ANGULAR_APPLICATION"); |
| 2526 |
| 2527 /** |
| 2528 * The data descriptor representing the information about an Angular component
this source is used |
| 2529 * as template for. |
| 2530 */ |
| 2531 static final DataDescriptor<AngularComponentElement> ANGULAR_COMPONENT = new D
ataDescriptor<AngularComponentElement>("HtmlEntry.ANGULAR_COMPONENT"); |
| 2532 |
| 2533 /** |
| 2534 * The data descriptor representing the information about an Angular applicati
on this source is |
| 2535 * entry point for. |
| 2536 */ |
| 2537 static final DataDescriptor<AngularApplicationInfo> ANGULAR_ENTRY = new DataDe
scriptor<AngularApplicationInfo>("HtmlEntry.ANGULAR_ENTRY"); |
| 2538 |
| 2539 /** |
| 2486 * The data descriptor representing the errors reported during Angular resolut
ion. | 2540 * The data descriptor representing the errors reported during Angular resolut
ion. |
| 2487 */ | 2541 */ |
| 2488 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc
riptor<List<AnalysisError>>("HtmlEntry.ANGULAR_ERRORS"); | 2542 static final DataDescriptor<List<AnalysisError>> ANGULAR_ERRORS = new DataDesc
riptor<List<AnalysisError>>("HtmlEntry.ANGULAR_ERRORS"); |
| 2489 | 2543 |
| 2490 /** | 2544 /** |
| 2491 * The data descriptor representing the HTML element. | 2545 * The data descriptor representing the HTML element. |
| 2492 */ | 2546 */ |
| 2493 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem
ent>("HtmlEntry.ELEMENT"); | 2547 static final DataDescriptor<HtmlElement> ELEMENT = new DataDescriptor<HtmlElem
ent>("HtmlEntry.ELEMENT"); |
| 2494 | 2548 |
| 2495 /** | 2549 /** |
| 2496 * The data descriptor representing the hints resulting from auditing the sour
ce. | 2550 * The data descriptor representing the hints resulting from auditing the sour
ce. |
| 2497 */ | 2551 */ |
| 2498 static final DataDescriptor<List<AnalysisError>> HINTS = new DataDescriptor<Li
st<AnalysisError>>("HtmlEntry.HINTS"); | 2552 static final DataDescriptor<List<AnalysisError>> HINTS = new DataDescriptor<Li
st<AnalysisError>>("HtmlEntry.HINTS"); |
| 2499 | 2553 |
| 2500 /** | 2554 /** |
| 2501 * The data descriptor representing the errors resulting from parsing the sour
ce. | 2555 * The data descriptor representing the errors resulting from parsing the sour
ce. |
| 2502 */ | 2556 */ |
| 2503 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescri
ptor<List<AnalysisError>>("HtmlEntry.PARSE_ERRORS"); | 2557 static final DataDescriptor<List<AnalysisError>> PARSE_ERRORS = new DataDescri
ptor<List<AnalysisError>>("HtmlEntry.PARSE_ERRORS"); |
| 2504 | 2558 |
| 2505 /** | 2559 /** |
| 2506 * The data descriptor representing the parsed AST structure. | 2560 * The data descriptor representing the parsed AST structure. |
| 2507 */ | 2561 */ |
| 2508 static final DataDescriptor<ht.HtmlUnit> PARSED_UNIT = new DataDescriptor<ht.H
tmlUnit>("HtmlEntry.PARSED_UNIT"); | 2562 static final DataDescriptor<ht.HtmlUnit> PARSED_UNIT = new DataDescriptor<ht.H
tmlUnit>("HtmlEntry.PARSED_UNIT"); |
| 2509 | 2563 |
| 2510 /** | 2564 /** |
| 2565 * The data descriptor representing the resolved AST structure. |
| 2566 */ |
| 2567 static final DataDescriptor<ht.HtmlUnit> RESOLVED_UNIT = new DataDescriptor<ht
.HtmlUnit>("HtmlEntry.RESOLVED_UNIT"); |
| 2568 |
| 2569 /** |
| 2511 * The data descriptor representing the list of referenced libraries. | 2570 * The data descriptor representing the list of referenced libraries. |
| 2512 */ | 2571 */ |
| 2513 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescr
iptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); | 2572 static final DataDescriptor<List<Source>> REFERENCED_LIBRARIES = new DataDescr
iptor<List<Source>>("HtmlEntry.REFERENCED_LIBRARIES"); |
| 2514 | 2573 |
| 2515 /** | 2574 /** |
| 2516 * The data descriptor representing the errors resulting from resolving the so
urce. | 2575 * The data descriptor representing the errors resulting from resolving the so
urce. |
| 2517 */ | 2576 */ |
| 2518 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD
escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); | 2577 static final DataDescriptor<List<AnalysisError>> RESOLUTION_ERRORS = new DataD
escriptor<List<AnalysisError>>("HtmlEntry.RESOLUTION_ERRORS"); |
| 2519 | 2578 |
| 2520 /** | 2579 /** |
| 2521 * Return all of the errors associated with the compilation unit that are curr
ently cached. | 2580 * Return all of the errors associated with the compilation unit that are curr
ently cached. |
| 2522 * | 2581 * |
| 2523 * @return all of the errors associated with the compilation unit | 2582 * @return all of the errors associated with the compilation unit |
| 2524 */ | 2583 */ |
| 2525 List<AnalysisError> get allErrors; | 2584 List<AnalysisError> get allErrors; |
| 2526 | 2585 |
| 2586 /** |
| 2587 * Return a valid parsed unit, either an unresolved AST structure or the resul
t of resolving the |
| 2588 * AST structure, or `null` if there is no parsed unit available. |
| 2589 * |
| 2590 * @return a valid parsed unit |
| 2591 */ |
| 2592 ht.HtmlUnit get anyParsedUnit; |
| 2593 |
| 2527 HtmlEntryImpl get writableCopy; | 2594 HtmlEntryImpl get writableCopy; |
| 2528 } | 2595 } |
| 2529 | 2596 |
| 2530 /** | 2597 /** |
| 2531 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry]. | 2598 * Instances of the class `HtmlEntryImpl` implement an [HtmlEntry]. |
| 2532 * | 2599 * |
| 2533 * @coverage dart.engine | 2600 * @coverage dart.engine |
| 2534 */ | 2601 */ |
| 2535 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { | 2602 class HtmlEntryImpl extends SourceEntryImpl implements HtmlEntry { |
| 2536 /** | 2603 /** |
| 2537 * The state of the cached parsed (but not resolved) HTML unit. | 2604 * The state of the cached parsed (but not resolved) HTML unit. |
| 2538 */ | 2605 */ |
| 2539 CacheState _parsedUnitState = CacheState.INVALID; | 2606 CacheState _parsedUnitState = CacheState.INVALID; |
| 2540 | 2607 |
| 2541 /** | 2608 /** |
| 2542 * The parsed HTML unit, or `null` if the parsed HTML unit is not currently ca
ched. | 2609 * The parsed HTML unit, or `null` if the parsed HTML unit is not currently ca
ched. |
| 2543 */ | 2610 */ |
| 2544 ht.HtmlUnit _parsedUnit; | 2611 ht.HtmlUnit _parsedUnit; |
| 2545 | 2612 |
| 2546 /** | 2613 /** |
| 2614 * The state of the cached resolved HTML unit. |
| 2615 */ |
| 2616 CacheState _resolvedUnitState = CacheState.INVALID; |
| 2617 |
| 2618 /** |
| 2619 * The resolved HTML unit, or `null` if the resolved HTML unit is not currentl
y cached. |
| 2620 */ |
| 2621 ht.HtmlUnit _resolvedUnit; |
| 2622 |
| 2623 /** |
| 2547 * The state of the cached parse errors. | 2624 * The state of the cached parse errors. |
| 2548 */ | 2625 */ |
| 2549 CacheState _parseErrorsState = CacheState.INVALID; | 2626 CacheState _parseErrorsState = CacheState.INVALID; |
| 2550 | 2627 |
| 2551 /** | 2628 /** |
| 2552 * The errors produced while scanning and parsing the HTML, or `null` if the e
rrors are not | 2629 * The errors produced while scanning and parsing the HTML, or `null` if the e
rrors are not |
| 2553 * currently cached. | 2630 * currently cached. |
| 2554 */ | 2631 */ |
| 2555 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; | 2632 List<AnalysisError> _parseErrors = AnalysisError.NO_ERRORS; |
| 2556 | 2633 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2580 * The state of the cached HTML element. | 2657 * The state of the cached HTML element. |
| 2581 */ | 2658 */ |
| 2582 CacheState _elementState = CacheState.INVALID; | 2659 CacheState _elementState = CacheState.INVALID; |
| 2583 | 2660 |
| 2584 /** | 2661 /** |
| 2585 * The element representing the HTML file, or `null` if the element is not cur
rently cached. | 2662 * The element representing the HTML file, or `null` if the element is not cur
rently cached. |
| 2586 */ | 2663 */ |
| 2587 HtmlElement _element; | 2664 HtmlElement _element; |
| 2588 | 2665 |
| 2589 /** | 2666 /** |
| 2667 * The state of the [angularApplication]. |
| 2668 */ |
| 2669 CacheState _angularApplicationState = CacheState.VALID; |
| 2670 |
| 2671 /** |
| 2672 * Information about the Angular Application this unit is used in. |
| 2673 */ |
| 2674 AngularApplicationInfo _angularApplication; |
| 2675 |
| 2676 /** |
| 2677 * The state of the [angularEntry]. |
| 2678 */ |
| 2679 CacheState _angularEntryState = CacheState.VALID; |
| 2680 |
| 2681 /** |
| 2682 * Information about the Angular Application this unit is entry point for. |
| 2683 */ |
| 2684 AngularApplicationInfo _angularEntry = null; |
| 2685 |
| 2686 /** |
| 2687 * The state of the [angularComponent]. |
| 2688 */ |
| 2689 CacheState _angularComponentState = CacheState.VALID; |
| 2690 |
| 2691 /** |
| 2692 * Information about the [AngularComponentElement] this unit is used as templa
te for. |
| 2693 */ |
| 2694 AngularComponentElement _angularComponent = null; |
| 2695 |
| 2696 /** |
| 2590 * The state of the Angular resolution errors. | 2697 * The state of the Angular resolution errors. |
| 2591 */ | 2698 */ |
| 2592 CacheState _angularErrorsState = CacheState.INVALID; | 2699 CacheState _angularErrorsState = CacheState.INVALID; |
| 2593 | 2700 |
| 2594 /** | 2701 /** |
| 2595 * The hints produced while performing Angular resolution, or an empty array i
f the error are not | 2702 * The hints produced while performing Angular resolution, or an empty array i
f the error are not |
| 2596 * currently cached. | 2703 * currently cached. |
| 2597 */ | 2704 */ |
| 2598 List<AnalysisError> _angularErrors = AnalysisError.NO_ERRORS; | 2705 List<AnalysisError> _angularErrors = AnalysisError.NO_ERRORS; |
| 2599 | 2706 |
| 2600 /** | 2707 /** |
| 2601 * The state of the cached hints. | 2708 * The state of the cached hints. |
| 2602 */ | 2709 */ |
| 2603 CacheState _hintsState = CacheState.INVALID; | 2710 CacheState _hintsState = CacheState.INVALID; |
| 2604 | 2711 |
| 2605 /** | 2712 /** |
| 2606 * The hints produced while auditing the compilation unit, or an empty array i
f the hints are not | 2713 * The hints produced while auditing the compilation unit, or an empty array i
f the hints are not |
| 2607 * currently cached. | 2714 * currently cached. |
| 2608 */ | 2715 */ |
| 2609 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; | 2716 List<AnalysisError> _hints = AnalysisError.NO_ERRORS; |
| 2610 | 2717 |
| 2718 /** |
| 2719 * Flush any AST structures being maintained by this entry. |
| 2720 */ |
| 2721 void flushAstStructures() { |
| 2722 if (identical(_parsedUnitState, CacheState.VALID)) { |
| 2723 _parsedUnitState = CacheState.FLUSHED; |
| 2724 _parsedUnit = null; |
| 2725 } |
| 2726 if (identical(_resolvedUnitState, CacheState.VALID)) { |
| 2727 _resolvedUnitState = CacheState.FLUSHED; |
| 2728 _resolvedUnit = null; |
| 2729 } |
| 2730 } |
| 2731 |
| 2611 List<AnalysisError> get allErrors { | 2732 List<AnalysisError> get allErrors { |
| 2612 List<AnalysisError> errors = new List<AnalysisError>(); | 2733 List<AnalysisError> errors = new List<AnalysisError>(); |
| 2613 if (_parseErrors != null) { | 2734 if (_parseErrors != null) { |
| 2614 for (AnalysisError error in _parseErrors) { | 2735 for (AnalysisError error in _parseErrors) { |
| 2615 errors.add(error); | 2736 errors.add(error); |
| 2616 } | 2737 } |
| 2617 } | 2738 } |
| 2618 if (_resolutionErrors != null) { | 2739 if (_resolutionErrors != null) { |
| 2619 for (AnalysisError error in _resolutionErrors) { | 2740 for (AnalysisError error in _resolutionErrors) { |
| 2620 errors.add(error); | 2741 errors.add(error); |
| 2621 } | 2742 } |
| 2622 } | 2743 } |
| 2623 if (_angularErrors != null) { | 2744 if (_angularErrors != null) { |
| 2624 for (AnalysisError error in _angularErrors) { | 2745 for (AnalysisError error in _angularErrors) { |
| 2625 errors.add(error); | 2746 errors.add(error); |
| 2626 } | 2747 } |
| 2627 } | 2748 } |
| 2628 if (_hints != null) { | 2749 if (_hints != null) { |
| 2629 for (AnalysisError error in _hints) { | 2750 for (AnalysisError error in _hints) { |
| 2630 errors.add(error); | 2751 errors.add(error); |
| 2631 } | 2752 } |
| 2632 } | 2753 } |
| 2633 if (errors.length == 0) { | 2754 if (errors.length == 0) { |
| 2634 return AnalysisError.NO_ERRORS; | 2755 return AnalysisError.NO_ERRORS; |
| 2635 } | 2756 } |
| 2636 return new List.from(errors); | 2757 return new List.from(errors); |
| 2637 } | 2758 } |
| 2638 | 2759 |
| 2760 ht.HtmlUnit get anyParsedUnit { |
| 2761 if (identical(_parsedUnitState, CacheState.VALID)) { |
| 2762 // parsedUnitAccessed = true; |
| 2763 return _parsedUnit; |
| 2764 } |
| 2765 if (identical(_resolvedUnitState, CacheState.VALID)) { |
| 2766 // resovledUnitAccessed = true; |
| 2767 return _resolvedUnit; |
| 2768 } |
| 2769 return null; |
| 2770 } |
| 2771 |
| 2639 SourceKind get kind => SourceKind.HTML; | 2772 SourceKind get kind => SourceKind.HTML; |
| 2640 | 2773 |
| 2641 CacheState getState(DataDescriptor descriptor) { | 2774 CacheState getState(DataDescriptor descriptor) { |
| 2642 if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { | 2775 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { |
| 2776 return _angularApplicationState; |
| 2777 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { |
| 2778 return _angularComponentState; |
| 2779 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { |
| 2780 return _angularEntryState; |
| 2781 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { |
| 2643 return _angularErrorsState; | 2782 return _angularErrorsState; |
| 2644 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { | 2783 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 2645 return _elementState; | 2784 return _elementState; |
| 2646 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { | 2785 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { |
| 2647 return _parseErrorsState; | 2786 return _parseErrorsState; |
| 2648 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 2787 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 2649 return _parsedUnitState; | 2788 return _parsedUnitState; |
| 2789 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 2790 return _resolvedUnitState; |
| 2650 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | 2791 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 2651 return _referencedLibrariesState; | 2792 return _referencedLibrariesState; |
| 2652 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | 2793 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 2653 return _resolutionErrorsState; | 2794 return _resolutionErrorsState; |
| 2654 } else if (identical(descriptor, HtmlEntry.HINTS)) { | 2795 } else if (identical(descriptor, HtmlEntry.HINTS)) { |
| 2655 return _hintsState; | 2796 return _hintsState; |
| 2656 } | 2797 } |
| 2657 return super.getState(descriptor); | 2798 return super.getState(descriptor); |
| 2658 } | 2799 } |
| 2659 | 2800 |
| 2660 Object getValue(DataDescriptor descriptor) { | 2801 Object getValue(DataDescriptor descriptor) { |
| 2661 if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { | 2802 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { |
| 2803 return _angularApplication; |
| 2804 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { |
| 2805 return _angularComponent; |
| 2806 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { |
| 2807 return _angularEntry; |
| 2808 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { |
| 2662 return _angularErrors; | 2809 return _angularErrors; |
| 2663 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { | 2810 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 2664 return _element; | 2811 return _element; |
| 2665 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { | 2812 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { |
| 2666 return _parseErrors; | 2813 return _parseErrors; |
| 2667 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 2814 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 2668 return _parsedUnit; | 2815 return _parsedUnit; |
| 2816 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 2817 return _resolvedUnit; |
| 2669 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | 2818 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 2670 return _referencedLibraries; | 2819 return _referencedLibraries; |
| 2671 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | 2820 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 2672 return _resolutionErrors; | 2821 return _resolutionErrors; |
| 2673 } else if (identical(descriptor, HtmlEntry.HINTS)) { | 2822 } else if (identical(descriptor, HtmlEntry.HINTS)) { |
| 2674 return _hints; | 2823 return _hints; |
| 2675 } | 2824 } |
| 2676 return super.getValue(descriptor); | 2825 return super.getValue(descriptor); |
| 2677 } | 2826 } |
| 2678 | 2827 |
| 2679 HtmlEntryImpl get writableCopy { | 2828 HtmlEntryImpl get writableCopy { |
| 2680 HtmlEntryImpl copy = new HtmlEntryImpl(); | 2829 HtmlEntryImpl copy = new HtmlEntryImpl(); |
| 2681 copy.copyFrom(this); | 2830 copy.copyFrom(this); |
| 2682 return copy; | 2831 return copy; |
| 2683 } | 2832 } |
| 2684 | 2833 |
| 2685 void invalidateAllInformation() { | 2834 void invalidateAllInformation() { |
| 2686 super.invalidateAllInformation(); | 2835 super.invalidateAllInformation(); |
| 2687 _parseErrors = AnalysisError.NO_ERRORS; | 2836 _parseErrors = AnalysisError.NO_ERRORS; |
| 2688 _parseErrorsState = CacheState.INVALID; | 2837 _parseErrorsState = CacheState.INVALID; |
| 2689 _parsedUnit = null; | 2838 _parsedUnit = null; |
| 2690 _parsedUnitState = CacheState.INVALID; | 2839 _parsedUnitState = CacheState.INVALID; |
| 2840 _resolvedUnit = null; |
| 2841 _resolvedUnitState = CacheState.INVALID; |
| 2691 _referencedLibraries = Source.EMPTY_ARRAY; | 2842 _referencedLibraries = Source.EMPTY_ARRAY; |
| 2692 _referencedLibrariesState = CacheState.INVALID; | 2843 _referencedLibrariesState = CacheState.INVALID; |
| 2693 invalidateAllResolutionInformation(); | 2844 invalidateAllResolutionInformation(); |
| 2694 } | 2845 } |
| 2695 | 2846 |
| 2696 /** | 2847 /** |
| 2697 * Invalidate all of the resolution information associated with the HTML file. | 2848 * Invalidate all of the resolution information associated with the HTML file. |
| 2698 */ | 2849 */ |
| 2699 void invalidateAllResolutionInformation() { | 2850 void invalidateAllResolutionInformation() { |
| 2700 _angularErrors = AnalysisError.NO_ERRORS; | 2851 _angularErrors = AnalysisError.NO_ERRORS; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2718 setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); | 2869 setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); |
| 2719 recordResolutionError(); | 2870 recordResolutionError(); |
| 2720 } | 2871 } |
| 2721 | 2872 |
| 2722 /** | 2873 /** |
| 2723 * Record that an error was encountered while attempting to resolve the source
associated with | 2874 * Record that an error was encountered while attempting to resolve the source
associated with |
| 2724 * this entry. | 2875 * this entry. |
| 2725 */ | 2876 */ |
| 2726 void recordResolutionError() { | 2877 void recordResolutionError() { |
| 2727 setState(HtmlEntry.ANGULAR_ERRORS, CacheState.ERROR); | 2878 setState(HtmlEntry.ANGULAR_ERRORS, CacheState.ERROR); |
| 2879 setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); |
| 2728 setState(HtmlEntry.ELEMENT, CacheState.ERROR); | 2880 setState(HtmlEntry.ELEMENT, CacheState.ERROR); |
| 2729 setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.ERROR); | 2881 setState(HtmlEntry.RESOLUTION_ERRORS, CacheState.ERROR); |
| 2730 setState(HtmlEntry.HINTS, CacheState.ERROR); | 2882 setState(HtmlEntry.HINTS, CacheState.ERROR); |
| 2731 } | 2883 } |
| 2732 | 2884 |
| 2733 void setState(DataDescriptor descriptor, CacheState state) { | 2885 void setState(DataDescriptor descriptor, CacheState state) { |
| 2734 if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { | 2886 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { |
| 2887 _angularApplication = updatedValue(state, _angularApplication, null); |
| 2888 _angularApplicationState = state; |
| 2889 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { |
| 2890 _angularComponent = updatedValue(state, _angularComponent, null); |
| 2891 _angularComponentState = state; |
| 2892 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { |
| 2893 _angularEntry = updatedValue(state, _angularEntry, null); |
| 2894 _angularEntryState = state; |
| 2895 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { |
| 2735 _angularErrors = updatedValue(state, _angularErrors, null); | 2896 _angularErrors = updatedValue(state, _angularErrors, null); |
| 2736 _angularErrorsState = state; | 2897 _angularErrorsState = state; |
| 2737 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { | 2898 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 2738 _element = updatedValue(state, _element, null); | 2899 _element = updatedValue(state, _element, null); |
| 2739 _elementState = state; | 2900 _elementState = state; |
| 2740 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { | 2901 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { |
| 2741 _parseErrors = updatedValue(state, _parseErrors, null); | 2902 _parseErrors = updatedValue(state, _parseErrors, null); |
| 2742 _parseErrorsState = state; | 2903 _parseErrorsState = state; |
| 2743 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 2904 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 2744 _parsedUnit = updatedValue(state, _parsedUnit, null); | 2905 _parsedUnit = updatedValue(state, _parsedUnit, null); |
| 2745 _parsedUnitState = state; | 2906 _parsedUnitState = state; |
| 2907 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 2908 _resolvedUnit = updatedValue(state, _resolvedUnit, null); |
| 2909 _resolvedUnitState = state; |
| 2746 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | 2910 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 2747 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM
PTY_ARRAY); | 2911 _referencedLibraries = updatedValue(state, _referencedLibraries, Source.EM
PTY_ARRAY); |
| 2748 _referencedLibrariesState = state; | 2912 _referencedLibrariesState = state; |
| 2749 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | 2913 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 2750 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N
O_ERRORS); | 2914 _resolutionErrors = updatedValue(state, _resolutionErrors, AnalysisError.N
O_ERRORS); |
| 2751 _resolutionErrorsState = state; | 2915 _resolutionErrorsState = state; |
| 2752 } else if (identical(descriptor, HtmlEntry.HINTS)) { | 2916 } else if (identical(descriptor, HtmlEntry.HINTS)) { |
| 2753 _hints = updatedValue(state, _hints, AnalysisError.NO_ERRORS); | 2917 _hints = updatedValue(state, _hints, AnalysisError.NO_ERRORS); |
| 2754 _hintsState = state; | 2918 _hintsState = state; |
| 2755 } else { | 2919 } else { |
| 2756 super.setState(descriptor, state); | 2920 super.setState(descriptor, state); |
| 2757 } | 2921 } |
| 2758 } | 2922 } |
| 2759 | 2923 |
| 2760 void setValue(DataDescriptor descriptor, Object value) { | 2924 void setValue(DataDescriptor descriptor, Object value) { |
| 2761 if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { | 2925 if (identical(descriptor, HtmlEntry.ANGULAR_APPLICATION)) { |
| 2926 _angularApplication = value as AngularApplicationInfo; |
| 2927 _angularApplicationState = CacheState.VALID; |
| 2928 } else if (identical(descriptor, HtmlEntry.ANGULAR_COMPONENT)) { |
| 2929 _angularComponent = value as AngularComponentElement; |
| 2930 _angularComponentState = CacheState.VALID; |
| 2931 } else if (identical(descriptor, HtmlEntry.ANGULAR_ENTRY)) { |
| 2932 _angularEntry = value as AngularApplicationInfo; |
| 2933 _angularEntryState = CacheState.VALID; |
| 2934 } else if (identical(descriptor, HtmlEntry.ANGULAR_ERRORS)) { |
| 2762 _angularErrors = value as List<AnalysisError>; | 2935 _angularErrors = value as List<AnalysisError>; |
| 2763 _angularErrorsState = CacheState.VALID; | 2936 _angularErrorsState = CacheState.VALID; |
| 2764 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { | 2937 } else if (identical(descriptor, HtmlEntry.ELEMENT)) { |
| 2765 _element = value as HtmlElement; | 2938 _element = value as HtmlElement; |
| 2766 _elementState = CacheState.VALID; | 2939 _elementState = CacheState.VALID; |
| 2767 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { | 2940 } else if (identical(descriptor, HtmlEntry.PARSE_ERRORS)) { |
| 2768 _parseErrors = value as List<AnalysisError>; | 2941 _parseErrors = value as List<AnalysisError>; |
| 2769 _parseErrorsState = CacheState.VALID; | 2942 _parseErrorsState = CacheState.VALID; |
| 2770 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { | 2943 } else if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 2771 _parsedUnit = value as ht.HtmlUnit; | 2944 _parsedUnit = value as ht.HtmlUnit; |
| 2772 _parsedUnitState = CacheState.VALID; | 2945 _parsedUnitState = CacheState.VALID; |
| 2946 } else if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 2947 _resolvedUnit = value as ht.HtmlUnit; |
| 2948 _resolvedUnitState = CacheState.VALID; |
| 2773 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { | 2949 } else if (identical(descriptor, HtmlEntry.REFERENCED_LIBRARIES)) { |
| 2774 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List
<Source>); | 2950 _referencedLibraries = value == null ? Source.EMPTY_ARRAY : (value as List
<Source>); |
| 2775 _referencedLibrariesState = CacheState.VALID; | 2951 _referencedLibrariesState = CacheState.VALID; |
| 2776 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { | 2952 } else if (identical(descriptor, HtmlEntry.RESOLUTION_ERRORS)) { |
| 2777 _resolutionErrors = value as List<AnalysisError>; | 2953 _resolutionErrors = value as List<AnalysisError>; |
| 2778 _resolutionErrorsState = CacheState.VALID; | 2954 _resolutionErrorsState = CacheState.VALID; |
| 2779 } else if (identical(descriptor, HtmlEntry.HINTS)) { | 2955 } else if (identical(descriptor, HtmlEntry.HINTS)) { |
| 2780 _hints = value as List<AnalysisError>; | 2956 _hints = value as List<AnalysisError>; |
| 2781 _hintsState = CacheState.VALID; | 2957 _hintsState = CacheState.VALID; |
| 2782 } else { | 2958 } else { |
| 2783 super.setValue(descriptor, value); | 2959 super.setValue(descriptor, value); |
| 2784 } | 2960 } |
| 2785 } | 2961 } |
| 2786 | 2962 |
| 2787 void copyFrom(SourceEntryImpl entry) { | 2963 void copyFrom(SourceEntryImpl entry) { |
| 2788 super.copyFrom(entry); | 2964 super.copyFrom(entry); |
| 2789 HtmlEntryImpl other = entry as HtmlEntryImpl; | 2965 HtmlEntryImpl other = entry as HtmlEntryImpl; |
| 2966 _angularApplicationState = other._angularApplicationState; |
| 2967 _angularApplication = other._angularApplication; |
| 2968 _angularComponentState = other._angularComponentState; |
| 2969 _angularComponent = other._angularComponent; |
| 2970 _angularEntryState = other._angularEntryState; |
| 2971 _angularEntry = other._angularEntry; |
| 2790 _angularErrorsState = other._angularErrorsState; | 2972 _angularErrorsState = other._angularErrorsState; |
| 2791 _angularErrors = other._angularErrors; | 2973 _angularErrors = other._angularErrors; |
| 2792 _parseErrorsState = other._parseErrorsState; | 2974 _parseErrorsState = other._parseErrorsState; |
| 2793 _parseErrors = other._parseErrors; | 2975 _parseErrors = other._parseErrors; |
| 2794 _parsedUnitState = other._parsedUnitState; | 2976 _parsedUnitState = other._parsedUnitState; |
| 2795 _parsedUnit = other._parsedUnit; | 2977 _parsedUnit = other._parsedUnit; |
| 2978 _resolvedUnitState = other._resolvedUnitState; |
| 2979 _resolvedUnit = other._resolvedUnit; |
| 2796 _referencedLibrariesState = other._referencedLibrariesState; | 2980 _referencedLibrariesState = other._referencedLibrariesState; |
| 2797 _referencedLibraries = other._referencedLibraries; | 2981 _referencedLibraries = other._referencedLibraries; |
| 2798 _resolutionErrors = other._resolutionErrors; | 2982 _resolutionErrors = other._resolutionErrors; |
| 2799 _resolutionErrorsState = other._resolutionErrorsState; | 2983 _resolutionErrorsState = other._resolutionErrorsState; |
| 2800 _elementState = other._elementState; | 2984 _elementState = other._elementState; |
| 2801 _element = other._element; | 2985 _element = other._element; |
| 2802 _hints = other._hints; | 2986 _hints = other._hints; |
| 2803 _hintsState = other._hintsState; | 2987 _hintsState = other._hintsState; |
| 2804 } | 2988 } |
| 2805 | 2989 |
| 2806 bool hasErrorState() => super.hasErrorState() || identical(_parsedUnitState, C
acheState.ERROR) || identical(_parseErrorsState, CacheState.ERROR) || identical(
_resolutionErrorsState, CacheState.ERROR) || identical(_referencedLibrariesState
, CacheState.ERROR) || identical(_elementState, CacheState.ERROR) || identical(_
angularErrorsState, CacheState.ERROR) || identical(_hintsState, CacheState.ERROR
); | 2990 bool 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); |
| 2807 | 2991 |
| 2808 void writeOn(JavaStringBuilder builder) { | 2992 void writeOn(JavaStringBuilder builder) { |
| 2809 builder.append("Html: "); | 2993 builder.append("Html: "); |
| 2810 super.writeOn(builder); | 2994 super.writeOn(builder); |
| 2811 builder.append("; parseErrors = "); | 2995 builder.append("; parseErrors = "); |
| 2812 builder.append(_parseErrorsState); | 2996 builder.append(_parseErrorsState); |
| 2813 builder.append("; parsedUnit = "); | 2997 builder.append("; parsedUnit = "); |
| 2814 builder.append(_parsedUnitState); | 2998 builder.append(_parsedUnitState); |
| 2999 builder.append("; resolvedUnit = "); |
| 3000 builder.append(_resolvedUnitState); |
| 2815 builder.append("; resolutionErrors = "); | 3001 builder.append("; resolutionErrors = "); |
| 2816 builder.append(_resolutionErrorsState); | 3002 builder.append(_resolutionErrorsState); |
| 2817 builder.append("; referencedLibraries = "); | 3003 builder.append("; referencedLibraries = "); |
| 2818 builder.append(_referencedLibrariesState); | 3004 builder.append(_referencedLibrariesState); |
| 2819 builder.append("; element = "); | 3005 builder.append("; element = "); |
| 2820 builder.append(_elementState); | 3006 builder.append(_elementState); |
| 3007 builder.append("; angularApplication = "); |
| 3008 builder.append(_angularApplicationState); |
| 3009 builder.append("; angularComponent = "); |
| 3010 builder.append(_angularComponentState); |
| 3011 builder.append("; angularEntry = "); |
| 3012 builder.append(_angularEntryState); |
| 2821 builder.append("; angularErrors = "); | 3013 builder.append("; angularErrors = "); |
| 2822 builder.append(_angularErrorsState); | 3014 builder.append(_angularErrorsState); |
| 2823 } | 3015 } |
| 2824 } | 3016 } |
| 2825 | 3017 |
| 2826 /** | 3018 /** |
| 2827 * The enumerated type `RetentionPriority` represents the priority of data in th
e cache in | 3019 * The enumerated type `RetentionPriority` represents the priority of data in th
e cache in |
| 2828 * terms of the desirability of retaining some specified data about a specified
source. | 3020 * terms of the desirability of retaining some specified data about a specified
source. |
| 2829 */ | 3021 */ |
| 2830 class RetentionPriority extends Enum<RetentionPriority> { | 3022 class RetentionPriority extends Enum<RetentionPriority> { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3239 */ | 3431 */ |
| 3240 AnalysisContextImpl_AnalysisTaskResultRecorder _resultRecorder; | 3432 AnalysisContextImpl_AnalysisTaskResultRecorder _resultRecorder; |
| 3241 | 3433 |
| 3242 /** | 3434 /** |
| 3243 * Cached information used in incremental analysis or `null` if none. Synchron
ize against | 3435 * Cached information used in incremental analysis or `null` if none. Synchron
ize against |
| 3244 * [cacheLock] before accessing this field. | 3436 * [cacheLock] before accessing this field. |
| 3245 */ | 3437 */ |
| 3246 IncrementalAnalysisCache _incrementalAnalysisCache; | 3438 IncrementalAnalysisCache _incrementalAnalysisCache; |
| 3247 | 3439 |
| 3248 /** | 3440 /** |
| 3441 * The object used to manage the list of sources that need to be analyzed. |
| 3442 */ |
| 3443 WorkManager _workManager = new WorkManager(); |
| 3444 |
| 3445 /** |
| 3249 * Initialize a newly created analysis context. | 3446 * Initialize a newly created analysis context. |
| 3250 */ | 3447 */ |
| 3251 AnalysisContextImpl() : super() { | 3448 AnalysisContextImpl() : super() { |
| 3252 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); | 3449 _resultRecorder = new AnalysisContextImpl_AnalysisTaskResultRecorder(this); |
| 3253 _cache = new AnalysisCache(AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, new Analy
sisContextImpl_ContextRetentionPolicy(this)); | 3450 _cache = new AnalysisCache(AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, new Analy
sisContextImpl_ContextRetentionPolicy(this)); |
| 3254 } | 3451 } |
| 3255 | 3452 |
| 3256 void addSourceInfo(Source source, SourceEntry info) { | 3453 void addSourceInfo(Source source, SourceEntry info) { |
| 3257 // This implementation assumes that the access to the cache does not need to
be synchronized | 3454 // This implementation assumes that the access to the cache does not need to
be synchronized |
| 3258 // because no other object can have access to this context while this method
is being invoked. | 3455 // because no other object can have access to this context while this method
is being invoked. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3287 for (Source source in removedSources) { | 3484 for (Source source in removedSources) { |
| 3288 sourceRemoved(source); | 3485 sourceRemoved(source); |
| 3289 } | 3486 } |
| 3290 if (addedDartSource) { | 3487 if (addedDartSource) { |
| 3291 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-an
alyze any libraries | 3488 // TODO(brianwilkerson) This is hugely inefficient, but we need to re-an
alyze any libraries |
| 3292 // that might have been referencing the not-yet-existing source that was
just added. Longer | 3489 // that might have been referencing the not-yet-existing source that was
just added. Longer |
| 3293 // term we need to keep track of which libraries are referencing non-exi
sting sources and | 3490 // term we need to keep track of which libraries are referencing non-exi
sting sources and |
| 3294 // only re-analyze those libraries. | 3491 // only re-analyze those libraries. |
| 3295 logInformation("Added Dart sources, invalidating all resolution informat
ion"); | 3492 logInformation("Added Dart sources, invalidating all resolution informat
ion"); |
| 3296 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 3493 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
| 3494 Source source = mapEntry.getKey(); |
| 3297 SourceEntry sourceEntry = mapEntry.getValue(); | 3495 SourceEntry sourceEntry = mapEntry.getValue(); |
| 3298 if (!mapEntry.getKey().isInSystemLibrary && sourceEntry is DartEntry)
{ | 3496 if (!source.isInSystemLibrary && sourceEntry is DartEntry) { |
| 3299 DartEntryImpl dartCopy = sourceEntry.writableCopy; | 3497 DartEntry dartEntry = sourceEntry; |
| 3498 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3499 removeFromParts(source, dartEntry); |
| 3300 dartCopy.invalidateAllResolutionInformation(); | 3500 dartCopy.invalidateAllResolutionInformation(); |
| 3301 mapEntry.setValue(dartCopy); | 3501 mapEntry.setValue(dartCopy); |
| 3502 WorkManagerPriority priority = WorkManagerPriority.UNKNOWN; |
| 3503 SourceKind kind = dartCopy.kind; |
| 3504 if (identical(kind, SourceKind.LIBRARY)) { |
| 3505 priority = WorkManagerPriority.LIBRARY; |
| 3506 } else if (identical(kind, SourceKind.PART)) { |
| 3507 priority = WorkManagerPriority.NORMAL_PART; |
| 3508 } |
| 3509 _workManager.add(source, priority); |
| 3302 } | 3510 } |
| 3303 } | 3511 } |
| 3304 } | 3512 } |
| 3305 } | 3513 } |
| 3306 } | 3514 } |
| 3307 | 3515 |
| 3308 String computeDocumentationComment(Element element) { | 3516 String computeDocumentationComment(Element element) { |
| 3309 if (element == null) { | 3517 if (element == null) { |
| 3310 return null; | 3518 return null; |
| 3311 } | 3519 } |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3400 LineInfo computeLineInfo(Source source) { | 3608 LineInfo computeLineInfo(Source source) { |
| 3401 SourceEntry sourceEntry = getReadableSourceEntry(source); | 3609 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 3402 if (sourceEntry is HtmlEntry) { | 3610 if (sourceEntry is HtmlEntry) { |
| 3403 return getHtmlParseData(source, SourceEntry.LINE_INFO, null); | 3611 return getHtmlParseData(source, SourceEntry.LINE_INFO, null); |
| 3404 } else if (sourceEntry is DartEntry) { | 3612 } else if (sourceEntry is DartEntry) { |
| 3405 return getDartParseData2(source, SourceEntry.LINE_INFO, null); | 3613 return getDartParseData2(source, SourceEntry.LINE_INFO, null); |
| 3406 } | 3614 } |
| 3407 return null; | 3615 return null; |
| 3408 } | 3616 } |
| 3409 | 3617 |
| 3618 ResolvableHtmlUnit computeResolvableAngularComponentHtmlUnit(Source source) { |
| 3619 HtmlEntry htmlEntry = getReadableHtmlEntry(source); |
| 3620 if (htmlEntry == null) { |
| 3621 throw new AnalysisException.con1("computeResolvableAngularComponentHtmlUni
t invoked for non-HTML file: ${source.fullName}"); |
| 3622 } |
| 3623 htmlEntry = cacheHtmlResolutionData(source, htmlEntry, HtmlEntry.RESOLVED_UN
IT); |
| 3624 ht.HtmlUnit unit = htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 3625 if (unit == null) { |
| 3626 AnalysisException cause = htmlEntry.exception; |
| 3627 throw new AnalysisException.con2("Internal error: computeResolvableAngular
ComponentHtmlUnit could not resolve ${source.fullName}", cause); |
| 3628 } |
| 3629 // If the unit is ever modified by resolution then we will need to create a
copy of it. |
| 3630 return new ResolvableHtmlUnit(htmlEntry.modificationTime, unit); |
| 3631 } |
| 3632 |
| 3410 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { | 3633 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) { |
| 3411 while (true) { | 3634 { |
| 3412 { | 3635 DartEntry dartEntry = getReadableDartEntry(source); |
| 3413 DartEntry dartEntry = getReadableDartEntry(source); | 3636 if (dartEntry == null) { |
| 3414 if (dartEntry == null) { | 3637 throw new AnalysisException.con1("computeResolvableCompilationUnit for n
on-Dart: ${source.fullName}"); |
| 3415 throw new AnalysisException.con1("computeResolvableCompilationUnit for
non-Dart: ${source.fullName}"); | |
| 3416 } | |
| 3417 if (identical(dartEntry.getState(DartEntry.PARSED_UNIT), CacheState.ERRO
R)) { | |
| 3418 AnalysisException cause = dartEntry.exception; | |
| 3419 if (cause == null) { | |
| 3420 throw new AnalysisException.con1("Internal error: computeResolvableC
ompilationUnit could not parse ${source.fullName}"); | |
| 3421 } else { | |
| 3422 throw new AnalysisException.con2("Internal error: computeResolvableC
ompilationUnit could not parse ${source.fullName}", cause); | |
| 3423 } | |
| 3424 } | |
| 3425 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 3426 CompilationUnit unit = dartCopy.resolvableCompilationUnit; | |
| 3427 if (unit != null) { | |
| 3428 _cache.put(source, dartCopy); | |
| 3429 return new ResolvableCompilationUnit(dartCopy.modificationTime, unit); | |
| 3430 } | |
| 3431 } | 3638 } |
| 3432 cacheDartParseData(source, getReadableDartEntry(source), DartEntry.PARSED_
UNIT); | 3639 dartEntry = cacheDartParseData(source, dartEntry, DartEntry.PARSED_UNIT); |
| 3640 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3641 CompilationUnit unit = dartCopy.resolvableCompilationUnit; |
| 3642 if (unit == null) { |
| 3643 throw new AnalysisException.con2("Internal error: computeResolvableCompi
lationUnit could not parse ${source.fullName}", dartEntry.exception); |
| 3644 } |
| 3645 _cache.put(source, dartCopy); |
| 3646 return new ResolvableCompilationUnit(dartCopy.modificationTime, unit); |
| 3433 } | 3647 } |
| 3434 } | 3648 } |
| 3435 | 3649 |
| 3436 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) { | 3650 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) { |
| 3437 HtmlEntry htmlEntry = getReadableHtmlEntry(source); | 3651 HtmlEntry htmlEntry = getReadableHtmlEntry(source); |
| 3438 if (htmlEntry == null) { | 3652 if (htmlEntry == null) { |
| 3439 throw new AnalysisException.con1("computeResolvableHtmlUnit invoked for no
n-HTML file: ${source.fullName}"); | 3653 throw new AnalysisException.con1("computeResolvableHtmlUnit invoked for no
n-HTML file: ${source.fullName}"); |
| 3440 } | 3654 } |
| 3441 htmlEntry = cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); | 3655 htmlEntry = cacheHtmlParseData(source, htmlEntry, HtmlEntry.PARSED_UNIT); |
| 3442 ht.HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); | 3656 ht.HtmlUnit unit = htmlEntry.getValue(HtmlEntry.PARSED_UNIT); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3574 // DartEntry dartEntry = (DartEntry) sourceEntry; | 3788 // DartEntry dartEntry = (DartEntry) sourceEntry; |
| 3575 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEn
try.getValue(DartEntry.IS_CLIENT)) { | 3789 // if (dartEntry.getValue(DartEntry.IS_LAUNCHABLE) && !dartEn
try.getValue(DartEntry.IS_CLIENT)) { |
| 3576 sources.add(source); | 3790 sources.add(source); |
| 3577 } | 3791 } |
| 3578 } | 3792 } |
| 3579 } | 3793 } |
| 3580 return new List.from(sources); | 3794 return new List.from(sources); |
| 3581 } | 3795 } |
| 3582 | 3796 |
| 3583 List<Source> getLibrariesContaining(Source source) { | 3797 List<Source> getLibrariesContaining(Source source) { |
| 3584 { | 3798 DartEntry dartEntry = getReadableDartEntry(source); |
| 3585 SourceEntry sourceEntry = _cache.get(source); | 3799 if (dartEntry == null) { |
| 3586 if (sourceEntry == null || sourceEntry.kind != SourceKind.PART) { | 3800 return Source.EMPTY_ARRAY; |
| 3587 return <Source> [source]; | |
| 3588 } | |
| 3589 List<Source> librarySources = new List<Source>(); | |
| 3590 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | |
| 3591 sourceEntry = entry.getValue(); | |
| 3592 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { | |
| 3593 if (contains((sourceEntry as DartEntry).getValue(DartEntry.INCLUDED_PA
RTS), source)) { | |
| 3594 librarySources.add(entry.getKey()); | |
| 3595 } | |
| 3596 } | |
| 3597 } | |
| 3598 if (librarySources.isEmpty) { | |
| 3599 return Source.EMPTY_ARRAY; | |
| 3600 } | |
| 3601 return new List.from(librarySources); | |
| 3602 } | 3801 } |
| 3802 return dartEntry.getValue(DartEntry.CONTAINING_LIBRARIES); |
| 3603 } | 3803 } |
| 3604 | 3804 |
| 3605 List<Source> getLibrariesDependingOn(Source librarySource) { | 3805 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 3606 { | 3806 { |
| 3607 List<Source> dependentLibraries = new List<Source>(); | 3807 List<Source> dependentLibraries = new List<Source>(); |
| 3608 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 3808 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 3609 SourceEntry sourceEntry = entry.getValue(); | 3809 SourceEntry sourceEntry = entry.getValue(); |
| 3610 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { | 3810 if (identical(sourceEntry.kind, SourceKind.LIBRARY)) { |
| 3611 if (contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LI
BRARIES), librarySource)) { | 3811 if (contains((sourceEntry as DartEntry).getValue(DartEntry.EXPORTED_LI
BRARIES), librarySource)) { |
| 3612 dependentLibraries.add(entry.getKey()); | 3812 dependentLibraries.add(entry.getKey()); |
| 3613 } | 3813 } |
| 3614 if (contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LI
BRARIES), librarySource)) { | 3814 if (contains((sourceEntry as DartEntry).getValue(DartEntry.IMPORTED_LI
BRARIES), librarySource)) { |
| 3615 dependentLibraries.add(entry.getKey()); | 3815 dependentLibraries.add(entry.getKey()); |
| 3616 } | 3816 } |
| 3617 } | 3817 } |
| 3618 } | 3818 } |
| 3619 if (dependentLibraries.isEmpty) { | 3819 if (dependentLibraries.isEmpty) { |
| 3620 return Source.EMPTY_ARRAY; | 3820 return Source.EMPTY_ARRAY; |
| 3621 } | 3821 } |
| 3622 return new List.from(dependentLibraries); | 3822 return new List.from(dependentLibraries); |
| 3623 } | 3823 } |
| 3624 } | 3824 } |
| 3625 | 3825 |
| 3626 List<AngularElement> getLibraryAngularElements(Source source) { | |
| 3627 SourceEntry sourceEntry = getReadableSourceEntry(source); | |
| 3628 if (sourceEntry is DartEntry) { | |
| 3629 return sourceEntry.getValue(DartEntry.ANGULAR_ELEMENTS); | |
| 3630 } | |
| 3631 return AngularElement.EMPTY_ARRAY; | |
| 3632 } | |
| 3633 | |
| 3634 LibraryElement getLibraryElement(Source source) { | 3826 LibraryElement getLibraryElement(Source source) { |
| 3635 SourceEntry sourceEntry = getReadableSourceEntry(source); | 3827 SourceEntry sourceEntry = getReadableSourceEntry(source); |
| 3636 if (sourceEntry is DartEntry) { | 3828 if (sourceEntry is DartEntry) { |
| 3637 return sourceEntry.getValue(DartEntry.ELEMENT); | 3829 return sourceEntry.getValue(DartEntry.ELEMENT); |
| 3638 } | 3830 } |
| 3639 return null; | 3831 return null; |
| 3640 } | 3832 } |
| 3641 | 3833 |
| 3642 List<Source> get librarySources => getSources(SourceKind.LIBRARY); | 3834 List<Source> get librarySources => getSources(SourceKind.LIBRARY); |
| 3643 | 3835 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 3660 Namespace namespace = null; | 3852 Namespace namespace = null; |
| 3661 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 3853 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
| 3662 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); | 3854 namespace = dartEntry.getValue(DartEntry.PUBLIC_NAMESPACE); |
| 3663 } | 3855 } |
| 3664 if (namespace == null) { | 3856 if (namespace == null) { |
| 3665 NamespaceBuilder builder = new NamespaceBuilder(); | 3857 NamespaceBuilder builder = new NamespaceBuilder(); |
| 3666 namespace = builder.createPublicNamespace(library); | 3858 namespace = builder.createPublicNamespace(library); |
| 3667 { | 3859 { |
| 3668 dartEntry = getReadableDartEntry(source); | 3860 dartEntry = getReadableDartEntry(source); |
| 3669 if (dartEntry == null) { | 3861 if (dartEntry == null) { |
| 3670 AnalysisEngine.instance.logger.logError3(new AnalysisException.con1("A
Dart file became a non-Dart file: ${source.fullName}")); | 3862 AnalysisEngine.instance.logger.logError2("Could not compute the public
namespace for ${library.source.fullName}", new AnalysisException.con1("A Dart f
ile became a non-Dart file: ${source.fullName}")); |
| 3671 return null; | 3863 return null; |
| 3672 } | 3864 } |
| 3673 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { | 3865 if (identical(dartEntry.getValue(DartEntry.ELEMENT), library)) { |
| 3674 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; | 3866 DartEntryImpl dartCopy = getReadableDartEntry(source).writableCopy; |
| 3675 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); | 3867 dartCopy.setValue(DartEntry.PUBLIC_NAMESPACE, namespace); |
| 3676 _cache.put(source, dartCopy); | 3868 _cache.put(source, dartCopy); |
| 3677 } | 3869 } |
| 3678 } | 3870 } |
| 3679 } | 3871 } |
| 3680 return namespace; | 3872 return namespace; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3737 if (sourceEntry is DartEntry) { | 3929 if (sourceEntry is DartEntry) { |
| 3738 return sourceEntry.getValue2(DartEntry.RESOLVED_UNIT, librarySource); | 3930 return sourceEntry.getValue2(DartEntry.RESOLVED_UNIT, librarySource); |
| 3739 } | 3931 } |
| 3740 return null; | 3932 return null; |
| 3741 } | 3933 } |
| 3742 | 3934 |
| 3743 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 3935 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
| 3744 SourceEntry sourceEntry = getReadableSourceEntry(htmlSource); | 3936 SourceEntry sourceEntry = getReadableSourceEntry(htmlSource); |
| 3745 if (sourceEntry is HtmlEntry) { | 3937 if (sourceEntry is HtmlEntry) { |
| 3746 HtmlEntry htmlEntry = sourceEntry; | 3938 HtmlEntry htmlEntry = sourceEntry; |
| 3747 if (htmlEntry.getValue(HtmlEntry.ELEMENT) != null) { | 3939 return htmlEntry.getValue(HtmlEntry.RESOLVED_UNIT); |
| 3748 return htmlEntry.getValue(HtmlEntry.PARSED_UNIT); | |
| 3749 } | |
| 3750 } | 3940 } |
| 3751 return null; | 3941 return null; |
| 3752 } | 3942 } |
| 3753 | 3943 |
| 3754 SourceFactory get sourceFactory => _sourceFactory; | 3944 SourceFactory get sourceFactory => _sourceFactory; |
| 3755 | 3945 |
| 3756 /** | 3946 /** |
| 3757 * Return a list of the sources that would be processed by [performAnalysisTas
k]. This | 3947 * Return a list of the sources that would be processed by [performAnalysisTas
k]. This |
| 3758 * method duplicates, and must therefore be kept in sync with, [getNextTaskAna
lysisTask]. | 3948 * method duplicates, and must therefore be kept in sync with, [getNextAnalysi
sTask]. |
| 3759 * This method is intended to be used for testing purposes only. | 3949 * This method is intended to be used for testing purposes only. |
| 3760 * | 3950 * |
| 3761 * @return a list of the sources that would be processed by [performAnalysisTa
sk] | 3951 * @return a list of the sources that would be processed by [performAnalysisTa
sk] |
| 3762 */ | 3952 */ |
| 3763 List<Source> get sourcesNeedingProcessing { | 3953 List<Source> get sourcesNeedingProcessing { |
| 3764 Set<Source> sources = new Set<Source>(); | 3954 Set<Source> sources = new Set<Source>(); |
| 3765 { | 3955 { |
| 3766 bool hintsEnabled = _options.hint; | 3956 bool hintsEnabled = _options.hint; |
| 3767 // | 3957 // |
| 3768 // Look for priority sources that need to be analyzed. | 3958 // Look for priority sources that need to be analyzed. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3869 } | 4059 } |
| 3870 } | 4060 } |
| 3871 } | 4061 } |
| 3872 | 4062 |
| 3873 CompilationUnit parseCompilationUnit(Source source) => getDartParseData2(sourc
e, DartEntry.PARSED_UNIT, null); | 4063 CompilationUnit parseCompilationUnit(Source source) => getDartParseData2(sourc
e, DartEntry.PARSED_UNIT, null); |
| 3874 | 4064 |
| 3875 ht.HtmlUnit parseHtmlUnit(Source source) => getHtmlParseData(source, HtmlEntry
.PARSED_UNIT, null); | 4065 ht.HtmlUnit parseHtmlUnit(Source source) => getHtmlParseData(source, HtmlEntry
.PARSED_UNIT, null); |
| 3876 | 4066 |
| 3877 AnalysisResult performAnalysisTask() { | 4067 AnalysisResult performAnalysisTask() { |
| 3878 int getStart = JavaSystem.currentTimeMillis(); | 4068 int getStart = JavaSystem.currentTimeMillis(); |
| 3879 AnalysisTask task = nextTaskAnalysisTask; | 4069 AnalysisTask task = nextAnalysisTask; |
| 3880 int getEnd = JavaSystem.currentTimeMillis(); | 4070 int getEnd = JavaSystem.currentTimeMillis(); |
| 3881 if (task == null && validateCacheConsistency()) { | 4071 if (task == null && validateCacheConsistency()) { |
| 3882 task = nextTaskAnalysisTask; | 4072 task = nextAnalysisTask; |
| 3883 } | 4073 } |
| 3884 if (task == null) { | 4074 if (task == null) { |
| 3885 return new AnalysisResult(getChangeNotices(true), getEnd - getStart, null,
-1); | 4075 return new AnalysisResult(getChangeNotices(true), getEnd - getStart, null,
-1); |
| 3886 } | 4076 } |
| 3887 String taskDescriptor = task.toString(); | 4077 String taskDescriptor = task.toString(); |
| 3888 if (_recentTasks.add(taskDescriptor)) { | 4078 if (_recentTasks.add(taskDescriptor)) { |
| 3889 logInformation("Performing task: ${taskDescriptor}"); | 4079 logInformation("Performing task: ${taskDescriptor}"); |
| 3890 } else { | 4080 } else { |
| 3891 logInformation("*** Performing repeated task: ${taskDescriptor}"); | 4081 logInformation("*** Performing repeated task: ${taskDescriptor}"); |
| 3892 } | 4082 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 3907 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); | 4097 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); |
| 3908 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap))
{ | 4098 for (MapEntry<Source, LibraryElement> entry in getMapEntrySet(elementMap))
{ |
| 3909 Source librarySource = entry.getKey(); | 4099 Source librarySource = entry.getKey(); |
| 3910 LibraryElement library = entry.getValue(); | 4100 LibraryElement library = entry.getValue(); |
| 3911 // | 4101 // |
| 3912 // Cache the element in the library's info. | 4102 // Cache the element in the library's info. |
| 3913 // | 4103 // |
| 3914 DartEntry dartEntry = getReadableDartEntry(librarySource); | 4104 DartEntry dartEntry = getReadableDartEntry(librarySource); |
| 3915 if (dartEntry != null) { | 4105 if (dartEntry != null) { |
| 3916 DartEntryImpl dartCopy = dartEntry.writableCopy; | 4106 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 3917 recordElementData(dartCopy, library, htmlSource); | 4107 recordElementData(dartEntry, dartCopy, library, library.source, htmlSo
urce); |
| 3918 _cache.put(librarySource, dartCopy); | 4108 _cache.put(librarySource, dartCopy); |
| 3919 } | 4109 } |
| 3920 } | 4110 } |
| 3921 } | 4111 } |
| 3922 } | 4112 } |
| 3923 | 4113 |
| 3924 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { | 4114 CompilationUnit resolveCompilationUnit(Source unitSource, LibraryElement libra
ry) { |
| 3925 if (library == null) { | 4115 if (library == null) { |
| 3926 return null; | 4116 return null; |
| 3927 } | 4117 } |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4073 // The resolved libraries should only be null if an exception was thrown
during resolution. | 4263 // The resolved libraries should only be null if an exception was thrown
during resolution. |
| 4074 // | 4264 // |
| 4075 unitEntry = getReadableDartEntry(unitSource); | 4265 unitEntry = getReadableDartEntry(unitSource); |
| 4076 if (unitEntry == null) { | 4266 if (unitEntry == null) { |
| 4077 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); | 4267 throw new AnalysisException.con1("A Dart file became a non-Dart file:
${unitSource.fullName}"); |
| 4078 } | 4268 } |
| 4079 DartEntryImpl dartCopy = unitEntry.writableCopy; | 4269 DartEntryImpl dartCopy = unitEntry.writableCopy; |
| 4080 dartCopy.recordResolutionError(); | 4270 dartCopy.recordResolutionError(); |
| 4081 dartCopy.exception = thrownException; | 4271 dartCopy.exception = thrownException; |
| 4082 _cache.put(unitSource, dartCopy); | 4272 _cache.put(unitSource, dartCopy); |
| 4273 _cache.remove(unitSource); |
| 4083 if (thrownException != null) { | 4274 if (thrownException != null) { |
| 4084 throw thrownException; | 4275 throw thrownException; |
| 4085 } | 4276 } |
| 4086 return dartCopy; | 4277 return dartCopy; |
| 4087 } | 4278 } |
| 4088 { | 4279 { |
| 4089 if (allModificationTimesMatch(resolvedLibraries)) { | 4280 if (allModificationTimesMatch(resolvedLibraries)) { |
| 4090 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); | 4281 Source htmlSource = sourceFactory.forUri(DartSdk.DART_HTML); |
| 4091 RecordingErrorListener errorListener = resolver.errorListener; | 4282 RecordingErrorListener errorListener = resolver.errorListener; |
| 4092 for (Library library in resolvedLibraries) { | 4283 for (Library library in resolvedLibraries) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4104 if (dartEntry == null) { | 4295 if (dartEntry == null) { |
| 4105 throw new AnalysisException.con1("A Dart file became a non-Dar
t file: ${source.fullName}"); | 4296 throw new AnalysisException.con1("A Dart file became a non-Dar
t file: ${source.fullName}"); |
| 4106 } | 4297 } |
| 4107 } | 4298 } |
| 4108 DartEntryImpl dartCopy = dartEntry.writableCopy; | 4299 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4109 if (thrownException == null) { | 4300 if (thrownException == null) { |
| 4110 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 4301 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 4111 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); | 4302 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 4112 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit)
; | 4303 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, unit)
; |
| 4113 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, e
rrors); | 4304 dartCopy.setValue2(DartEntry.RESOLUTION_ERRORS, librarySource, e
rrors); |
| 4114 if (identical(source, librarySource)) { | 4305 if (source == librarySource) { |
| 4115 recordElementData(dartCopy, library.libraryElement, htmlSource
); | 4306 recordElementData(dartEntry, dartCopy, library.libraryElement,
librarySource, htmlSource); |
| 4116 recordAngularComponents(library, dartCopy); | |
| 4117 } | 4307 } |
| 4308 _cache.storedAst(source); |
| 4118 } else { | 4309 } else { |
| 4119 dartCopy.recordResolutionError(); | 4310 dartCopy.recordResolutionError(); |
| 4311 _cache.remove(source); |
| 4120 } | 4312 } |
| 4121 dartCopy.exception = thrownException; | 4313 dartCopy.exception = thrownException; |
| 4122 _cache.put(source, dartCopy); | 4314 _cache.put(source, dartCopy); |
| 4315 if (source != librarySource) { |
| 4316 _workManager.add(source, WorkManagerPriority.PRIORITY_PART); |
| 4317 } |
| 4123 if (source == unitSource) { | 4318 if (source == unitSource) { |
| 4124 unitEntry = dartCopy; | 4319 unitEntry = dartCopy; |
| 4125 } | 4320 } |
| 4126 ChangeNoticeImpl notice = getNotice(source); | 4321 ChangeNoticeImpl notice = getNotice(source); |
| 4127 notice.compilationUnit = unit; | 4322 notice.compilationUnit = unit; |
| 4128 notice.setErrors(dartCopy.allErrors, lineInfo); | 4323 notice.setErrors(dartCopy.allErrors, lineInfo); |
| 4129 } | 4324 } |
| 4130 } | 4325 } |
| 4131 } else { | 4326 } else { |
| 4132 PrintStringWriter writer = new PrintStringWriter(); | 4327 PrintStringWriter writer = new PrintStringWriter(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 4144 // sources will be re-analyzed using the up-to-date sources. | 4339 // sources will be re-analyzed using the up-to-date sources. |
| 4145 // | 4340 // |
| 4146 dartCopy.recordResolutionNotInProcess(); | 4341 dartCopy.recordResolutionNotInProcess(); |
| 4147 } else { | 4342 } else { |
| 4148 // | 4343 // |
| 4149 // We could not determine whether the sources were up-to-date
or out-of-date. Mark | 4344 // We could not determine whether the sources were up-to-date
or out-of-date. Mark |
| 4150 // the cache so that we won't attempt to re-analyze the source
s until there's a | 4345 // the cache so that we won't attempt to re-analyze the source
s until there's a |
| 4151 // good chance that we'll be able to do so without error. | 4346 // good chance that we'll be able to do so without error. |
| 4152 // | 4347 // |
| 4153 dartCopy.recordResolutionError(); | 4348 dartCopy.recordResolutionError(); |
| 4349 _cache.remove(source); |
| 4154 } | 4350 } |
| 4155 dartCopy.exception = thrownException; | 4351 dartCopy.exception = thrownException; |
| 4156 _cache.put(source, dartCopy); | 4352 _cache.put(source, dartCopy); |
| 4157 if (source == unitSource) { | 4353 if (source == unitSource) { |
| 4158 unitEntry = dartCopy; | 4354 unitEntry = dartCopy; |
| 4159 } | 4355 } |
| 4160 } else { | 4356 } else { |
| 4161 writer.println(" ${debuggingString(source)}; sourceTime = ${sou
rce.modificationStamp}, no entry"); | 4357 writer.println(" ${debuggingString(source)}; sourceTime = ${sou
rce.modificationStamp}, no entry"); |
| 4162 } | 4358 } |
| 4163 } | 4359 } |
| 4164 } | 4360 } |
| 4165 logInformation(writer.toString()); | 4361 logInformation(writer.toString()); |
| 4166 } | 4362 } |
| 4167 } | 4363 } |
| 4168 } | 4364 } |
| 4169 if (thrownException != null) { | 4365 if (thrownException != null) { |
| 4170 throw thrownException; | 4366 throw thrownException; |
| 4171 } | 4367 } |
| 4172 if (unitEntry == null) { | 4368 if (unitEntry == null) { |
| 4173 unitEntry = getReadableDartEntry(unitSource); | 4369 unitEntry = getReadableDartEntry(unitSource); |
| 4174 if (unitEntry == null) { | 4370 if (unitEntry == null) { |
| 4175 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
unitSource.fullName}"); | 4371 throw new AnalysisException.con1("A Dart file became a non-Dart file: ${
unitSource.fullName}"); |
| 4176 } | 4372 } |
| 4177 } | 4373 } |
| 4178 return unitEntry; | 4374 return unitEntry; |
| 4179 } | 4375 } |
| 4180 | 4376 |
| 4181 /** | 4377 /** |
| 4378 * Record that we have accessed the AST structure associated with the given so
urce. At the moment, |
| 4379 * there is no differentiation between the parsed and resolved forms of the AS
T. |
| 4380 * |
| 4381 * @param source the source whose AST structure was accessed |
| 4382 */ |
| 4383 void accessedAst(Source source) { |
| 4384 { |
| 4385 _cache.accessedAst(source); |
| 4386 } |
| 4387 } |
| 4388 |
| 4389 /** |
| 4182 * Add all of the sources contained in the given source container to the given
list of sources. | 4390 * Add all of the sources contained in the given source container to the given
list of sources. |
| 4183 * | 4391 * |
| 4184 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. | 4392 * Note: This method must only be invoked while we are synchronized on [cacheL
ock]. |
| 4185 * | 4393 * |
| 4186 * @param sources the list to which sources are to be added | 4394 * @param sources the list to which sources are to be added |
| 4187 * @param container the source container containing the sources to be added to
the list | 4395 * @param container the source container containing the sources to be added to
the list |
| 4188 */ | 4396 */ |
| 4189 void addSourcesInContainer(List<Source> sources, SourceContainer container) { | 4397 void addSourcesInContainer(List<Source> sources, SourceContainer container) { |
| 4190 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 4398 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 4191 Source source = entry.getKey(); | 4399 Source source = entry.getKey(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 4220 // The source has changed without the context being notified. Simulate
notification. | 4428 // The source has changed without the context being notified. Simulate
notification. |
| 4221 sourceChanged(source); | 4429 sourceChanged(source); |
| 4222 allTimesMatch = false; | 4430 allTimesMatch = false; |
| 4223 } | 4431 } |
| 4224 } | 4432 } |
| 4225 } | 4433 } |
| 4226 return allTimesMatch; | 4434 return allTimesMatch; |
| 4227 } | 4435 } |
| 4228 | 4436 |
| 4229 /** | 4437 /** |
| 4230 * Given a source for a Dart file, return a cache entry in which the data repr
esented by the given | 4438 * Given a source for a Dart file, return a cache entry in which the state of
the data represented |
| 4231 * descriptor is available. This method assumes that the data can be produced
by resolving the | 4439 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This |
| 4232 * directives in the source if they are not already cached. | 4440 * method assumes that the data can be produced by resolving the directives in
the source if they |
| 4441 * are not already cached. |
| 4233 * | 4442 * |
| 4234 * @param source the source representing the Dart file | 4443 * @param source the source representing the Dart file |
| 4235 * @param dartEntry the cache entry associated with the Dart file | 4444 * @param dartEntry the cache entry associated with the Dart file |
| 4236 * @param descriptor the descriptor representing the data to be returned | 4445 * @param descriptor the descriptor representing the data to be returned |
| 4237 * @return a cache entry containing the required data | 4446 * @return a cache entry containing the required data |
| 4238 * @throws AnalysisException if data could not be returned because the source
could not be | 4447 * @throws AnalysisException if data could not be returned because the source
could not be |
| 4239 * resolved | 4448 * resolved |
| 4240 */ | 4449 */ |
| 4241 DartEntry cacheDartDependencyData(Source source, DartEntry dartEntry, DataDesc
riptor descriptor) { | 4450 DartEntry cacheDartDependencyData(Source source, DartEntry dartEntry, DataDesc
riptor descriptor) { |
| 4242 // | 4451 // |
| 4243 // Check to see whether we already have the information being requested. | 4452 // Check to see whether we already have the information being requested. |
| 4244 // | 4453 // |
| 4245 CacheState state = dartEntry.getState(descriptor); | 4454 CacheState state = dartEntry.getState(descriptor); |
| 4246 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4455 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4247 // | 4456 // |
| 4248 // If not, compute the information. Unless the modification date of the so
urce continues to | 4457 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4249 // change, this loop will eventually terminate. | 4458 // change, this loop will eventually terminate. |
| 4250 // | 4459 // |
| 4251 dartEntry = new ResolveDartDependenciesTask(this, source).perform(_resultR
ecorder) as DartEntry; | 4460 dartEntry = new ResolveDartDependenciesTask(this, source).perform(_resultR
ecorder) as DartEntry; |
| 4252 state = dartEntry.getState(descriptor); | 4461 state = dartEntry.getState(descriptor); |
| 4253 } | 4462 } |
| 4254 return dartEntry; | 4463 return dartEntry; |
| 4255 } | 4464 } |
| 4256 | 4465 |
| 4257 /** | 4466 /** |
| 4258 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 4467 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
| 4259 * the data represented by the given descriptor is available. This method assu
mes that the data | 4468 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or |
| 4260 * can be produced by generating hints for the library if the data is not alre
ady cached. | 4469 * [CacheState#ERROR]. This method assumes that the data can be produced by ge
nerating hints |
| 4470 * for the library if the data is not already cached. |
| 4261 * | 4471 * |
| 4262 * @param unitSource the source representing the Dart file | 4472 * @param unitSource the source representing the Dart file |
| 4263 * @param librarySource the source representing the library containing the Dar
t file | 4473 * @param librarySource the source representing the library containing the Dar
t file |
| 4264 * @param dartEntry the cache entry associated with the Dart file | 4474 * @param dartEntry the cache entry associated with the Dart file |
| 4265 * @param descriptor the descriptor representing the data to be returned | 4475 * @param descriptor the descriptor representing the data to be returned |
| 4266 * @return a cache entry containing the required data | 4476 * @return a cache entry containing the required data |
| 4267 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 4477 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 4268 */ | 4478 */ |
| 4269 DartEntry cacheDartHintData(Source unitSource, Source librarySource, DartEntry
dartEntry, DataDescriptor descriptor) { | 4479 DartEntry cacheDartHintData(Source unitSource, Source librarySource, DartEntry
dartEntry, DataDescriptor descriptor) { |
| 4270 // | 4480 // |
| 4271 // Check to see whether we already have the information being requested. | 4481 // Check to see whether we already have the information being requested. |
| 4272 // | 4482 // |
| 4273 CacheState state = dartEntry.getState2(descriptor, librarySource); | 4483 CacheState state = dartEntry.getState2(descriptor, librarySource); |
| 4274 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4484 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4275 // | 4485 // |
| 4276 // If not, compute the information. Unless the modification date of the so
urce continues to | 4486 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4277 // change, this loop will eventually terminate. | 4487 // change, this loop will eventually terminate. |
| 4278 // | 4488 // |
| 4279 dartEntry = new GenerateDartHintsTask(this, getLibraryElement(librarySourc
e)).perform(_resultRecorder) as DartEntry; | 4489 dartEntry = new GenerateDartHintsTask(this, getLibraryElement(librarySourc
e)).perform(_resultRecorder) as DartEntry; |
| 4280 state = dartEntry.getState2(descriptor, librarySource); | 4490 state = dartEntry.getState2(descriptor, librarySource); |
| 4281 } | 4491 } |
| 4282 return dartEntry; | 4492 return dartEntry; |
| 4283 } | 4493 } |
| 4284 | 4494 |
| 4285 /** | 4495 /** |
| 4286 * Given a source for a Dart file, return a cache entry in which the data repr
esented by the given | 4496 * Given a source for a Dart file, return a cache entry in which the state of
the data represented |
| 4287 * descriptor is available. This method assumes that the data can be produced
by parsing the | 4497 * by the given descriptor is either [CacheState#VALID] or [CacheState#ERROR].
This |
| 4288 * source if it is not already cached. | 4498 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
| 4289 * | 4499 * |
| 4290 * @param source the source representing the Dart file | 4500 * @param source the source representing the Dart file |
| 4291 * @param dartEntry the cache entry associated with the Dart file | 4501 * @param dartEntry the cache entry associated with the Dart file |
| 4292 * @param descriptor the descriptor representing the data to be returned | 4502 * @param descriptor the descriptor representing the data to be returned |
| 4293 * @return a cache entry containing the required data | 4503 * @return a cache entry containing the required data |
| 4294 * @throws AnalysisException if data could not be returned because the source
could not be | 4504 * @throws AnalysisException if data could not be returned because the source
could not be |
| 4295 * resolved | 4505 * resolved |
| 4296 */ | 4506 */ |
| 4297 DartEntry cacheDartParseData(Source source, DartEntry dartEntry, DataDescripto
r descriptor) { | 4507 DartEntry cacheDartParseData(Source source, DartEntry dartEntry, DataDescripto
r descriptor) { |
| 4298 if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 4508 if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4311 // change, this loop will eventually terminate. | 4521 // change, this loop will eventually terminate. |
| 4312 // | 4522 // |
| 4313 dartEntry = new ParseDartTask(this, source).perform(_resultRecorder) as Da
rtEntry; | 4523 dartEntry = new ParseDartTask(this, source).perform(_resultRecorder) as Da
rtEntry; |
| 4314 state = dartEntry.getState(descriptor); | 4524 state = dartEntry.getState(descriptor); |
| 4315 } | 4525 } |
| 4316 return dartEntry; | 4526 return dartEntry; |
| 4317 } | 4527 } |
| 4318 | 4528 |
| 4319 /** | 4529 /** |
| 4320 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 4530 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
| 4321 * the data represented by the given descriptor is available. This method assu
mes that the data | 4531 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or |
| 4322 * can be produced by resolving the source in the context of the library if it
is not already | 4532 * [CacheState#ERROR]. This method assumes that the data can be produced by re
solving the |
| 4323 * cached. | 4533 * source in the context of the library if it is not already cached. |
| 4324 * | 4534 * |
| 4325 * @param unitSource the source representing the Dart file | 4535 * @param unitSource the source representing the Dart file |
| 4326 * @param librarySource the source representing the library containing the Dar
t file | 4536 * @param librarySource the source representing the library containing the Dar
t file |
| 4327 * @param dartEntry the cache entry associated with the Dart file | 4537 * @param dartEntry the cache entry associated with the Dart file |
| 4328 * @param descriptor the descriptor representing the data to be returned | 4538 * @param descriptor the descriptor representing the data to be returned |
| 4329 * @return a cache entry containing the required data | 4539 * @return a cache entry containing the required data |
| 4330 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 4540 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 4331 */ | 4541 */ |
| 4332 DartEntry cacheDartResolutionData(Source unitSource, Source librarySource, Dar
tEntry dartEntry, DataDescriptor descriptor) { | 4542 DartEntry cacheDartResolutionData(Source unitSource, Source librarySource, Dar
tEntry dartEntry, DataDescriptor descriptor) { |
| 4333 // | 4543 // |
| 4334 // Check to see whether we already have the information being requested. | 4544 // Check to see whether we already have the information being requested. |
| 4335 // | 4545 // |
| 4336 CacheState state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.ge
tState(descriptor) : dartEntry.getState2(descriptor, librarySource); | 4546 CacheState state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.ge
tState(descriptor) : dartEntry.getState2(descriptor, librarySource); |
| 4337 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4547 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4338 // | 4548 // |
| 4339 // If not, compute the information. Unless the modification date of the so
urce continues to | 4549 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4340 // change, this loop will eventually terminate. | 4550 // change, this loop will eventually terminate. |
| 4341 // | 4551 // |
| 4342 // TODO(brianwilkerson) As an optimization, if we already have the element
model for the | 4552 // TODO(brianwilkerson) As an optimization, if we already have the element
model for the |
| 4343 // library we can use ResolveDartUnitTask to produce the resolved AST stru
cture much faster. | 4553 // library we can use ResolveDartUnitTask to produce the resolved AST stru
cture much faster. |
| 4344 dartEntry = new ResolveDartLibraryTask(this, unitSource, librarySource).pe
rform(_resultRecorder) as DartEntry; | 4554 dartEntry = new ResolveDartLibraryTask(this, unitSource, librarySource).pe
rform(_resultRecorder) as DartEntry; |
| 4345 state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.getState(de
scriptor) : dartEntry.getState2(descriptor, librarySource); | 4555 state = (identical(descriptor, DartEntry.ELEMENT)) ? dartEntry.getState(de
scriptor) : dartEntry.getState2(descriptor, librarySource); |
| 4346 } | 4556 } |
| 4347 return dartEntry; | 4557 return dartEntry; |
| 4348 } | 4558 } |
| 4349 | 4559 |
| 4350 /** | 4560 /** |
| 4351 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which | 4561 * Given a source for a Dart file and the library that contains it, return a c
ache entry in which |
| 4352 * the data represented by the given descriptor is available. This method assu
mes that the data | 4562 * the state of the data represented by the given descriptor is either [CacheS
tate#VALID] or |
| 4353 * can be produced by verifying the source in the given library if the data is
not already cached. | 4563 * [CacheState#ERROR]. This method assumes that the data can be produced by ve
rifying the |
| 4564 * source in the given library if the data is not already cached. |
| 4354 * | 4565 * |
| 4355 * @param unitSource the source representing the Dart file | 4566 * @param unitSource the source representing the Dart file |
| 4356 * @param librarySource the source representing the library containing the Dar
t file | 4567 * @param librarySource the source representing the library containing the Dar
t file |
| 4357 * @param dartEntry the cache entry associated with the Dart file | 4568 * @param dartEntry the cache entry associated with the Dart file |
| 4358 * @param descriptor the descriptor representing the data to be returned | 4569 * @param descriptor the descriptor representing the data to be returned |
| 4359 * @return a cache entry containing the required data | 4570 * @return a cache entry containing the required data |
| 4360 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 4571 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 4361 */ | 4572 */ |
| 4362 DartEntry cacheDartVerificationData(Source unitSource, Source librarySource, D
artEntry dartEntry, DataDescriptor descriptor) { | 4573 DartEntry cacheDartVerificationData(Source unitSource, Source librarySource, D
artEntry dartEntry, DataDescriptor descriptor) { |
| 4363 // | 4574 // |
| 4364 // Check to see whether we already have the information being requested. | 4575 // Check to see whether we already have the information being requested. |
| 4365 // | 4576 // |
| 4366 CacheState state = dartEntry.getState2(descriptor, librarySource); | 4577 CacheState state = dartEntry.getState2(descriptor, librarySource); |
| 4367 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4578 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4368 // | 4579 // |
| 4369 // If not, compute the information. Unless the modification date of the so
urce continues to | 4580 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4370 // change, this loop will eventually terminate. | 4581 // change, this loop will eventually terminate. |
| 4371 // | 4582 // |
| 4372 dartEntry = new GenerateDartErrorsTask(this, unitSource, getLibraryElement
(librarySource)).perform(_resultRecorder) as DartEntry; | 4583 dartEntry = new GenerateDartErrorsTask(this, unitSource, getLibraryElement
(librarySource)).perform(_resultRecorder) as DartEntry; |
| 4373 state = dartEntry.getState2(descriptor, librarySource); | 4584 state = dartEntry.getState2(descriptor, librarySource); |
| 4374 } | 4585 } |
| 4375 return dartEntry; | 4586 return dartEntry; |
| 4376 } | 4587 } |
| 4377 | 4588 |
| 4378 /** | 4589 /** |
| 4379 * Given a source for an HTML file, return a cache entry in which all of the d
ata represented by | 4590 * Given a source for an HTML file, return a cache entry in which all of the d
ata represented by |
| 4380 * the given descriptors is available. This method assumes that the data can b
e produced by | 4591 * the state of the given descriptors is either [CacheState#VALID] or |
| 4381 * parsing the source if it is not already cached. | 4592 * [CacheState#ERROR]. This method assumes that the data can be produced by pa
rsing the |
| 4593 * source if it is not already cached. |
| 4382 * | 4594 * |
| 4383 * @param source the source representing the HTML file | 4595 * @param source the source representing the HTML file |
| 4384 * @param htmlEntry the cache entry associated with the HTML file | 4596 * @param htmlEntry the cache entry associated with the HTML file |
| 4385 * @param descriptor the descriptor representing the data to be returned | 4597 * @param descriptor the descriptor representing the data to be returned |
| 4386 * @return a cache entry containing the required data | 4598 * @return a cache entry containing the required data |
| 4387 * @throws AnalysisException if data could not be returned because the source
could not be | 4599 * @throws AnalysisException if data could not be returned because the source
could not be |
| 4388 * resolved | 4600 * resolved |
| 4389 */ | 4601 */ |
| 4390 HtmlEntry cacheHtmlParseData(Source source, HtmlEntry htmlEntry, DataDescripto
r descriptor) { | 4602 HtmlEntry cacheHtmlParseData(Source source, HtmlEntry htmlEntry, DataDescripto
r descriptor) { |
| 4603 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 4604 ht.HtmlUnit unit = htmlEntry.anyParsedUnit; |
| 4605 if (unit != null) { |
| 4606 return htmlEntry; |
| 4607 } |
| 4608 } |
| 4391 // | 4609 // |
| 4392 // Check to see whether we already have the information being requested. | 4610 // Check to see whether we already have the information being requested. |
| 4393 // | 4611 // |
| 4394 CacheState state = htmlEntry.getState(descriptor); | 4612 CacheState state = htmlEntry.getState(descriptor); |
| 4395 while (state != CacheState.ERROR && state != CacheState.VALID) { | 4613 while (state != CacheState.ERROR && state != CacheState.VALID) { |
| 4396 // | 4614 // |
| 4397 // If not, compute the information. Unless the modification date of the so
urce continues to | 4615 // If not, compute the information. Unless the modification date of the so
urce continues to |
| 4398 // change, this loop will eventually terminate. | 4616 // change, this loop will eventually terminate. |
| 4399 // | 4617 // |
| 4400 htmlEntry = new ParseHtmlTask(this, source).perform(_resultRecorder) as Ht
mlEntry; | 4618 htmlEntry = new ParseHtmlTask(this, source).perform(_resultRecorder) as Ht
mlEntry; |
| 4401 state = htmlEntry.getState(descriptor); | 4619 state = htmlEntry.getState(descriptor); |
| 4402 } | 4620 } |
| 4403 return htmlEntry; | 4621 return htmlEntry; |
| 4404 } | 4622 } |
| 4405 | 4623 |
| 4406 /** | 4624 /** |
| 4407 * Given a source for an HTML file, return a cache entry in which the the data
represented by the | 4625 * Given a source for an HTML file, return a cache entry in which the state of
the data |
| 4408 * given descriptor is available. This method assumes that the data can be pro
duced by resolving | 4626 * represented by the given descriptor is either [CacheState#VALID] or |
| 4409 * the source if it is not already cached. | 4627 * [CacheState#ERROR]. This method assumes that the data can be produced by re
solving the |
| 4628 * source if it is not already cached. |
| 4410 * | 4629 * |
| 4411 * @param source the source representing the HTML file | 4630 * @param source the source representing the HTML file |
| 4412 * @param dartEntry the cache entry associated with the HTML file | 4631 * @param dartEntry the cache entry associated with the HTML file |
| 4413 * @param descriptor the descriptor representing the data to be returned | 4632 * @param descriptor the descriptor representing the data to be returned |
| 4414 * @return a cache entry containing the required data | 4633 * @return a cache entry containing the required data |
| 4415 * @throws AnalysisException if data could not be returned because the source
could not be | 4634 * @throws AnalysisException if data could not be returned because the source
could not be |
| 4416 * resolved | 4635 * resolved |
| 4417 */ | 4636 */ |
| 4418 HtmlEntry cacheHtmlResolutionData(Source source, HtmlEntry htmlEntry, DataDesc
riptor descriptor) { | 4637 HtmlEntry cacheHtmlResolutionData(Source source, HtmlEntry htmlEntry, DataDesc
riptor descriptor) { |
| 4419 // | 4638 // |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4592 * | 4811 * |
| 4593 * @param source the source representing the Dart file | 4812 * @param source the source representing the Dart file |
| 4594 * @param dartEntry the cache entry associated with the Dart file | 4813 * @param dartEntry the cache entry associated with the Dart file |
| 4595 * @param descriptor the descriptor representing the data to be returned | 4814 * @param descriptor the descriptor representing the data to be returned |
| 4596 * @return the requested data about the given source | 4815 * @return the requested data about the given source |
| 4597 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 4816 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 4598 */ | 4817 */ |
| 4599 Object getDartParseData(Source source, DartEntry dartEntry, DataDescriptor des
criptor) { | 4818 Object getDartParseData(Source source, DartEntry dartEntry, DataDescriptor des
criptor) { |
| 4600 dartEntry = cacheDartParseData(source, dartEntry, descriptor); | 4819 dartEntry = cacheDartParseData(source, dartEntry, descriptor); |
| 4601 if (identical(descriptor, DartEntry.PARSED_UNIT)) { | 4820 if (identical(descriptor, DartEntry.PARSED_UNIT)) { |
| 4821 accessedAst(source); |
| 4602 return dartEntry.anyParsedCompilationUnit; | 4822 return dartEntry.anyParsedCompilationUnit; |
| 4603 } | 4823 } |
| 4604 return dartEntry.getValue(descriptor); | 4824 return dartEntry.getValue(descriptor); |
| 4605 } | 4825 } |
| 4606 | 4826 |
| 4607 /** | 4827 /** |
| 4608 * Given a source for a Dart file, return the data represented by the given de
scriptor that is | 4828 * Given a source for a Dart file, return the data represented by the given de
scriptor that is |
| 4609 * associated with that source, or the given default value if the source is no
t a Dart file. This | 4829 * associated with that source, or the given default value if the source is no
t a Dart file. This |
| 4610 * method assumes that the data can be produced by parsing the source if it is
not already cached. | 4830 * method assumes that the data can be produced by parsing the source if it is
not already cached. |
| 4611 * | 4831 * |
| (...skipping 21 matching lines...) Expand all Loading... |
| 4633 * @param dartEntry the entry representing the Dart file | 4853 * @param dartEntry the entry representing the Dart file |
| 4634 * @param descriptor the descriptor representing the data to be returned | 4854 * @param descriptor the descriptor representing the data to be returned |
| 4635 * @return the requested data about the given source | 4855 * @return the requested data about the given source |
| 4636 * @throws AnalysisException if data could not be returned because the source
could not be | 4856 * @throws AnalysisException if data could not be returned because the source
could not be |
| 4637 * resolved | 4857 * resolved |
| 4638 */ | 4858 */ |
| 4639 Object getDartResolutionData(Source unitSource, Source librarySource, DartEntr
y dartEntry, DataDescriptor descriptor) { | 4859 Object getDartResolutionData(Source unitSource, Source librarySource, DartEntr
y dartEntry, DataDescriptor descriptor) { |
| 4640 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, de
scriptor); | 4860 dartEntry = cacheDartResolutionData(unitSource, librarySource, dartEntry, de
scriptor); |
| 4641 if (identical(descriptor, DartEntry.ELEMENT)) { | 4861 if (identical(descriptor, DartEntry.ELEMENT)) { |
| 4642 return dartEntry.getValue(descriptor); | 4862 return dartEntry.getValue(descriptor); |
| 4863 } else if (identical(descriptor, DartEntry.RESOLVED_UNIT)) { |
| 4864 accessedAst(unitSource); |
| 4643 } | 4865 } |
| 4644 return dartEntry.getValue2(descriptor, librarySource); | 4866 return dartEntry.getValue2(descriptor, librarySource); |
| 4645 } | 4867 } |
| 4646 | 4868 |
| 4647 /** | 4869 /** |
| 4648 * Given a source for a Dart file and the library that contains it, return the
data represented by | 4870 * Given a source for a Dart file and the library that contains it, return the
data represented by |
| 4649 * the given descriptor that is associated with that source, or the given defa
ult value if the | 4871 * the given descriptor that is associated with that source, or the given defa
ult value if the |
| 4650 * source is not a Dart file. This method assumes that the data can be produce
d by resolving the | 4872 * source is not a Dart file. This method assumes that the data can be produce
d by resolving the |
| 4651 * source in the context of the library if it is not already cached. | 4873 * source in the context of the library if it is not already cached. |
| 4652 * | 4874 * |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4694 * @param defaultValue the value to be returned if the source is not an HTML f
ile | 4916 * @param defaultValue the value to be returned if the source is not an HTML f
ile |
| 4695 * @return the requested data about the given source | 4917 * @return the requested data about the given source |
| 4696 * @throws AnalysisException if data could not be returned because the source
could not be parsed | 4918 * @throws AnalysisException if data could not be returned because the source
could not be parsed |
| 4697 */ | 4919 */ |
| 4698 Object getHtmlParseData(Source source, DataDescriptor descriptor, Object defau
ltValue) { | 4920 Object getHtmlParseData(Source source, DataDescriptor descriptor, Object defau
ltValue) { |
| 4699 HtmlEntry htmlEntry = getReadableHtmlEntry(source); | 4921 HtmlEntry htmlEntry = getReadableHtmlEntry(source); |
| 4700 if (htmlEntry == null) { | 4922 if (htmlEntry == null) { |
| 4701 return defaultValue; | 4923 return defaultValue; |
| 4702 } | 4924 } |
| 4703 htmlEntry = cacheHtmlParseData(source, htmlEntry, descriptor); | 4925 htmlEntry = cacheHtmlParseData(source, htmlEntry, descriptor); |
| 4926 if (identical(descriptor, HtmlEntry.PARSED_UNIT)) { |
| 4927 accessedAst(source); |
| 4928 return htmlEntry.anyParsedUnit; |
| 4929 } |
| 4704 return htmlEntry.getValue(descriptor); | 4930 return htmlEntry.getValue(descriptor); |
| 4705 } | 4931 } |
| 4706 | 4932 |
| 4707 /** | 4933 /** |
| 4708 * Given a source for an HTML file, return the data represented by the given d
escriptor that is | 4934 * Given a source for an HTML file, return the data represented by the given d
escriptor that is |
| 4709 * associated with that source, or the given default value if the source is no
t an HTML file. This | 4935 * associated with that source, or the given default value if the source is no
t an HTML file. This |
| 4710 * method assumes that the data can be produced by resolving the source if it
is not already | 4936 * method assumes that the data can be produced by resolving the source if it
is not already |
| 4711 * cached. | 4937 * cached. |
| 4712 * | 4938 * |
| 4713 * @param source the source representing the HTML file | 4939 * @param source the source representing the HTML file |
| (...skipping 18 matching lines...) Expand all Loading... |
| 4732 * | 4958 * |
| 4733 * @param source the source representing the HTML file | 4959 * @param source the source representing the HTML file |
| 4734 * @param htmlEntry the entry representing the HTML file | 4960 * @param htmlEntry the entry representing the HTML file |
| 4735 * @param descriptor the descriptor representing the data to be returned | 4961 * @param descriptor the descriptor representing the data to be returned |
| 4736 * @return the requested data about the given source | 4962 * @return the requested data about the given source |
| 4737 * @throws AnalysisException if data could not be returned because the source
could not be | 4963 * @throws AnalysisException if data could not be returned because the source
could not be |
| 4738 * resolved | 4964 * resolved |
| 4739 */ | 4965 */ |
| 4740 Object getHtmlResolutionData2(Source source, HtmlEntry htmlEntry, DataDescript
or descriptor) { | 4966 Object getHtmlResolutionData2(Source source, HtmlEntry htmlEntry, DataDescript
or descriptor) { |
| 4741 htmlEntry = cacheHtmlResolutionData(source, htmlEntry, descriptor); | 4967 htmlEntry = cacheHtmlResolutionData(source, htmlEntry, descriptor); |
| 4968 if (identical(descriptor, HtmlEntry.RESOLVED_UNIT)) { |
| 4969 accessedAst(source); |
| 4970 } |
| 4742 return htmlEntry.getValue(descriptor); | 4971 return htmlEntry.getValue(descriptor); |
| 4743 } | 4972 } |
| 4744 | 4973 |
| 4745 /** | 4974 /** |
| 4746 * Look through the cache for a task that needs to be performed. Return the ta
sk that was found, | 4975 * Look through the cache for a task that needs to be performed. Return the ta
sk that was found, |
| 4747 * or `null` if there is no more work to be done. | 4976 * or `null` if there is no more work to be done. |
| 4748 * | 4977 * |
| 4749 * @return the next task that needs to be performed | 4978 * @return the next task that needs to be performed |
| 4750 */ | 4979 */ |
| 4751 AnalysisTask get nextTaskAnalysisTask { | 4980 AnalysisTask get nextAnalysisTask { |
| 4752 { | 4981 { |
| 4753 bool hintsEnabled = _options.hint; | 4982 bool hintsEnabled = _options.hint; |
| 4754 // | 4983 // |
| 4755 // Look for incremental analysis | 4984 // Look for incremental analysis |
| 4756 // | 4985 // |
| 4757 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork
()) { | 4986 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork
()) { |
| 4758 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalys
isCache); | 4987 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalys
isCache); |
| 4759 _incrementalAnalysisCache = null; | 4988 _incrementalAnalysisCache = null; |
| 4760 return task; | 4989 return task; |
| 4761 } | 4990 } |
| 4762 // | 4991 // |
| 4763 // Look for a priority source that needs to be analyzed. | 4992 // Look for a priority source that needs to be analyzed. |
| 4764 // | 4993 // |
| 4765 for (Source source in _priorityOrder) { | 4994 for (Source source in _priorityOrder) { |
| 4766 AnalysisTask task = getNextTaskAnalysisTask2(source, _cache.get(source),
true, hintsEnabled); | 4995 AnalysisTask task = getNextAnalysisTask2(source, _cache.get(source), tru
e, hintsEnabled); |
| 4767 if (task != null) { | 4996 if (task != null) { |
| 4768 return task; | 4997 return task; |
| 4769 } | 4998 } |
| 4770 } | 4999 } |
| 4771 // | 5000 // |
| 4772 // Look for a non-priority source that needs to be analyzed. | 5001 // Look for a non-priority source that needs to be analyzed. |
| 4773 // | 5002 // |
| 4774 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 5003 Source source = _workManager.nextSource; |
| 4775 AnalysisTask task = getNextTaskAnalysisTask2(entry.getKey(), entry.getVa
lue(), false, hintsEnabled); | 5004 while (source != null) { |
| 5005 AnalysisTask task = getNextAnalysisTask2(source, _cache.get(source), fal
se, hintsEnabled); |
| 4776 if (task != null) { | 5006 if (task != null) { |
| 4777 return task; | 5007 return task; |
| 4778 } | 5008 } |
| 5009 _workManager.remove(source); |
| 5010 source = _workManager.nextSource; |
| 4779 } | 5011 } |
| 4780 // | 5012 // // |
| 4781 // Look for HTML sources that should be resolved as Angular templates. | 5013 // // Look for a non-priority source that needs to be analyzed and wa
s missed by the loop above. |
| 4782 // | 5014 // // |
| 4783 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 5015 // for (Map.Entry<Source, SourceEntry> entry : cache.entrySet()) { |
| 4784 SourceEntry sourceEntry = entry.getValue(); | 5016 // source = entry.getKey(); |
| 4785 if (sourceEntry is DartEntry) { | 5017 // AnalysisTask task = getNextAnalysisTask(source, entry.getValue()
, false, hintsEnabled); |
| 4786 DartEntry dartEntry = sourceEntry; | 5018 // if (task != null) { |
| 4787 List<AngularElement> angularElements = dartEntry.getValue(DartEntry.AN
GULAR_ELEMENTS); | 5019 // System.out.println("Failed to analyze " + source.getFullName()
); |
| 4788 for (AngularElement angularElement in angularElements) { | 5020 // return task; |
| 4789 // prepare Angular component | 5021 // } |
| 4790 if (angularElement is! AngularComponentElement) { | 5022 // } |
| 4791 continue; | |
| 4792 } | |
| 4793 AngularComponentElement component = angularElement as AngularCompone
ntElement; | |
| 4794 // prepare HTML template | |
| 4795 Source templateSource = component.templateSource; | |
| 4796 if (templateSource == null) { | |
| 4797 continue; | |
| 4798 } | |
| 4799 // prepare HTML template entry | |
| 4800 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource); | |
| 4801 if (htmlEntry == null) { | |
| 4802 continue; | |
| 4803 } | |
| 4804 // we need an entry with invalid Angular errors | |
| 4805 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR
_ERRORS); | |
| 4806 if (angularErrorsState != CacheState.INVALID) { | |
| 4807 continue; | |
| 4808 } | |
| 4809 // do Angular component resolution | |
| 4810 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | |
| 4811 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS); | |
| 4812 _cache.put(templateSource, htmlCopy); | |
| 4813 return new ResolveAngularComponentTemplateTask(this, templateSource,
component, angularElements); | |
| 4814 } | |
| 4815 } | |
| 4816 } | |
| 4817 return null; | 5023 return null; |
| 4818 } | 5024 } |
| 4819 } | 5025 } |
| 4820 | 5026 |
| 4821 /** | 5027 /** |
| 4822 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the | 5028 * Look at the given source to see whether a task needs to be performed relate
d to it. Return the |
| 4823 * task that should be performed, or `null` if there is no more work to be don
e for the | 5029 * task that should be performed, or `null` if there is no more work to be don
e for the |
| 4824 * source. | 5030 * source. |
| 4825 * | 5031 * |
| 4826 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5032 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 4827 * | 5033 * |
| 4828 * @param source the source to be checked | 5034 * @param source the source to be checked |
| 4829 * @param sourceEntry the cache entry associated with the source | 5035 * @param sourceEntry the cache entry associated with the source |
| 4830 * @param isPriority `true` if the source is a priority source | 5036 * @param isPriority `true` if the source is a priority source |
| 4831 * @param hintsEnabled `true` if hints are currently enabled | 5037 * @param hintsEnabled `true` if hints are currently enabled |
| 4832 * @return the next task that needs to be performed for the given source | 5038 * @return the next task that needs to be performed for the given source |
| 4833 */ | 5039 */ |
| 4834 AnalysisTask getNextTaskAnalysisTask2(Source source, SourceEntry sourceEntry,
bool isPriority, bool hintsEnabled) { | 5040 AnalysisTask getNextAnalysisTask2(Source source, SourceEntry sourceEntry, bool
isPriority, bool hintsEnabled) { |
| 4835 if (sourceEntry is DartEntry) { | 5041 if (sourceEntry is DartEntry) { |
| 4836 DartEntry dartEntry = sourceEntry; | 5042 DartEntry dartEntry = sourceEntry; |
| 4837 if (!source.exists()) { | |
| 4838 DartEntryImpl dartCopy = dartEntry.writableCopy; | |
| 4839 dartCopy.recordParseError(); | |
| 4840 dartCopy.exception = new AnalysisException.con1("Source does not exist")
; | |
| 4841 _cache.put(source, dartCopy); | |
| 4842 return null; | |
| 4843 } | |
| 4844 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); | 5043 CacheState parseErrorsState = dartEntry.getState(DartEntry.PARSE_ERRORS); |
| 4845 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { | 5044 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { |
| 4846 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5045 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4847 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS); | 5046 dartCopy.setState(DartEntry.PARSE_ERRORS, CacheState.IN_PROCESS); |
| 4848 _cache.put(source, dartCopy); | 5047 _cache.put(source, dartCopy); |
| 4849 return new ParseDartTask(this, source); | 5048 return new ParseDartTask(this, source); |
| 4850 } | 5049 } |
| 4851 if (isPriority && parseErrorsState != CacheState.ERROR) { | 5050 if (isPriority && parseErrorsState != CacheState.ERROR) { |
| 4852 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit; | 5051 CompilationUnit parseUnit = dartEntry.anyParsedCompilationUnit; |
| 4853 if (parseUnit == null) { | 5052 if (parseUnit == null) { |
| 4854 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5053 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4855 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.IN_PROCESS); | 5054 dartCopy.setState(DartEntry.PARSED_UNIT, CacheState.IN_PROCESS); |
| 4856 _cache.put(source, dartCopy); | 5055 _cache.put(source, dartCopy); |
| 4857 return new ParseDartTask(this, source); | 5056 return new ParseDartTask(this, source); |
| 4858 } | 5057 } |
| 4859 } | 5058 } |
| 4860 CacheState exportState = dartEntry.getState(DartEntry.EXPORTED_LIBRARIES); | 5059 CacheState exportState = dartEntry.getState(DartEntry.EXPORTED_LIBRARIES); |
| 4861 if (identical(exportState, CacheState.INVALID) || (isPriority && identical
(exportState, CacheState.FLUSHED))) { | 5060 if (identical(exportState, CacheState.INVALID) || (isPriority && identical
(exportState, CacheState.FLUSHED))) { |
| 4862 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5061 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 4863 dartCopy.setState(DartEntry.EXPORTED_LIBRARIES, CacheState.IN_PROCESS); | 5062 dartCopy.setState(DartEntry.EXPORTED_LIBRARIES, CacheState.IN_PROCESS); |
| 4864 _cache.put(source, dartCopy); | 5063 _cache.put(source, dartCopy); |
| 4865 return new ResolveDartDependenciesTask(this, source); | 5064 return new ResolveDartDependenciesTask(this, source); |
| 4866 } | 5065 } |
| 4867 for (Source librarySource in getLibrariesContaining(source)) { | 5066 List<Source> librariesContaining = dartEntry.getValue(DartEntry.CONTAINING
_LIBRARIES); |
| 5067 for (Source librarySource in librariesContaining) { |
| 4868 SourceEntry libraryEntry = _cache.get(librarySource); | 5068 SourceEntry libraryEntry = _cache.get(librarySource); |
| 4869 if (libraryEntry is DartEntry) { | 5069 if (libraryEntry is DartEntry) { |
| 4870 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); | 5070 CacheState elementState = libraryEntry.getState(DartEntry.ELEMENT); |
| 4871 if (identical(elementState, CacheState.INVALID) || (isPriority && iden
tical(elementState, CacheState.FLUSHED))) { | 5071 if (identical(elementState, CacheState.INVALID) || (isPriority && iden
tical(elementState, CacheState.FLUSHED))) { |
| 4872 DartEntryImpl libraryCopy = libraryEntry.writableCopy; | 5072 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
| 4873 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); | 5073 libraryCopy.setState(DartEntry.ELEMENT, CacheState.IN_PROCESS); |
| 4874 _cache.put(librarySource, libraryCopy); | 5074 _cache.put(librarySource, libraryCopy); |
| 4875 return new ResolveDartLibraryTask(this, source, librarySource); | 5075 return new ResolveDartLibraryTask(this, source, librarySource); |
| 4876 } | 5076 } |
| 4877 CacheState resolvedUnitState = dartEntry.getState2(DartEntry.RESOLVED_
UNIT, librarySource); | 5077 CacheState resolvedUnitState = dartEntry.getState2(DartEntry.RESOLVED_
UNIT, librarySource); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 4908 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.IN
_PROCESS); | 5108 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.IN
_PROCESS); |
| 4909 _cache.put(source, dartCopy); | 5109 _cache.put(source, dartCopy); |
| 4910 return new GenerateDartHintsTask(this, libraryElement); | 5110 return new GenerateDartHintsTask(this, libraryElement); |
| 4911 } | 5111 } |
| 4912 } | 5112 } |
| 4913 } | 5113 } |
| 4914 } | 5114 } |
| 4915 } | 5115 } |
| 4916 } else if (sourceEntry is HtmlEntry) { | 5116 } else if (sourceEntry is HtmlEntry) { |
| 4917 HtmlEntry htmlEntry = sourceEntry; | 5117 HtmlEntry htmlEntry = sourceEntry; |
| 4918 if (!source.exists()) { | 5118 CacheState parseErrorsState = htmlEntry.getState(HtmlEntry.PARSE_ERRORS); |
| 4919 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5119 if (identical(parseErrorsState, CacheState.INVALID) || (isPriority && iden
tical(parseErrorsState, CacheState.FLUSHED))) { |
| 4920 htmlCopy.recordParseError(); | 5120 HtmlEntryImpl dartCopy = htmlEntry.writableCopy; |
| 4921 htmlCopy.exception = new AnalysisException.con1("Source does not exist")
; | 5121 dartCopy.setState(HtmlEntry.PARSE_ERRORS, CacheState.IN_PROCESS); |
| 4922 _cache.put(source, htmlCopy); | 5122 _cache.put(source, dartCopy); |
| 4923 return null; | |
| 4924 } | |
| 4925 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); | |
| 4926 if (identical(parsedUnitState, CacheState.INVALID) || (isPriority && ident
ical(parsedUnitState, CacheState.FLUSHED))) { | |
| 4927 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | |
| 4928 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.IN_PROCESS); | |
| 4929 _cache.put(source, htmlCopy); | |
| 4930 return new ParseHtmlTask(this, source); | 5123 return new ParseHtmlTask(this, source); |
| 4931 } | 5124 } |
| 4932 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT); | 5125 if (isPriority && parseErrorsState != CacheState.ERROR) { |
| 4933 if (identical(elementState, CacheState.INVALID) || (isPriority && identica
l(elementState, CacheState.FLUSHED))) { | 5126 ht.HtmlUnit parsedUnit = htmlEntry.anyParsedUnit; |
| 5127 if (parsedUnit == null) { |
| 5128 HtmlEntryImpl dartCopy = htmlEntry.writableCopy; |
| 5129 dartCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.IN_PROCESS); |
| 5130 _cache.put(source, dartCopy); |
| 5131 return new ParseHtmlTask(this, source); |
| 5132 } |
| 5133 } |
| 5134 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; |
| 5135 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { |
| 4934 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5136 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 4935 htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.IN_PROCESS); | 5137 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.IN_PROCESS); |
| 4936 _cache.put(source, htmlCopy); | 5138 _cache.put(source, htmlCopy); |
| 4937 return new ResolveHtmlTask(this, source); | 5139 return new ResolveHtmlTask(this, source); |
| 4938 } | 5140 } |
| 5141 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERROR
S); |
| 5142 if (identical(angularErrorsState, CacheState.INVALID)) { |
| 5143 AngularApplicationInfo entryInfo = htmlEntry.getValue(HtmlEntry.ANGULAR_
ENTRY); |
| 5144 if (entryInfo != null) { |
| 5145 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5146 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS); |
| 5147 _cache.put(source, htmlCopy); |
| 5148 return new ResolveAngularEntryHtmlTask(this, source, entryInfo); |
| 5149 } |
| 5150 AngularApplicationInfo applicationInfo = htmlEntry.getValue(HtmlEntry.AN
GULAR_APPLICATION); |
| 5151 if (applicationInfo != null) { |
| 5152 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANGUL
AR_COMPONENT); |
| 5153 if (component != null) { |
| 5154 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5155 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.IN_PROCESS); |
| 5156 _cache.put(source, htmlCopy); |
| 5157 return new ResolveAngularComponentTemplateTask(this, source, compone
nt, applicationInfo); |
| 5158 } |
| 5159 } |
| 5160 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5161 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS); |
| 5162 _cache.put(source, htmlCopy); |
| 5163 } |
| 4939 } | 5164 } |
| 4940 return null; | 5165 return null; |
| 4941 } | 5166 } |
| 4942 | 5167 |
| 4943 /** | 5168 /** |
| 4944 * Return a change notice for the given source, creating one if one does not a
lready exist. | 5169 * Return a change notice for the given source, creating one if one does not a
lready exist. |
| 4945 * | 5170 * |
| 4946 * @param source the source for which changes are being reported | 5171 * @param source the source for which changes are being reported |
| 4947 * @return a change notice for the given source | 5172 * @return a change notice for the given source |
| 4948 */ | 5173 */ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4962 * @param source the source for which a cache entry is being sought | 5187 * @param source the source for which a cache entry is being sought |
| 4963 * @return the source cache entry associated with the given source | 5188 * @return the source cache entry associated with the given source |
| 4964 */ | 5189 */ |
| 4965 DartEntry getReadableDartEntry(Source source) { | 5190 DartEntry getReadableDartEntry(Source source) { |
| 4966 { | 5191 { |
| 4967 SourceEntry sourceEntry = _cache.get(source); | 5192 SourceEntry sourceEntry = _cache.get(source); |
| 4968 if (sourceEntry == null) { | 5193 if (sourceEntry == null) { |
| 4969 sourceEntry = createSourceEntry(source); | 5194 sourceEntry = createSourceEntry(source); |
| 4970 } | 5195 } |
| 4971 if (sourceEntry is DartEntry) { | 5196 if (sourceEntry is DartEntry) { |
| 4972 _cache.accessed(source); | |
| 4973 return sourceEntry as DartEntry; | 5197 return sourceEntry as DartEntry; |
| 4974 } | 5198 } |
| 4975 return null; | 5199 return null; |
| 4976 } | 5200 } |
| 4977 } | 5201 } |
| 4978 | 5202 |
| 4979 /** | 5203 /** |
| 4980 * Return the cache entry associated with the given source, or `null` if the s
ource is not | 5204 * Return the cache entry associated with the given source, or `null` if the s
ource is not |
| 4981 * an HTML file. | 5205 * an HTML file. |
| 4982 * | 5206 * |
| 4983 * @param source the source for which a cache entry is being sought | 5207 * @param source the source for which a cache entry is being sought |
| 4984 * @return the source cache entry associated with the given source | 5208 * @return the source cache entry associated with the given source |
| 4985 */ | 5209 */ |
| 4986 HtmlEntry getReadableHtmlEntry(Source source) { | 5210 HtmlEntry getReadableHtmlEntry(Source source) { |
| 4987 { | 5211 { |
| 4988 SourceEntry sourceEntry = _cache.get(source); | 5212 SourceEntry sourceEntry = _cache.get(source); |
| 4989 if (sourceEntry == null) { | 5213 if (sourceEntry == null) { |
| 4990 sourceEntry = createSourceEntry(source); | 5214 sourceEntry = createSourceEntry(source); |
| 4991 } | 5215 } |
| 4992 if (sourceEntry is HtmlEntry) { | 5216 if (sourceEntry is HtmlEntry) { |
| 4993 _cache.accessed(source); | |
| 4994 return sourceEntry as HtmlEntry; | 5217 return sourceEntry as HtmlEntry; |
| 4995 } | 5218 } |
| 4996 return null; | 5219 return null; |
| 4997 } | 5220 } |
| 4998 } | 5221 } |
| 4999 | 5222 |
| 5000 /** | 5223 /** |
| 5001 * Return the cache entry associated with the given source, or `null` if there
is no entry | 5224 * Return the cache entry associated with the given source, or `null` if there
is no entry |
| 5002 * associated with the source. | 5225 * associated with the source. |
| 5003 * | 5226 * |
| 5004 * @param source the source for which a cache entry is being sought | 5227 * @param source the source for which a cache entry is being sought |
| 5005 * @return the source cache entry associated with the given source | 5228 * @return the source cache entry associated with the given source |
| 5006 */ | 5229 */ |
| 5007 SourceEntry getReadableSourceEntry(Source source) { | 5230 SourceEntry getReadableSourceEntry(Source source) { |
| 5008 { | 5231 { |
| 5009 SourceEntry sourceEntry = _cache.get(source); | 5232 SourceEntry sourceEntry = _cache.get(source); |
| 5010 if (sourceEntry == null) { | 5233 if (sourceEntry == null) { |
| 5011 sourceEntry = createSourceEntry(source); | 5234 sourceEntry = createSourceEntry(source); |
| 5012 } | 5235 } |
| 5013 if (sourceEntry != null) { | |
| 5014 _cache.accessed(source); | |
| 5015 } | |
| 5016 return sourceEntry; | 5236 return sourceEntry; |
| 5017 } | 5237 } |
| 5018 } | 5238 } |
| 5019 | 5239 |
| 5020 /** | 5240 /** |
| 5021 * Return an array containing all of the sources known to this context that ha
ve the given kind. | 5241 * Return an array containing all of the sources known to this context that ha
ve the given kind. |
| 5022 * | 5242 * |
| 5023 * @param kind the kind of sources to be returned | 5243 * @param kind the kind of sources to be returned |
| 5024 * @return all of the sources known to this context that have the given kind | 5244 * @return all of the sources known to this context that have the given kind |
| 5025 */ | 5245 */ |
| 5026 List<Source> getSources(SourceKind kind) { | 5246 List<Source> getSources(SourceKind kind) { |
| 5027 List<Source> sources = new List<Source>(); | 5247 List<Source> sources = new List<Source>(); |
| 5028 { | 5248 { |
| 5029 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 5249 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 5030 if (identical(entry.getValue().kind, kind)) { | 5250 if (identical(entry.getValue().kind, kind)) { |
| 5031 sources.add(entry.getKey()); | 5251 sources.add(entry.getKey()); |
| 5032 } | 5252 } |
| 5033 } | 5253 } |
| 5034 } | 5254 } |
| 5035 return new List.from(sources); | 5255 return new List.from(sources); |
| 5036 } | 5256 } |
| 5037 | 5257 |
| 5038 /** | 5258 /** |
| 5039 * Look at the given source to see whether a task needs to be performed relate
d to it. If so, add | 5259 * Look at the given source to see whether a task needs to be performed relate
d to it. If so, add |
| 5040 * the source to the set of sources that need to be processed. This method dup
licates, and must | 5260 * the source to the set of sources that need to be processed. This method dup
licates, and must |
| 5041 * therefore be kept in sync with, | 5261 * therefore be kept in sync with, |
| 5042 * [getNextTaskAnalysisTask]. This method is | 5262 * [getNextAnalysisTask]. This method is intended to |
| 5043 * intended to be used for testing purposes only. | 5263 * be used for testing purposes only. |
| 5044 * | 5264 * |
| 5045 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5265 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5046 * | 5266 * |
| 5047 * @param source the source to be checked | 5267 * @param source the source to be checked |
| 5048 * @param sourceEntry the cache entry associated with the source | 5268 * @param sourceEntry the cache entry associated with the source |
| 5049 * @param isPriority `true` if the source is a priority source | 5269 * @param isPriority `true` if the source is a priority source |
| 5050 * @param hintsEnabled `true` if hints are currently enabled | 5270 * @param hintsEnabled `true` if hints are currently enabled |
| 5051 * @param sources the set to which sources should be added | 5271 * @param sources the set to which sources should be added |
| 5052 */ | 5272 */ |
| 5053 void getSourcesNeedingProcessing2(Source source, SourceEntry sourceEntry, bool
isPriority, bool hintsEnabled, Set<Source> sources) { | 5273 void getSourcesNeedingProcessing2(Source source, SourceEntry sourceEntry, bool
isPriority, bool hintsEnabled, Set<Source> sources) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5101 } | 5321 } |
| 5102 } | 5322 } |
| 5103 } | 5323 } |
| 5104 } else if (sourceEntry is HtmlEntry) { | 5324 } else if (sourceEntry is HtmlEntry) { |
| 5105 HtmlEntry htmlEntry = sourceEntry; | 5325 HtmlEntry htmlEntry = sourceEntry; |
| 5106 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); | 5326 CacheState parsedUnitState = htmlEntry.getState(HtmlEntry.PARSED_UNIT); |
| 5107 if (identical(parsedUnitState, CacheState.INVALID) || (isPriority && ident
ical(parsedUnitState, CacheState.FLUSHED))) { | 5327 if (identical(parsedUnitState, CacheState.INVALID) || (isPriority && ident
ical(parsedUnitState, CacheState.FLUSHED))) { |
| 5108 sources.add(source); | 5328 sources.add(source); |
| 5109 return; | 5329 return; |
| 5110 } | 5330 } |
| 5111 CacheState elementState = htmlEntry.getState(HtmlEntry.ELEMENT); | 5331 CacheState resolvedUnitState = htmlEntry.getState(HtmlEntry.RESOLVED_UNIT)
; |
| 5112 if (identical(elementState, CacheState.INVALID) || (isPriority && identica
l(elementState, CacheState.FLUSHED))) { | 5332 if (identical(resolvedUnitState, CacheState.INVALID) || (isPriority && ide
ntical(resolvedUnitState, CacheState.FLUSHED))) { |
| 5113 sources.add(source); | 5333 sources.add(source); |
| 5114 return; | 5334 return; |
| 5115 } | 5335 } |
| 5336 CacheState angularErrorsState = htmlEntry.getState(HtmlEntry.ANGULAR_ERROR
S); |
| 5337 if (identical(angularErrorsState, CacheState.INVALID)) { |
| 5338 AngularApplicationInfo entryInfo = htmlEntry.getValue(HtmlEntry.ANGULAR_
ENTRY); |
| 5339 if (entryInfo != null) { |
| 5340 sources.add(source); |
| 5341 return; |
| 5342 } |
| 5343 AngularApplicationInfo applicationInfo = htmlEntry.getValue(HtmlEntry.AN
GULAR_APPLICATION); |
| 5344 if (applicationInfo != null) { |
| 5345 AngularComponentElement component = htmlEntry.getValue(HtmlEntry.ANGUL
AR_COMPONENT); |
| 5346 if (component != null) { |
| 5347 sources.add(source); |
| 5348 return; |
| 5349 } |
| 5350 } |
| 5351 } |
| 5116 } | 5352 } |
| 5117 } | 5353 } |
| 5118 | 5354 |
| 5119 /** | 5355 /** |
| 5120 * Invalidate all of the resolution results computed by this context. | 5356 * Invalidate all of the resolution results computed by this context. |
| 5121 * | 5357 * |
| 5122 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5358 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5123 */ | 5359 */ |
| 5124 void invalidateAllResolutionInformation() { | 5360 void invalidateAllResolutionInformation() { |
| 5125 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { | 5361 for (MapEntry<Source, SourceEntry> mapEntry in _cache.entrySet()) { |
| 5362 Source source = mapEntry.getKey(); |
| 5126 SourceEntry sourceEntry = mapEntry.getValue(); | 5363 SourceEntry sourceEntry = mapEntry.getValue(); |
| 5127 if (sourceEntry is HtmlEntry) { | 5364 if (sourceEntry is HtmlEntry) { |
| 5128 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 5365 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 5129 htmlCopy.invalidateAllResolutionInformation(); | 5366 htmlCopy.invalidateAllResolutionInformation(); |
| 5130 mapEntry.setValue(htmlCopy); | 5367 mapEntry.setValue(htmlCopy); |
| 5131 } else if (sourceEntry is DartEntry) { | 5368 } else if (sourceEntry is DartEntry) { |
| 5132 DartEntryImpl dartCopy = sourceEntry.writableCopy; | 5369 DartEntry dartEntry = sourceEntry; |
| 5370 removeFromParts(source, dartEntry); |
| 5371 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5133 dartCopy.invalidateAllResolutionInformation(); | 5372 dartCopy.invalidateAllResolutionInformation(); |
| 5134 mapEntry.setValue(dartCopy); | 5373 mapEntry.setValue(dartCopy); |
| 5374 _workManager.add(source, WorkManagerPriority.UNKNOWN); |
| 5135 } | 5375 } |
| 5136 } | 5376 } |
| 5137 } | 5377 } |
| 5138 | 5378 |
| 5139 /** | 5379 /** |
| 5140 * In response to a change to at least one of the compilation units in the giv
en library, | 5380 * In response to a change to at least one of the compilation units in the giv
en library, |
| 5141 * invalidate any results that are dependent on the result of resolving that l
ibrary. | 5381 * invalidate any results that are dependent on the result of resolving that l
ibrary. |
| 5142 * | 5382 * |
| 5143 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 5383 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5144 * | 5384 * |
| 5385 * <b>Note:</b> Any cache entries that were accessed before this method was in
voked must be |
| 5386 * re-accessed after this method returns. |
| 5387 * |
| 5145 * @param librarySource the source of the library being invalidated | 5388 * @param librarySource the source of the library being invalidated |
| 5146 * @param writer the writer to which debugging information should be written | 5389 * @param writer the writer to which debugging information should be written |
| 5147 */ | 5390 */ |
| 5148 void invalidateLibraryResolution(Source librarySource, PrintStringWriter write
r) { | 5391 void invalidateLibraryResolution(Source librarySource, PrintStringWriter write
r) { |
| 5149 // TODO(brianwilkerson) This could be optimized. There's no need to flush al
l of these caches if | 5392 // TODO(brianwilkerson) This could be optimized. There's no need to flush al
l of these caches if |
| 5150 // the public namespace hasn't changed, which will be a fairly common case.
The question is | 5393 // the public namespace hasn't changed, which will be a fairly common case.
The question is |
| 5151 // whether we can afford the time to compute the namespace to look for diffe
rences. | 5394 // whether we can afford the time to compute the namespace to look for diffe
rences. |
| 5152 DartEntry libraryEntry = getReadableDartEntry(librarySource); | 5395 DartEntry libraryEntry = getReadableDartEntry(librarySource); |
| 5153 if (libraryEntry != null) { | 5396 if (libraryEntry != null) { |
| 5154 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); | 5397 List<Source> includedParts = libraryEntry.getValue(DartEntry.INCLUDED_PART
S); |
| 5155 DartEntryImpl libraryCopy = libraryEntry.writableCopy; | 5398 DartEntryImpl libraryCopy = libraryEntry.writableCopy; |
| 5156 int oldTime = libraryCopy.modificationTime; | 5399 int oldTime = libraryCopy.modificationTime; |
| 5157 libraryCopy.invalidateAllResolutionInformation(); | 5400 libraryCopy.invalidateAllResolutionInformation(); |
| 5158 libraryCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.INVALID); | |
| 5159 _cache.put(librarySource, libraryCopy); | 5401 _cache.put(librarySource, libraryCopy); |
| 5402 _workManager.add(librarySource, WorkManagerPriority.LIBRARY); |
| 5160 if (writer != null) { | 5403 if (writer != null) { |
| 5161 writer.println(" Invalidated library source: ${debuggingString(libraryS
ource)} (previously modified at ${oldTime})"); | 5404 writer.println(" Invalidated library source: ${debuggingString(libraryS
ource)} (previously modified at ${oldTime})"); |
| 5162 } | 5405 } |
| 5163 for (Source partSource in includedParts) { | 5406 for (Source partSource in includedParts) { |
| 5164 SourceEntry partEntry = _cache.get(partSource); | 5407 SourceEntry partEntry = _cache.get(partSource); |
| 5165 if (partEntry is DartEntry) { | 5408 if (partEntry is DartEntry) { |
| 5166 DartEntryImpl partCopy = partEntry.writableCopy; | 5409 DartEntryImpl partCopy = partEntry.writableCopy; |
| 5167 oldTime = partCopy.modificationTime; | 5410 oldTime = partCopy.modificationTime; |
| 5411 if (partEntry != libraryCopy) { |
| 5412 partCopy.removeContainingLibrary(librarySource); |
| 5413 _workManager.add(librarySource, WorkManagerPriority.NORMAL_PART); |
| 5414 } |
| 5168 partCopy.invalidateAllResolutionInformation(); | 5415 partCopy.invalidateAllResolutionInformation(); |
| 5169 _cache.put(partSource, partCopy); | 5416 _cache.put(partSource, partCopy); |
| 5170 if (writer != null) { | 5417 if (writer != null) { |
| 5171 writer.println(" Invalidated part source: ${debuggingString(partSou
rce)} (previously modified at ${oldTime})"); | 5418 writer.println(" Invalidated part source: ${debuggingString(partSou
rce)} (previously modified at ${oldTime})"); |
| 5172 } | 5419 } |
| 5173 } | 5420 } |
| 5174 } | 5421 } |
| 5175 } | 5422 } |
| 5176 } | 5423 } |
| 5177 | 5424 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5226 AnalysisEngine.instance.logger.logInformation3(message, exception); | 5473 AnalysisEngine.instance.logger.logInformation3(message, exception); |
| 5227 } | 5474 } |
| 5228 } | 5475 } |
| 5229 | 5476 |
| 5230 /** | 5477 /** |
| 5231 * Updates [HtmlEntry]s that correspond to the previously known and new Angula
r components. | 5478 * Updates [HtmlEntry]s that correspond to the previously known and new Angula
r components. |
| 5232 * | 5479 * |
| 5233 * @param library the [Library] that was resolved | 5480 * @param library the [Library] that was resolved |
| 5234 * @param dartCopy the [DartEntryImpl] to record new Angular components | 5481 * @param dartCopy the [DartEntryImpl] to record new Angular components |
| 5235 */ | 5482 */ |
| 5236 void recordAngularComponents(Library library, DartEntryImpl dartCopy) { | 5483 void recordAngularComponents(HtmlEntryImpl entry, AngularApplicationInfo app)
{ |
| 5237 // reset old Angular errors | 5484 // reset old Angular errors |
| 5238 List<AngularElement> oldAngularElements = dartCopy.getValue(DartEntry.ANGULA
R_ELEMENTS); | 5485 AngularApplicationInfo oldApp = entry.getValue(HtmlEntry.ANGULAR_ENTRY); |
| 5239 if (oldAngularElements != null) { | 5486 if (oldApp != null) { |
| 5487 List<AngularElement> oldAngularElements = oldApp.elements; |
| 5240 for (AngularElement angularElement in oldAngularElements) { | 5488 for (AngularElement angularElement in oldAngularElements) { |
| 5241 if (angularElement is AngularComponentElement) { | 5489 if (angularElement is AngularComponentElement) { |
| 5242 AngularComponentElement component = angularElement; | 5490 AngularComponentElement component = angularElement; |
| 5243 Source templateSource = component.templateSource; | 5491 Source templateSource = component.templateSource; |
| 5244 if (templateSource != null) { | 5492 if (templateSource != null) { |
| 5245 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource); | 5493 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource); |
| 5246 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5494 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5495 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, null); |
| 5496 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, null); |
| 5247 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS)
; | 5497 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, AnalysisError.NO_ERRORS)
; |
| 5248 _cache.put(templateSource, htmlCopy); | 5498 _cache.put(templateSource, htmlCopy); |
| 5249 // notify about (disappeared) HTML errors | 5499 // notify about (disappeared) HTML errors |
| 5250 ChangeNoticeImpl notice = getNotice(templateSource); | 5500 ChangeNoticeImpl notice = getNotice(templateSource); |
| 5251 notice.setErrors(htmlCopy.allErrors, computeLineInfo(templateSource)
); | 5501 notice.setErrors(htmlCopy.allErrors, computeLineInfo(templateSource)
); |
| 5252 } | 5502 } |
| 5253 } | 5503 } |
| 5254 } | 5504 } |
| 5255 } | 5505 } |
| 5256 // invalidate new Angular errors | 5506 // prepare for new Angular analysis |
| 5257 List<AngularElement> newAngularElements = library.angularElements; | 5507 if (app != null) { |
| 5258 for (AngularElement angularElement in newAngularElements) { | 5508 List<AngularElement> newAngularElements = app.elements; |
| 5259 if (angularElement is AngularComponentElement) { | 5509 for (AngularElement angularElement in newAngularElements) { |
| 5260 AngularComponentElement component = angularElement; | 5510 if (angularElement is AngularComponentElement) { |
| 5261 Source templateSource = component.templateSource; | 5511 AngularComponentElement component = angularElement; |
| 5262 if (templateSource != null) { | 5512 Source templateSource = component.templateSource; |
| 5263 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource); | 5513 if (templateSource != null) { |
| 5264 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 5514 HtmlEntry htmlEntry = getReadableHtmlEntry(templateSource); |
| 5265 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); | 5515 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5266 _cache.put(templateSource, htmlCopy); | 5516 htmlCopy.setValue(HtmlEntry.ANGULAR_APPLICATION, app); |
| 5517 htmlCopy.setValue(HtmlEntry.ANGULAR_COMPONENT, component); |
| 5518 htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); |
| 5519 _cache.put(templateSource, htmlCopy); |
| 5520 _workManager.add(templateSource, WorkManagerPriority.HTML); |
| 5521 } |
| 5267 } | 5522 } |
| 5268 } | 5523 } |
| 5269 } | 5524 } |
| 5270 // remember Angular elements to resolve HTML templates later | 5525 // remember Angular application |
| 5271 dartCopy.setValue(DartEntry.ANGULAR_ELEMENTS, newAngularElements); | 5526 entry.setValue(HtmlEntry.ANGULAR_ENTRY, app); |
| 5527 entry.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.INVALID); |
| 5272 } | 5528 } |
| 5273 | 5529 |
| 5274 /** | 5530 /** |
| 5275 * Given a cache entry and a library element, record the library element and o
ther information | 5531 * Given a cache entry and a library element, record the library element and o
ther information |
| 5276 * gleaned from the element in the cache entry. | 5532 * gleaned from the element in the cache entry. |
| 5277 * | 5533 * |
| 5534 * @param dartEntry the original cache entry from which the copy was made |
| 5278 * @param dartCopy the cache entry in which data is to be recorded | 5535 * @param dartCopy the cache entry in which data is to be recorded |
| 5279 * @param library the library element used to record information | 5536 * @param library the library element used to record information |
| 5537 * @param librarySource the source for the library used to record information |
| 5280 * @param htmlSource the source for the HTML library | 5538 * @param htmlSource the source for the HTML library |
| 5281 */ | 5539 */ |
| 5282 void recordElementData(DartEntryImpl dartCopy, LibraryElement library, Source
htmlSource) { | 5540 void recordElementData(DartEntry dartEntry, DartEntryImpl dartCopy, LibraryEle
ment library, Source librarySource, Source htmlSource) { |
| 5283 dartCopy.setValue(DartEntry.ELEMENT, library); | 5541 dartCopy.setValue(DartEntry.ELEMENT, library); |
| 5284 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); | 5542 dartCopy.setValue(DartEntry.IS_LAUNCHABLE, library.entryPoint != null); |
| 5285 dartCopy.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource, new Set
<LibraryElement>())); | 5543 dartCopy.setValue(DartEntry.IS_CLIENT, isClient(library, htmlSource, new Set
<LibraryElement>())); |
| 5286 List<Source> unitSources = new List<Source>(); | |
| 5287 unitSources.add(library.definingCompilationUnit.source); | |
| 5288 // TODO(brianwilkerson) Understand why we're doing this both here and in | 5544 // TODO(brianwilkerson) Understand why we're doing this both here and in |
| 5289 // ResolveDartDependenciesTask and whether we should also be capturing the i
mported and exported | 5545 // ResolveDartDependenciesTask and whether we should also be capturing the i
mported and exported |
| 5290 // sources here. | 5546 // sources here. |
| 5291 for (CompilationUnitElement part in library.parts) { | 5547 removeFromParts(librarySource, dartEntry); |
| 5292 Source partSource = part.source; | 5548 List<CompilationUnitElement> parts = library.parts; |
| 5293 unitSources.add(partSource); | 5549 int count = parts.length; |
| 5550 List<Source> unitSources = new List<Source>(count + 1); |
| 5551 unitSources[0] = library.definingCompilationUnit.source; |
| 5552 for (int i = 0; i < count; i++) { |
| 5553 Source unitSource = parts[i].source; |
| 5554 unitSources[i + 1] = unitSource; |
| 5555 DartEntry unitEntry = getReadableDartEntry(unitSource); |
| 5556 if (unitSource != null) { |
| 5557 DartEntryImpl unitCopy = unitEntry.writableCopy; |
| 5558 unitCopy.addContainingLibrary(librarySource); |
| 5559 _cache.put(unitSource, unitCopy); |
| 5560 } |
| 5294 } | 5561 } |
| 5295 dartCopy.setValue(DartEntry.INCLUDED_PARTS, new List.from(unitSources)); | 5562 dartCopy.setValue(DartEntry.INCLUDED_PARTS, unitSources); |
| 5296 } | 5563 } |
| 5297 | 5564 |
| 5298 /** | 5565 /** |
| 5299 * Record the results produced by performing a [GenerateDartErrorsTask]. If th
e results were | 5566 * Record the results produced by performing a [GenerateDartErrorsTask]. If th
e results were |
| 5300 * computed from data that is now out-of-date, then the results will not be re
corded. | 5567 * computed from data that is now out-of-date, then the results will not be re
corded. |
| 5301 * | 5568 * |
| 5302 * @param task the task that was performed | 5569 * @param task the task that was performed |
| 5303 * @return an entry containing the computed results | 5570 * @return an entry containing the computed results |
| 5304 * @throws AnalysisException if the results could not be recorded | 5571 * @throws AnalysisException if the results could not be recorded |
| 5305 */ | 5572 */ |
| 5306 DartEntry recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { | 5573 DartEntry recordGenerateDartErrorsTask(GenerateDartErrorsTask task) { |
| 5307 Source source = task.source; | 5574 Source source = task.source; |
| 5308 Source librarySource = task.libraryElement.source; | 5575 Source librarySource = task.libraryElement.source; |
| 5309 AnalysisException thrownException = task.exception; | 5576 AnalysisException thrownException = task.exception; |
| 5310 DartEntry dartEntry = null; | 5577 DartEntry dartEntry = null; |
| 5311 { | 5578 { |
| 5312 SourceEntry sourceEntry = _cache.get(source); | 5579 SourceEntry sourceEntry = _cache.get(source); |
| 5313 if (sourceEntry is! DartEntry) { | 5580 if (sourceEntry is! DartEntry) { |
| 5314 // This shouldn't be possible because we should never have performed the
task if the source | 5581 // This shouldn't be possible because we should never have performed the
task if the source |
| 5315 // didn't represent a Dart file, but check to be safe. | 5582 // didn't represent a Dart file, but check to be safe. |
| 5316 throw new AnalysisException.con1("Internal error: attempting to verify n
on-Dart file as a Dart file: ${source.fullName}"); | 5583 throw new AnalysisException.con1("Internal error: attempting to verify n
on-Dart file as a Dart file: ${source.fullName}"); |
| 5317 } | 5584 } |
| 5318 dartEntry = sourceEntry as DartEntry; | 5585 dartEntry = sourceEntry as DartEntry; |
| 5319 _cache.accessed(source); | |
| 5320 int sourceTime = source.modificationStamp; | 5586 int sourceTime = source.modificationStamp; |
| 5321 int resultTime = task.modificationTime; | 5587 int resultTime = task.modificationTime; |
| 5322 if (sourceTime == resultTime) { | 5588 if (sourceTime == resultTime) { |
| 5323 if (dartEntry.modificationTime != sourceTime) { | 5589 if (dartEntry.modificationTime != sourceTime) { |
| 5324 // The source has changed without the context being notified. Simulate
notification. | 5590 // The source has changed without the context being notified. Simulate
notification. |
| 5325 sourceChanged(source); | 5591 sourceChanged(source); |
| 5326 dartEntry = getReadableDartEntry(source); | 5592 dartEntry = getReadableDartEntry(source); |
| 5327 if (dartEntry == null) { | 5593 if (dartEntry == null) { |
| 5328 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); | 5594 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); |
| 5329 } | 5595 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 5341 dartEntry = dartCopy; | 5607 dartEntry = dartCopy; |
| 5342 } else { | 5608 } else { |
| 5343 logInformation2("Generated errors discarded for ${debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn
try.modificationTime}", thrownException); | 5609 logInformation2("Generated errors discarded for ${debuggingString(source
)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEn
try.modificationTime}", thrownException); |
| 5344 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5610 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5345 if (thrownException == null || resultTime >= 0) { | 5611 if (thrownException == null || resultTime >= 0) { |
| 5346 // | 5612 // |
| 5347 // The analysis was performed on out-of-date sources. Mark the cache s
o that the source | 5613 // The analysis was performed on out-of-date sources. Mark the cache s
o that the source |
| 5348 // will be re-verified using the up-to-date sources. | 5614 // will be re-verified using the up-to-date sources. |
| 5349 // | 5615 // |
| 5350 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySo
urce, CacheState.INVALID); | 5616 // dartCopy.setState(DartEntry.VERIFICATION_ERRORS, librarySo
urce, CacheState.INVALID); |
| 5617 removeFromParts(source, dartEntry); |
| 5351 dartCopy.invalidateAllInformation(); | 5618 dartCopy.invalidateAllInformation(); |
| 5352 dartCopy.modificationTime = sourceTime; | 5619 dartCopy.modificationTime = sourceTime; |
| 5620 _cache.removedAst(source); |
| 5621 _workManager.add(source, WorkManagerPriority.UNKNOWN); |
| 5353 } else { | 5622 } else { |
| 5354 // | 5623 // |
| 5355 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | 5624 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the |
| 5356 // cache so that we won't attempt to re-verify the source until there'
s a good chance | 5625 // cache so that we won't attempt to re-verify the source until there'
s a good chance |
| 5357 // that we'll be able to do so without error. | 5626 // that we'll be able to do so without error. |
| 5358 // | 5627 // |
| 5359 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, Cache
State.ERROR); | 5628 dartCopy.setState2(DartEntry.VERIFICATION_ERRORS, librarySource, Cache
State.ERROR); |
| 5360 } | 5629 } |
| 5361 dartCopy.exception = thrownException; | 5630 dartCopy.exception = thrownException; |
| 5362 _cache.put(source, dartCopy); | 5631 _cache.put(source, dartCopy); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5409 SourceEntry sourceEntry = _cache.get(unitSource); | 5678 SourceEntry sourceEntry = _cache.get(unitSource); |
| 5410 if (sourceEntry is! DartEntry) { | 5679 if (sourceEntry is! DartEntry) { |
| 5411 // This shouldn't be possible because we should never have performed t
he task if the source | 5680 // This shouldn't be possible because we should never have performed t
he task if the source |
| 5412 // didn't represent a Dart file, but check to be safe. | 5681 // didn't represent a Dart file, but check to be safe. |
| 5413 throw new AnalysisException.con1("Internal error: attempting to parse
non-Dart file as a Dart file: ${unitSource.fullName}"); | 5682 throw new AnalysisException.con1("Internal error: attempting to parse
non-Dart file as a Dart file: ${unitSource.fullName}"); |
| 5414 } | 5683 } |
| 5415 DartEntry dartEntry = sourceEntry as DartEntry; | 5684 DartEntry dartEntry = sourceEntry as DartEntry; |
| 5416 if (unitSource == librarySource) { | 5685 if (unitSource == librarySource) { |
| 5417 libraryEntry = dartEntry; | 5686 libraryEntry = dartEntry; |
| 5418 } | 5687 } |
| 5419 _cache.accessed(unitSource); | |
| 5420 int sourceTime = unitSource.modificationStamp; | 5688 int sourceTime = unitSource.modificationStamp; |
| 5421 int resultTime = results.modificationTime; | 5689 int resultTime = results.modificationTime; |
| 5422 if (sourceTime == resultTime) { | 5690 if (sourceTime == resultTime) { |
| 5423 if (dartEntry.modificationTime != sourceTime) { | 5691 if (dartEntry.modificationTime != sourceTime) { |
| 5424 // The source has changed without the context being notified. Simula
te notification. | 5692 // The source has changed without the context being notified. Simula
te notification. |
| 5425 sourceChanged(unitSource); | 5693 sourceChanged(unitSource); |
| 5426 dartEntry = getReadableDartEntry(unitSource); | 5694 dartEntry = getReadableDartEntry(unitSource); |
| 5427 if (dartEntry == null) { | 5695 if (dartEntry == null) { |
| 5428 throw new AnalysisException.con1("A Dart file became a non-Dart fi
le: ${unitSource.fullName}"); | 5696 throw new AnalysisException.con1("A Dart file became a non-Dart fi
le: ${unitSource.fullName}"); |
| 5429 } | 5697 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5442 } else { | 5710 } else { |
| 5443 logInformation2("Generated hints discarded for ${debuggingString(unitS
ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d
artEntry.modificationTime}", thrownException); | 5711 logInformation2("Generated hints discarded for ${debuggingString(unitS
ource)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${d
artEntry.modificationTime}", thrownException); |
| 5444 if (identical(dartEntry.getState2(DartEntry.HINTS, librarySource), Cac
heState.IN_PROCESS)) { | 5712 if (identical(dartEntry.getState2(DartEntry.HINTS, librarySource), Cac
heState.IN_PROCESS)) { |
| 5445 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5713 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5446 if (thrownException == null || resultTime >= 0) { | 5714 if (thrownException == null || resultTime >= 0) { |
| 5447 // | 5715 // |
| 5448 // The analysis was performed on out-of-date sources. Mark the cac
he so that the sources | 5716 // The analysis was performed on out-of-date sources. Mark the cac
he so that the sources |
| 5449 // will be re-analyzed using the up-to-date sources. | 5717 // will be re-analyzed using the up-to-date sources. |
| 5450 // | 5718 // |
| 5451 // dartCopy.setState(DartEntry.HINTS, librarySource,
CacheState.INVALID); | 5719 // dartCopy.setState(DartEntry.HINTS, librarySource,
CacheState.INVALID); |
| 5720 removeFromParts(unitSource, dartEntry); |
| 5452 dartCopy.invalidateAllInformation(); | 5721 dartCopy.invalidateAllInformation(); |
| 5453 dartCopy.modificationTime = sourceTime; | 5722 dartCopy.modificationTime = sourceTime; |
| 5723 _cache.removedAst(unitSource); |
| 5724 _workManager.add(unitSource, WorkManagerPriority.UNKNOWN); |
| 5454 } else { | 5725 } else { |
| 5455 // | 5726 // |
| 5456 // We could not determine whether the sources were up-to-date or o
ut-of-date. Mark the | 5727 // We could not determine whether the sources were up-to-date or o
ut-of-date. Mark the |
| 5457 // cache so that we won't attempt to re-analyze the sources until
there's a good chance | 5728 // cache so that we won't attempt to re-analyze the sources until
there's a good chance |
| 5458 // that we'll be able to do so without error. | 5729 // that we'll be able to do so without error. |
| 5459 // | 5730 // |
| 5460 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERRO
R); | 5731 dartCopy.setState2(DartEntry.HINTS, librarySource, CacheState.ERRO
R); |
| 5461 } | 5732 } |
| 5462 dartCopy.exception = thrownException; | 5733 dartCopy.exception = thrownException; |
| 5463 _cache.put(unitSource, dartCopy); | 5734 _cache.put(unitSource, dartCopy); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5504 AnalysisException thrownException = task.exception; | 5775 AnalysisException thrownException = task.exception; |
| 5505 DartEntry dartEntry = null; | 5776 DartEntry dartEntry = null; |
| 5506 { | 5777 { |
| 5507 SourceEntry sourceEntry = _cache.get(source); | 5778 SourceEntry sourceEntry = _cache.get(source); |
| 5508 if (sourceEntry is! DartEntry) { | 5779 if (sourceEntry is! DartEntry) { |
| 5509 // This shouldn't be possible because we should never have performed the
task if the source | 5780 // This shouldn't be possible because we should never have performed the
task if the source |
| 5510 // didn't represent a Dart file, but check to be safe. | 5781 // didn't represent a Dart file, but check to be safe. |
| 5511 throw new AnalysisException.con1("Internal error: attempting to parse no
n-Dart file as a Dart file: ${source.fullName}"); | 5782 throw new AnalysisException.con1("Internal error: attempting to parse no
n-Dart file as a Dart file: ${source.fullName}"); |
| 5512 } | 5783 } |
| 5513 dartEntry = sourceEntry as DartEntry; | 5784 dartEntry = sourceEntry as DartEntry; |
| 5514 _cache.accessed(source); | |
| 5515 int sourceTime = source.modificationStamp; | 5785 int sourceTime = source.modificationStamp; |
| 5516 int resultTime = task.modificationTime; | 5786 int resultTime = task.modificationTime; |
| 5517 if (sourceTime == resultTime) { | 5787 if (sourceTime == resultTime) { |
| 5518 if (dartEntry.modificationTime != sourceTime) { | 5788 if (dartEntry.modificationTime != sourceTime) { |
| 5519 // The source has changed without the context being notified. Simulate
notification. | 5789 // The source has changed without the context being notified. Simulate
notification. |
| 5520 sourceChanged(source); | 5790 sourceChanged(source); |
| 5521 dartEntry = getReadableDartEntry(source); | 5791 dartEntry = getReadableDartEntry(source); |
| 5522 if (dartEntry == null) { | 5792 if (dartEntry == null) { |
| 5523 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); | 5793 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); |
| 5524 } | 5794 } |
| 5525 } | 5795 } |
| 5526 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5796 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5527 if (thrownException == null) { | 5797 if (thrownException == null) { |
| 5528 LineInfo lineInfo = task.lineInfo; | 5798 LineInfo lineInfo = task.lineInfo; |
| 5529 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 5799 dartCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 5530 if (task.hasPartOfDirective() && !task.hasLibraryDirective()) { | 5800 if (task.hasPartOfDirective() && !task.hasLibraryDirective()) { |
| 5531 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); | 5801 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.PART); |
| 5802 _workManager.add(source, WorkManagerPriority.NORMAL_PART); |
| 5532 } else { | 5803 } else { |
| 5533 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); | 5804 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); |
| 5805 dartCopy.containingLibrary = source; |
| 5806 _workManager.add(source, WorkManagerPriority.LIBRARY); |
| 5534 } | 5807 } |
| 5535 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); | 5808 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); |
| 5536 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); | 5809 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); |
| 5810 _cache.storedAst(source); |
| 5537 ChangeNoticeImpl notice = getNotice(source); | 5811 ChangeNoticeImpl notice = getNotice(source); |
| 5538 notice.setErrors(dartEntry.allErrors, lineInfo); | 5812 notice.setErrors(dartEntry.allErrors, lineInfo); |
| 5539 // Verify that the incrementally parsed and resolved unit in the incre
mental cache | 5813 // Verify that the incrementally parsed and resolved unit in the incre
mental cache |
| 5540 // is structurally equivalent to the fully parsed unit | 5814 // is structurally equivalent to the fully parsed unit |
| 5541 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_
incrementalAnalysisCache, source, task.compilationUnit); | 5815 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_
incrementalAnalysisCache, source, task.compilationUnit); |
| 5542 } else { | 5816 } else { |
| 5817 removeFromParts(source, dartEntry); |
| 5543 dartCopy.recordParseError(); | 5818 dartCopy.recordParseError(); |
| 5819 _cache.removedAst(source); |
| 5544 } | 5820 } |
| 5545 dartCopy.exception = thrownException; | 5821 dartCopy.exception = thrownException; |
| 5546 _cache.put(source, dartCopy); | 5822 _cache.put(source, dartCopy); |
| 5547 dartEntry = dartCopy; | 5823 dartEntry = dartCopy; |
| 5548 } else { | 5824 } else { |
| 5549 logInformation2("Parse results discarded for ${debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry
.modificationTime}", thrownException); | 5825 logInformation2("Parse results discarded for ${debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${dartEntry
.modificationTime}", thrownException); |
| 5550 DartEntryImpl dartCopy = dartEntry.writableCopy; | 5826 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5551 if (thrownException == null || resultTime >= 0) { | 5827 if (thrownException == null || resultTime >= 0) { |
| 5552 // | 5828 // |
| 5553 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | 5829 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources |
| 5554 // will be re-analyzed using the up-to-date sources. | 5830 // will be re-analyzed using the up-to-date sources. |
| 5555 // | 5831 // |
| 5556 // dartCopy.recordParseNotInProcess(); | 5832 // dartCopy.recordParseNotInProcess(); |
| 5833 removeFromParts(source, dartEntry); |
| 5557 dartCopy.invalidateAllInformation(); | 5834 dartCopy.invalidateAllInformation(); |
| 5558 dartCopy.modificationTime = sourceTime; | 5835 dartCopy.modificationTime = sourceTime; |
| 5836 _cache.removedAst(source); |
| 5837 _workManager.add(source, WorkManagerPriority.UNKNOWN); |
| 5559 } else { | 5838 } else { |
| 5560 // | 5839 // |
| 5561 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | 5840 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the |
| 5562 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | 5841 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance |
| 5563 // that we'll be able to do so without error. | 5842 // that we'll be able to do so without error. |
| 5564 // | 5843 // |
| 5565 dartCopy.recordParseError(); | 5844 dartCopy.recordParseError(); |
| 5566 } | 5845 } |
| 5567 dartCopy.exception = thrownException; | 5846 dartCopy.exception = thrownException; |
| 5568 _cache.put(source, dartCopy); | 5847 _cache.put(source, dartCopy); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5588 AnalysisException thrownException = task.exception; | 5867 AnalysisException thrownException = task.exception; |
| 5589 HtmlEntry htmlEntry = null; | 5868 HtmlEntry htmlEntry = null; |
| 5590 { | 5869 { |
| 5591 SourceEntry sourceEntry = _cache.get(source); | 5870 SourceEntry sourceEntry = _cache.get(source); |
| 5592 if (sourceEntry is! HtmlEntry) { | 5871 if (sourceEntry is! HtmlEntry) { |
| 5593 // This shouldn't be possible because we should never have performed the
task if the source | 5872 // This shouldn't be possible because we should never have performed the
task if the source |
| 5594 // didn't represent an HTML file, but check to be safe. | 5873 // didn't represent an HTML file, but check to be safe. |
| 5595 throw new AnalysisException.con1("Internal error: attempting to parse no
n-HTML file as a HTML file: ${source.fullName}"); | 5874 throw new AnalysisException.con1("Internal error: attempting to parse no
n-HTML file as a HTML file: ${source.fullName}"); |
| 5596 } | 5875 } |
| 5597 htmlEntry = sourceEntry as HtmlEntry; | 5876 htmlEntry = sourceEntry as HtmlEntry; |
| 5598 _cache.accessed(source); | |
| 5599 int sourceTime = source.modificationStamp; | 5877 int sourceTime = source.modificationStamp; |
| 5600 int resultTime = task.modificationTime; | 5878 int resultTime = task.modificationTime; |
| 5601 if (sourceTime == resultTime) { | 5879 if (sourceTime == resultTime) { |
| 5602 if (htmlEntry.modificationTime != sourceTime) { | 5880 if (htmlEntry.modificationTime != sourceTime) { |
| 5603 // The source has changed without the context being notified. Simulate
notification. | 5881 // The source has changed without the context being notified. Simulate
notification. |
| 5604 sourceChanged(source); | 5882 sourceChanged(source); |
| 5605 htmlEntry = getReadableHtmlEntry(source); | 5883 htmlEntry = getReadableHtmlEntry(source); |
| 5606 if (htmlEntry == null) { | 5884 if (htmlEntry == null) { |
| 5607 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); | 5885 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); |
| 5608 } | 5886 } |
| 5609 } | 5887 } |
| 5610 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 5888 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
| 5611 if (thrownException == null) { | 5889 if (thrownException == null) { |
| 5612 LineInfo lineInfo = task.lineInfo; | 5890 LineInfo lineInfo = task.lineInfo; |
| 5613 ht.HtmlUnit unit = task.htmlUnit; | 5891 ht.HtmlUnit unit = task.htmlUnit; |
| 5614 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); | 5892 htmlCopy.setValue(SourceEntry.LINE_INFO, lineInfo); |
| 5615 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); | 5893 htmlCopy.setValue(HtmlEntry.PARSED_UNIT, unit); |
| 5616 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); | 5894 htmlCopy.setValue(HtmlEntry.PARSE_ERRORS, task.errors); |
| 5617 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibra
ries); | 5895 htmlCopy.setValue(HtmlEntry.REFERENCED_LIBRARIES, task.referencedLibra
ries); |
| 5896 _cache.storedAst(source); |
| 5618 ChangeNoticeImpl notice = getNotice(source); | 5897 ChangeNoticeImpl notice = getNotice(source); |
| 5619 notice.setErrors(htmlEntry.allErrors, lineInfo); | 5898 notice.setErrors(htmlEntry.allErrors, lineInfo); |
| 5620 } else { | 5899 } else { |
| 5621 htmlCopy.recordParseError(); | 5900 htmlCopy.recordParseError(); |
| 5901 _cache.removedAst(source); |
| 5622 } | 5902 } |
| 5623 htmlCopy.exception = thrownException; | 5903 htmlCopy.exception = thrownException; |
| 5624 _cache.put(source, htmlCopy); | 5904 _cache.put(source, htmlCopy); |
| 5625 htmlEntry = htmlCopy; | 5905 htmlEntry = htmlCopy; |
| 5626 } else { | 5906 } else { |
| 5627 logInformation2("Parse results discarded for ${debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry
.modificationTime}", thrownException); | 5907 logInformation2("Parse results discarded for ${debuggingString(source)};
sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${htmlEntry
.modificationTime}", thrownException); |
| 5628 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; | 5908 HtmlEntryImpl htmlCopy = (sourceEntry as HtmlEntry).writableCopy; |
| 5629 if (thrownException == null || resultTime >= 0) { | 5909 if (thrownException == null || resultTime >= 0) { |
| 5630 // | 5910 // |
| 5631 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | 5911 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources |
| 5632 // will be re-analyzed using the up-to-date sources. | 5912 // will be re-analyzed using the up-to-date sources. |
| 5633 // | 5913 // |
| 5634 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState
.IN_PROCESS) { | 5914 // if (htmlCopy.getState(SourceEntry.LINE_INFO) == CacheState
.IN_PROCESS) { |
| 5635 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVA
LID); | 5915 // htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.INVA
LID); |
| 5636 // } | 5916 // } |
| 5637 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState
.IN_PROCESS) { | 5917 // if (htmlCopy.getState(HtmlEntry.PARSED_UNIT) == CacheState
.IN_PROCESS) { |
| 5638 // htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVA
LID); | 5918 // htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.INVA
LID); |
| 5639 // } | 5919 // } |
| 5640 // if (htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES) == C
acheState.IN_PROCESS) { | 5920 // if (htmlCopy.getState(HtmlEntry.REFERENCED_LIBRARIES) == C
acheState.IN_PROCESS) { |
| 5641 // htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheS
tate.INVALID); | 5921 // htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheS
tate.INVALID); |
| 5642 // } | 5922 // } |
| 5643 htmlCopy.invalidateAllInformation(); | 5923 htmlCopy.invalidateAllInformation(); |
| 5644 htmlCopy.modificationTime = sourceTime; | 5924 htmlCopy.modificationTime = sourceTime; |
| 5925 _cache.removedAst(source); |
| 5645 } else { | 5926 } else { |
| 5646 // | 5927 // |
| 5647 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | 5928 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the |
| 5648 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | 5929 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance |
| 5649 // that we'll be able to do so without error. | 5930 // that we'll be able to do so without error. |
| 5650 // | 5931 // |
| 5651 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); | 5932 htmlCopy.setState(SourceEntry.LINE_INFO, CacheState.ERROR); |
| 5652 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); | 5933 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.ERROR); |
| 5934 htmlCopy.setState(HtmlEntry.RESOLVED_UNIT, CacheState.ERROR); |
| 5653 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); | 5935 htmlCopy.setState(HtmlEntry.REFERENCED_LIBRARIES, CacheState.ERROR); |
| 5654 } | 5936 } |
| 5655 htmlCopy.exception = thrownException; | 5937 htmlCopy.exception = thrownException; |
| 5656 _cache.put(source, htmlCopy); | 5938 _cache.put(source, htmlCopy); |
| 5657 htmlEntry = htmlCopy; | 5939 htmlEntry = htmlCopy; |
| 5658 } | 5940 } |
| 5659 } | 5941 } |
| 5660 if (thrownException != null) { | 5942 if (thrownException != null) { |
| 5661 throw thrownException; | 5943 throw thrownException; |
| 5662 } | 5944 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 5675 AnalysisException thrownException = task.exception; | 5957 AnalysisException thrownException = task.exception; |
| 5676 HtmlEntry htmlEntry = null; | 5958 HtmlEntry htmlEntry = null; |
| 5677 { | 5959 { |
| 5678 SourceEntry sourceEntry = _cache.get(source); | 5960 SourceEntry sourceEntry = _cache.get(source); |
| 5679 if (sourceEntry is! HtmlEntry) { | 5961 if (sourceEntry is! HtmlEntry) { |
| 5680 // This shouldn't be possible because we should never have performed the
task if the source | 5962 // This shouldn't be possible because we should never have performed the
task if the source |
| 5681 // didn't represent an HTML file, but check to be safe. | 5963 // didn't represent an HTML file, but check to be safe. |
| 5682 throw new AnalysisException.con1("Internal error: attempting to resolve
non-HTML file as an HTML file: ${source.fullName}"); | 5964 throw new AnalysisException.con1("Internal error: attempting to resolve
non-HTML file as an HTML file: ${source.fullName}"); |
| 5683 } | 5965 } |
| 5684 htmlEntry = sourceEntry as HtmlEntry; | 5966 htmlEntry = sourceEntry as HtmlEntry; |
| 5685 _cache.accessed(source); | |
| 5686 int sourceTime = source.modificationStamp; | 5967 int sourceTime = source.modificationStamp; |
| 5687 int resultTime = task.modificationTime; | 5968 int resultTime = task.modificationTime; |
| 5688 if (sourceTime == resultTime) { | 5969 if (sourceTime == resultTime) { |
| 5689 if (htmlEntry.modificationTime != sourceTime) { | 5970 if (htmlEntry.modificationTime != sourceTime) { |
| 5690 // The source has changed without the context being notified. Simulate
notification. | 5971 // The source has changed without the context being notified. Simulate
notification. |
| 5691 sourceChanged(source); | 5972 sourceChanged(source); |
| 5692 htmlEntry = getReadableHtmlEntry(source); | 5973 htmlEntry = getReadableHtmlEntry(source); |
| 5693 if (htmlEntry == null) { | 5974 if (htmlEntry == null) { |
| 5694 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); | 5975 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); |
| 5695 } | 5976 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5717 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.I
NVALID); | 5998 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.I
NVALID); |
| 5718 // } | 5999 // } |
| 5719 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_
PROCESS) { | 6000 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_
PROCESS) { |
| 5720 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID)
; | 6001 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID)
; |
| 5721 // } | 6002 // } |
| 5722 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == Cach
eState.IN_PROCESS) { | 6003 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == Cach
eState.IN_PROCESS) { |
| 5723 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheStat
e.INVALID); | 6004 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheStat
e.INVALID); |
| 5724 // } | 6005 // } |
| 5725 htmlCopy.invalidateAllInformation(); | 6006 htmlCopy.invalidateAllInformation(); |
| 5726 htmlCopy.modificationTime = sourceTime; | 6007 htmlCopy.modificationTime = sourceTime; |
| 6008 _cache.removedAst(source); |
| 5727 } else { | 6009 } else { |
| 5728 // | 6010 // |
| 5729 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | 6011 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the |
| 6012 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance |
| 6013 // that we'll be able to do so without error. |
| 6014 // |
| 6015 htmlCopy.recordResolutionError(); |
| 6016 } |
| 6017 htmlCopy.exception = thrownException; |
| 6018 _cache.put(source, htmlCopy); |
| 6019 htmlEntry = htmlCopy; |
| 6020 } |
| 6021 } |
| 6022 if (thrownException != null) { |
| 6023 throw thrownException; |
| 6024 } |
| 6025 return htmlEntry; |
| 6026 } |
| 6027 |
| 6028 /** |
| 6029 * Record the results produced by performing a [ResolveAngularEntryHtmlTask].
If the results |
| 6030 * were computed from data that is now out-of-date, then the results will not
be recorded. |
| 6031 * |
| 6032 * @param task the task that was performed |
| 6033 * @throws AnalysisException if the results could not be recorded |
| 6034 */ |
| 6035 HtmlEntry recordResolveAngularEntryHtmlTaskResults(ResolveAngularEntryHtmlTask
task) { |
| 6036 Source source = task.source; |
| 6037 AnalysisException thrownException = task.exception; |
| 6038 HtmlEntry htmlEntry = null; |
| 6039 { |
| 6040 SourceEntry sourceEntry = _cache.get(source); |
| 6041 if (sourceEntry is! HtmlEntry) { |
| 6042 // This shouldn't be possible because we should never have performed the
task if the source |
| 6043 // didn't represent an HTML file, but check to be safe. |
| 6044 throw new AnalysisException.con1("Internal error: attempting to resolve
non-HTML file as an HTML file: ${source.fullName}"); |
| 6045 } |
| 6046 htmlEntry = sourceEntry as HtmlEntry; |
| 6047 int sourceTime = source.modificationStamp; |
| 6048 int resultTime = task.modificationTime; |
| 6049 if (sourceTime == resultTime) { |
| 6050 if (htmlEntry.modificationTime != sourceTime) { |
| 6051 // The source has changed without the context being notified. Simulate
notification. |
| 6052 sourceChanged(source); |
| 6053 htmlEntry = getReadableHtmlEntry(source); |
| 6054 if (htmlEntry == null) { |
| 6055 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); |
| 6056 } |
| 6057 } |
| 6058 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6059 if (thrownException == null) { |
| 6060 htmlCopy.setValue(HtmlEntry.ANGULAR_ERRORS, task.resolutionErrors); |
| 6061 ChangeNoticeImpl notice = getNotice(source); |
| 6062 notice.htmlUnit = task.resolvedUnit; |
| 6063 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); |
| 6064 } else { |
| 6065 htmlCopy.recordResolutionError(); |
| 6066 } |
| 6067 htmlCopy.exception = thrownException; |
| 6068 _cache.put(source, htmlCopy); |
| 6069 htmlEntry = htmlCopy; |
| 6070 } else { |
| 6071 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 6072 if (thrownException == null || resultTime >= 0) { |
| 6073 // |
| 6074 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources |
| 6075 // will be re-analyzed using the up-to-date sources. |
| 6076 // |
| 6077 // if (htmlCopy.getState(HtmlEntry.ANGULAR_ERRORS) == CacheSt
ate.IN_PROCESS) { |
| 6078 // htmlCopy.setState(HtmlEntry.ANGULAR_ERRORS, CacheState.I
NVALID); |
| 6079 // } |
| 6080 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_
PROCESS) { |
| 6081 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID)
; |
| 6082 // } |
| 6083 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == Cach
eState.IN_PROCESS) { |
| 6084 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheStat
e.INVALID); |
| 6085 // } |
| 6086 htmlCopy.invalidateAllInformation(); |
| 6087 htmlCopy.modificationTime = sourceTime; |
| 6088 _cache.removedAst(source); |
| 6089 } else { |
| 6090 // |
| 6091 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the |
| 5730 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | 6092 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance |
| 5731 // that we'll be able to do so without error. | 6093 // that we'll be able to do so without error. |
| 5732 // | 6094 // |
| 5733 htmlCopy.recordResolutionError(); | 6095 htmlCopy.recordResolutionError(); |
| 5734 } | 6096 } |
| 5735 htmlCopy.exception = thrownException; | 6097 htmlCopy.exception = thrownException; |
| 5736 _cache.put(source, htmlCopy); | 6098 _cache.put(source, htmlCopy); |
| 5737 htmlEntry = htmlCopy; | 6099 htmlEntry = htmlCopy; |
| 5738 } | 6100 } |
| 5739 } | 6101 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5756 AnalysisException thrownException = task.exception; | 6118 AnalysisException thrownException = task.exception; |
| 5757 DartEntry dartEntry = null; | 6119 DartEntry dartEntry = null; |
| 5758 { | 6120 { |
| 5759 SourceEntry sourceEntry = _cache.get(source); | 6121 SourceEntry sourceEntry = _cache.get(source); |
| 5760 if (sourceEntry is! DartEntry) { | 6122 if (sourceEntry is! DartEntry) { |
| 5761 // This shouldn't be possible because we should never have performed the
task if the source | 6123 // This shouldn't be possible because we should never have performed the
task if the source |
| 5762 // didn't represent a Dart file, but check to be safe. | 6124 // didn't represent a Dart file, but check to be safe. |
| 5763 throw new AnalysisException.con1("Internal error: attempting to resolve
Dart dependencies in a non-Dart file: ${source.fullName}"); | 6125 throw new AnalysisException.con1("Internal error: attempting to resolve
Dart dependencies in a non-Dart file: ${source.fullName}"); |
| 5764 } | 6126 } |
| 5765 dartEntry = sourceEntry as DartEntry; | 6127 dartEntry = sourceEntry as DartEntry; |
| 5766 _cache.accessed(source); | |
| 5767 int sourceTime = source.modificationStamp; | 6128 int sourceTime = source.modificationStamp; |
| 5768 int resultTime = task.modificationTime; | 6129 int resultTime = task.modificationTime; |
| 5769 if (sourceTime == resultTime) { | 6130 if (sourceTime == resultTime) { |
| 5770 if (dartEntry.modificationTime != sourceTime) { | 6131 if (dartEntry.modificationTime != sourceTime) { |
| 5771 // The source has changed without the context being notified. Simulate
notification. | 6132 // The source has changed without the context being notified. Simulate
notification. |
| 5772 sourceChanged(source); | 6133 sourceChanged(source); |
| 5773 dartEntry = getReadableDartEntry(source); | 6134 dartEntry = getReadableDartEntry(source); |
| 5774 if (dartEntry == null) { | 6135 if (dartEntry == null) { |
| 5775 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); | 6136 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${source.fullName}"); |
| 5776 } | 6137 } |
| 5777 } | 6138 } |
| 6139 removeFromParts(source, dartEntry); |
| 5778 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6140 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5779 if (thrownException == null) { | 6141 if (thrownException == null) { |
| 6142 List<Source> newParts = task.includedSources; |
| 6143 for (int i = 0; i < newParts.length; i++) { |
| 6144 Source partSource = newParts[i]; |
| 6145 DartEntry partEntry = getReadableDartEntry(partSource); |
| 6146 if (partEntry != null && partEntry != dartEntry) { |
| 6147 DartEntryImpl partCopy = partEntry.writableCopy; |
| 6148 partCopy.addContainingLibrary(source); |
| 6149 _cache.put(partSource, partCopy); |
| 6150 } |
| 6151 } |
| 5780 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); | 6152 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); |
| 5781 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); | 6153 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); |
| 5782 dartCopy.setValue(DartEntry.INCLUDED_PARTS, task.includedSources); | 6154 dartCopy.setValue(DartEntry.INCLUDED_PARTS, newParts); |
| 5783 } else { | 6155 } else { |
| 5784 dartCopy.recordDependencyError(); | 6156 dartCopy.recordDependencyError(); |
| 5785 } | 6157 } |
| 5786 dartCopy.exception = thrownException; | 6158 dartCopy.exception = thrownException; |
| 5787 _cache.put(source, dartCopy); | 6159 _cache.put(source, dartCopy); |
| 5788 dartEntry = dartCopy; | 6160 dartEntry = dartCopy; |
| 5789 } else { | 6161 } else { |
| 5790 logInformation2("Dependency resolution results discarded for ${debugging
String(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTi
me = ${dartEntry.modificationTime}", thrownException); | 6162 logInformation2("Dependency resolution results discarded for ${debugging
String(source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTi
me = ${dartEntry.modificationTime}", thrownException); |
| 5791 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6163 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5792 if (thrownException == null || resultTime >= 0) { | 6164 if (thrownException == null || resultTime >= 0) { |
| 5793 // | 6165 // |
| 5794 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | 6166 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources |
| 5795 // will be re-analyzed using the up-to-date sources. | 6167 // will be re-analyzed using the up-to-date sources. |
| 5796 // | 6168 // |
| 5797 // dartCopy.recordDependencyNotInProcess(); | 6169 // dartCopy.recordDependencyNotInProcess(); |
| 6170 removeFromParts(source, dartEntry); |
| 5798 dartCopy.invalidateAllInformation(); | 6171 dartCopy.invalidateAllInformation(); |
| 5799 dartCopy.modificationTime = sourceTime; | 6172 dartCopy.modificationTime = sourceTime; |
| 6173 _cache.removedAst(source); |
| 6174 _workManager.add(source, WorkManagerPriority.UNKNOWN); |
| 5800 } else { | 6175 } else { |
| 5801 // | 6176 // |
| 5802 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | 6177 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the |
| 5803 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | 6178 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance |
| 5804 // that we'll be able to do so without error. | 6179 // that we'll be able to do so without error. |
| 5805 // | 6180 // |
| 5806 dartCopy.setState(DartEntry.EXPORTED_LIBRARIES, CacheState.ERROR); | 6181 dartCopy.setState(DartEntry.EXPORTED_LIBRARIES, CacheState.ERROR); |
| 5807 dartCopy.setState(DartEntry.IMPORTED_LIBRARIES, CacheState.ERROR); | 6182 dartCopy.setState(DartEntry.IMPORTED_LIBRARIES, CacheState.ERROR); |
| 5808 dartCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.ERROR); | 6183 dartCopy.setState(DartEntry.INCLUDED_PARTS, CacheState.ERROR); |
| 5809 } | 6184 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 5832 AnalysisException thrownException = task.exception; | 6207 AnalysisException thrownException = task.exception; |
| 5833 DartEntry dartEntry = null; | 6208 DartEntry dartEntry = null; |
| 5834 { | 6209 { |
| 5835 SourceEntry sourceEntry = _cache.get(unitSource); | 6210 SourceEntry sourceEntry = _cache.get(unitSource); |
| 5836 if (sourceEntry is! DartEntry) { | 6211 if (sourceEntry is! DartEntry) { |
| 5837 // This shouldn't be possible because we should never have performed the
task if the source | 6212 // This shouldn't be possible because we should never have performed the
task if the source |
| 5838 // didn't represent a Dart file, but check to be safe. | 6213 // didn't represent a Dart file, but check to be safe. |
| 5839 throw new AnalysisException.con1("Internal error: attempting to resolve
non-Dart file as a Dart file: ${unitSource.fullName}"); | 6214 throw new AnalysisException.con1("Internal error: attempting to resolve
non-Dart file as a Dart file: ${unitSource.fullName}"); |
| 5840 } | 6215 } |
| 5841 dartEntry = sourceEntry as DartEntry; | 6216 dartEntry = sourceEntry as DartEntry; |
| 5842 _cache.accessed(unitSource); | |
| 5843 int sourceTime = unitSource.modificationStamp; | 6217 int sourceTime = unitSource.modificationStamp; |
| 5844 int resultTime = task.modificationTime; | 6218 int resultTime = task.modificationTime; |
| 5845 if (sourceTime == resultTime) { | 6219 if (sourceTime == resultTime) { |
| 5846 if (dartEntry.modificationTime != sourceTime) { | 6220 if (dartEntry.modificationTime != sourceTime) { |
| 5847 // The source has changed without the context being notified. Simulate
notification. | 6221 // The source has changed without the context being notified. Simulate
notification. |
| 5848 sourceChanged(unitSource); | 6222 sourceChanged(unitSource); |
| 5849 dartEntry = getReadableDartEntry(unitSource); | 6223 dartEntry = getReadableDartEntry(unitSource); |
| 5850 if (dartEntry == null) { | 6224 if (dartEntry == null) { |
| 5851 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); | 6225 throw new AnalysisException.con1("A Dart file became a non-Dart file
: ${unitSource.fullName}"); |
| 5852 } | 6226 } |
| 5853 } | 6227 } |
| 5854 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6228 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5855 if (thrownException == null) { | 6229 if (thrownException == null) { |
| 5856 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, task.resolv
edUnit); | 6230 dartCopy.setValue2(DartEntry.RESOLVED_UNIT, librarySource, task.resolv
edUnit); |
| 6231 _cache.storedAst(unitSource); |
| 5857 } else { | 6232 } else { |
| 5858 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
ERROR); | 6233 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
ERROR); |
| 6234 _cache.removedAst(unitSource); |
| 5859 } | 6235 } |
| 5860 dartCopy.exception = thrownException; | 6236 dartCopy.exception = thrownException; |
| 5861 _cache.put(unitSource, dartCopy); | 6237 _cache.put(unitSource, dartCopy); |
| 5862 dartEntry = dartCopy; | 6238 dartEntry = dartCopy; |
| 5863 } else { | 6239 } else { |
| 5864 logInformation2("Resolution results discarded for ${debuggingString(unit
Source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${
dartEntry.modificationTime}", thrownException); | 6240 logInformation2("Resolution results discarded for ${debuggingString(unit
Source)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${
dartEntry.modificationTime}", thrownException); |
| 5865 DartEntryImpl dartCopy = dartEntry.writableCopy; | 6241 DartEntryImpl dartCopy = dartEntry.writableCopy; |
| 5866 if (thrownException == null || resultTime >= 0) { | 6242 if (thrownException == null || resultTime >= 0) { |
| 5867 // | 6243 // |
| 5868 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | 6244 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources |
| 5869 // will be re-analyzed using the up-to-date sources. | 6245 // will be re-analyzed using the up-to-date sources. |
| 5870 // | 6246 // |
| 5871 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheSta
te.IN_PROCESS) { | 6247 // if (dartCopy.getState(DartEntry.RESOLVED_UNIT) == CacheSta
te.IN_PROCESS) { |
| 5872 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource
, CacheState.INVALID); | 6248 // dartCopy.setState(DartEntry.RESOLVED_UNIT, librarySource
, CacheState.INVALID); |
| 5873 // } | 6249 // } |
| 6250 removeFromParts(unitSource, dartEntry); |
| 5874 dartCopy.invalidateAllInformation(); | 6251 dartCopy.invalidateAllInformation(); |
| 5875 dartCopy.modificationTime = sourceTime; | 6252 dartCopy.modificationTime = sourceTime; |
| 6253 _cache.removedAst(unitSource); |
| 6254 _workManager.add(unitSource, WorkManagerPriority.UNKNOWN); |
| 5876 } else { | 6255 } else { |
| 5877 // | 6256 // |
| 5878 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | 6257 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the |
| 5879 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | 6258 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance |
| 5880 // that we'll be able to do so without error. | 6259 // that we'll be able to do so without error. |
| 5881 // | 6260 // |
| 5882 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
ERROR); | 6261 dartCopy.setState2(DartEntry.RESOLVED_UNIT, librarySource, CacheState.
ERROR); |
| 5883 } | 6262 } |
| 5884 dartCopy.exception = thrownException; | 6263 dartCopy.exception = thrownException; |
| 5885 _cache.put(unitSource, dartCopy); | 6264 _cache.put(unitSource, dartCopy); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 5905 AnalysisException thrownException = task.exception; | 6284 AnalysisException thrownException = task.exception; |
| 5906 HtmlEntry htmlEntry = null; | 6285 HtmlEntry htmlEntry = null; |
| 5907 { | 6286 { |
| 5908 SourceEntry sourceEntry = _cache.get(source); | 6287 SourceEntry sourceEntry = _cache.get(source); |
| 5909 if (sourceEntry is! HtmlEntry) { | 6288 if (sourceEntry is! HtmlEntry) { |
| 5910 // This shouldn't be possible because we should never have performed the
task if the source | 6289 // This shouldn't be possible because we should never have performed the
task if the source |
| 5911 // didn't represent an HTML file, but check to be safe. | 6290 // didn't represent an HTML file, but check to be safe. |
| 5912 throw new AnalysisException.con1("Internal error: attempting to resolve
non-HTML file as an HTML file: ${source.fullName}"); | 6291 throw new AnalysisException.con1("Internal error: attempting to resolve
non-HTML file as an HTML file: ${source.fullName}"); |
| 5913 } | 6292 } |
| 5914 htmlEntry = sourceEntry as HtmlEntry; | 6293 htmlEntry = sourceEntry as HtmlEntry; |
| 5915 _cache.accessed(source); | |
| 5916 int sourceTime = source.modificationStamp; | 6294 int sourceTime = source.modificationStamp; |
| 5917 int resultTime = task.modificationTime; | 6295 int resultTime = task.modificationTime; |
| 5918 if (sourceTime == resultTime) { | 6296 if (sourceTime == resultTime) { |
| 5919 if (htmlEntry.modificationTime != sourceTime) { | 6297 if (htmlEntry.modificationTime != sourceTime) { |
| 5920 // The source has changed without the context being notified. Simulate
notification. | 6298 // The source has changed without the context being notified. Simulate
notification. |
| 5921 sourceChanged(source); | 6299 sourceChanged(source); |
| 5922 htmlEntry = getReadableHtmlEntry(source); | 6300 htmlEntry = getReadableHtmlEntry(source); |
| 5923 if (htmlEntry == null) { | 6301 if (htmlEntry == null) { |
| 5924 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); | 6302 throw new AnalysisException.con1("An HTML file became a non-HTML fil
e: ${source.fullName}"); |
| 5925 } | 6303 } |
| 5926 } | 6304 } |
| 5927 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6305 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5928 if (thrownException == null) { | 6306 if (thrownException == null) { |
| 6307 htmlCopy.setState(HtmlEntry.PARSED_UNIT, CacheState.FLUSHED); |
| 6308 htmlCopy.setValue(HtmlEntry.RESOLVED_UNIT, task.resolvedUnit); |
| 5929 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); | 6309 htmlCopy.setValue(HtmlEntry.ELEMENT, task.element); |
| 5930 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); | 6310 htmlCopy.setValue(HtmlEntry.RESOLUTION_ERRORS, task.resolutionErrors); |
| 6311 _cache.storedAst(source); |
| 5931 ChangeNoticeImpl notice = getNotice(source); | 6312 ChangeNoticeImpl notice = getNotice(source); |
| 5932 notice.htmlUnit = task.resolvedUnit; | 6313 notice.htmlUnit = task.resolvedUnit; |
| 5933 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); | 6314 notice.setErrors(htmlCopy.allErrors, htmlCopy.getValue(SourceEntry.LIN
E_INFO)); |
| 5934 } else { | 6315 } else { |
| 5935 htmlCopy.recordResolutionError(); | 6316 htmlCopy.recordResolutionError(); |
| 6317 _cache.removedAst(source); |
| 5936 } | 6318 } |
| 5937 htmlCopy.exception = thrownException; | 6319 htmlCopy.exception = thrownException; |
| 6320 recordAngularComponents(htmlCopy, task.angularApplication); |
| 5938 _cache.put(source, htmlCopy); | 6321 _cache.put(source, htmlCopy); |
| 5939 htmlEntry = htmlCopy; | 6322 htmlEntry = htmlCopy; |
| 5940 } else { | 6323 } else { |
| 5941 logInformation2("Resolution results discarded for ${debuggingString(sour
ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html
Entry.modificationTime}", thrownException); | 6324 logInformation2("Resolution results discarded for ${debuggingString(sour
ce)}; sourceTime = ${sourceTime}, resultTime = ${resultTime}, cacheTime = ${html
Entry.modificationTime}", thrownException); |
| 5942 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; | 6325 HtmlEntryImpl htmlCopy = htmlEntry.writableCopy; |
| 5943 if (thrownException == null || resultTime >= 0) { | 6326 if (thrownException == null || resultTime >= 0) { |
| 5944 // | 6327 // |
| 5945 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources | 6328 // The analysis was performed on out-of-date sources. Mark the cache s
o that the sources |
| 5946 // will be re-analyzed using the up-to-date sources. | 6329 // will be re-analyzed using the up-to-date sources. |
| 5947 // | 6330 // |
| 5948 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_
PROCESS) { | 6331 // if (htmlCopy.getState(HtmlEntry.ELEMENT) == CacheState.IN_
PROCESS) { |
| 5949 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID)
; | 6332 // htmlCopy.setState(HtmlEntry.ELEMENT, CacheState.INVALID)
; |
| 5950 // } | 6333 // } |
| 5951 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == Cach
eState.IN_PROCESS) { | 6334 // if (htmlCopy.getState(HtmlEntry.RESOLUTION_ERRORS) == Cach
eState.IN_PROCESS) { |
| 5952 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheStat
e.INVALID); | 6335 // htmlCopy.setState(HtmlEntry.RESOLUTION_ERRORS, CacheStat
e.INVALID); |
| 5953 // } | 6336 // } |
| 5954 htmlCopy.invalidateAllInformation(); | 6337 htmlCopy.invalidateAllInformation(); |
| 5955 htmlCopy.modificationTime = sourceTime; | 6338 htmlCopy.modificationTime = sourceTime; |
| 6339 _cache.removedAst(source); |
| 5956 } else { | 6340 } else { |
| 5957 // | 6341 // |
| 5958 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the | 6342 // We could not determine whether the sources were up-to-date or out-o
f-date. Mark the |
| 5959 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance | 6343 // cache so that we won't attempt to re-analyze the sources until ther
e's a good chance |
| 5960 // that we'll be able to do so without error. | 6344 // that we'll be able to do so without error. |
| 5961 // | 6345 // |
| 5962 htmlCopy.recordResolutionError(); | 6346 htmlCopy.recordResolutionError(); |
| 5963 } | 6347 } |
| 5964 htmlCopy.exception = thrownException; | 6348 htmlCopy.exception = thrownException; |
| 5965 _cache.put(source, htmlCopy); | 6349 _cache.put(source, htmlCopy); |
| 5966 htmlEntry = htmlCopy; | 6350 htmlEntry = htmlCopy; |
| 5967 } | 6351 } |
| 5968 } | 6352 } |
| 5969 if (thrownException != null) { | 6353 if (thrownException != null) { |
| 5970 throw thrownException; | 6354 throw thrownException; |
| 5971 } | 6355 } |
| 5972 return htmlEntry; | 6356 return htmlEntry; |
| 5973 } | 6357 } |
| 5974 | 6358 |
| 5975 /** | 6359 /** |
| 6360 * Remove the given library from the list of containing libraries for all of t
he parts referenced |
| 6361 * by the given entry. |
| 6362 * |
| 6363 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 6364 * |
| 6365 * @param librarySource the library to be removed |
| 6366 * @param dartEntry the entry containing the list of included parts |
| 6367 */ |
| 6368 void removeFromParts(Source librarySource, DartEntry dartEntry) { |
| 6369 List<Source> oldParts = dartEntry.getValue(DartEntry.INCLUDED_PARTS); |
| 6370 for (int i = 0; i < oldParts.length; i++) { |
| 6371 Source partSource = oldParts[i]; |
| 6372 DartEntry partEntry = getReadableDartEntry(partSource); |
| 6373 if (partEntry != null && partEntry != dartEntry) { |
| 6374 DartEntryImpl partCopy = partEntry.writableCopy; |
| 6375 partCopy.removeContainingLibrary(librarySource); |
| 6376 _cache.put(partSource, partCopy); |
| 6377 } |
| 6378 } |
| 6379 } |
| 6380 |
| 6381 /** |
| 6382 * Remove the given source from the priority order if it is in the list. |
| 6383 * |
| 6384 * @param source the source to be removed |
| 6385 */ |
| 6386 void removeFromPriorityOrder(Source source) { |
| 6387 int count = _priorityOrder.length; |
| 6388 List<Source> newOrder = new List<Source>(); |
| 6389 for (int i = 0; i < count; i++) { |
| 6390 if (_priorityOrder[i] != source) { |
| 6391 newOrder.add(_priorityOrder[i]); |
| 6392 } |
| 6393 } |
| 6394 if (newOrder.length < count) { |
| 6395 analysisPriorityOrder = newOrder; |
| 6396 } |
| 6397 } |
| 6398 |
| 6399 /** |
| 5976 * Create an entry for the newly added source. Return `true` if the new source
is a Dart | 6400 * Create an entry for the newly added source. Return `true` if the new source
is a Dart |
| 5977 * file. | 6401 * file. |
| 5978 * | 6402 * |
| 5979 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 6403 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 5980 * | 6404 * |
| 5981 * @param source the source that has been added | 6405 * @param source the source that has been added |
| 5982 * @return `true` if the new source is a Dart file | 6406 * @return `true` if the new source is a Dart file |
| 5983 */ | 6407 */ |
| 5984 bool sourceAvailable(Source source) { | 6408 bool sourceAvailable(Source source) { |
| 5985 SourceEntry sourceEntry = _cache.get(source); | 6409 SourceEntry sourceEntry = _cache.get(source); |
| 5986 if (sourceEntry == null) { | 6410 if (sourceEntry == null) { |
| 5987 sourceEntry = createSourceEntry(source); | 6411 sourceEntry = createSourceEntry(source); |
| 5988 logInformation("Added new source: ${debuggingString(source)}"); | 6412 logInformation("Added new source: ${debuggingString(source)}"); |
| 5989 } else { | 6413 } else { |
| 5990 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; | 6414 SourceEntryImpl sourceCopy = sourceEntry.writableCopy; |
| 5991 int oldTime = sourceCopy.modificationTime; | 6415 int oldTime = sourceCopy.modificationTime; |
| 5992 sourceCopy.modificationTime = source.modificationStamp; | 6416 sourceCopy.modificationTime = source.modificationStamp; |
| 5993 // TODO(brianwilkerson) Understand why we're not invalidating the cache. | 6417 // TODO(brianwilkerson) Understand why we're not invalidating the cache. |
| 5994 _cache.put(source, sourceCopy); | 6418 _cache.put(source, sourceCopy); |
| 5995 logInformation("Added new source: ${debuggingString(source)} (previously m
odified at ${oldTime})"); | 6419 logInformation("Added new source: ${debuggingString(source)} (previously m
odified at ${oldTime})"); |
| 5996 } | 6420 } |
| 6421 if (sourceEntry is HtmlEntry) { |
| 6422 _workManager.add(source, WorkManagerPriority.HTML); |
| 6423 } else { |
| 6424 _workManager.add(source, WorkManagerPriority.UNKNOWN); |
| 6425 } |
| 5997 return sourceEntry is DartEntry; | 6426 return sourceEntry is DartEntry; |
| 5998 } | 6427 } |
| 5999 | 6428 |
| 6000 /** | 6429 /** |
| 6001 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 6430 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 6002 * | 6431 * |
| 6003 * @param source the source that has been changed | 6432 * @param source the source that has been changed |
| 6004 */ | 6433 */ |
| 6005 void sourceChanged(Source source) { | 6434 void sourceChanged(Source source) { |
| 6006 SourceEntry sourceEntry = _cache.get(source); | 6435 SourceEntry sourceEntry = _cache.get(source); |
| 6007 if (sourceEntry == null || sourceEntry.modificationTime == source.modificati
onStamp) { | 6436 if (sourceEntry == null || sourceEntry.modificationTime == source.modificati
onStamp) { |
| 6008 // Either we have removed this source, in which case we don't care that it
is changed, or we | 6437 // Either we have removed this source, in which case we don't care that it
is changed, or we |
| 6009 // have already invalidated the cache and don't need to invalidate it agai
n. | 6438 // have already invalidated the cache and don't need to invalidate it agai
n. |
| 6010 if (sourceEntry == null) { | 6439 if (sourceEntry == null) { |
| 6011 logInformation("Modified source, but there is no entry: ${debuggingStrin
g(source)}"); | 6440 logInformation("Modified source, but there is no entry: ${debuggingStrin
g(source)}"); |
| 6012 } else { | 6441 } else { |
| 6013 logInformation("Modified source, but modification time matches: ${debugg
ingString(source)}"); | 6442 logInformation("Modified source, but modification time matches: ${debugg
ingString(source)}"); |
| 6014 } | 6443 } |
| 6015 return; | 6444 return; |
| 6016 } | 6445 } |
| 6017 if (sourceEntry is HtmlEntry) { | 6446 if (sourceEntry is HtmlEntry) { |
| 6018 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; | 6447 HtmlEntryImpl htmlCopy = sourceEntry.writableCopy; |
| 6019 int oldTime = htmlCopy.modificationTime; | 6448 int oldTime = htmlCopy.modificationTime; |
| 6020 htmlCopy.modificationTime = source.modificationStamp; | 6449 htmlCopy.modificationTime = source.modificationStamp; |
| 6021 htmlCopy.invalidateAllInformation(); | 6450 htmlCopy.invalidateAllInformation(); |
| 6022 _cache.put(source, htmlCopy); | 6451 _cache.put(source, htmlCopy); |
| 6452 _cache.removedAst(source); |
| 6453 _workManager.add(source, WorkManagerPriority.HTML); |
| 6023 logInformation("Modified HTML source: ${debuggingString(source)} (previous
ly modified at ${oldTime})"); | 6454 logInformation("Modified HTML source: ${debuggingString(source)} (previous
ly modified at ${oldTime})"); |
| 6024 } else if (sourceEntry is DartEntry) { | 6455 } else if (sourceEntry is DartEntry) { |
| 6025 List<Source> containingLibraries = getLibrariesContaining(source); | 6456 List<Source> containingLibraries = getLibrariesContaining(source); |
| 6026 Set<Source> librariesToInvalidate = new Set<Source>(); | 6457 Set<Source> librariesToInvalidate = new Set<Source>(); |
| 6027 for (Source containingLibrary in containingLibraries) { | 6458 for (Source containingLibrary in containingLibraries) { |
| 6028 librariesToInvalidate.add(containingLibrary); | 6459 librariesToInvalidate.add(containingLibrary); |
| 6029 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar
y)) { | 6460 for (Source dependentLibrary in getLibrariesDependingOn(containingLibrar
y)) { |
| 6030 librariesToInvalidate.add(dependentLibrary); | 6461 librariesToInvalidate.add(dependentLibrary); |
| 6031 } | 6462 } |
| 6032 } | 6463 } |
| 6033 PrintStringWriter writer = new PrintStringWriter(); | 6464 PrintStringWriter writer = new PrintStringWriter(); |
| 6034 int oldTime = sourceEntry.modificationTime; | 6465 int oldTime = sourceEntry.modificationTime; |
| 6035 writer.println("Modified Dart source: ${debuggingString(source)} (previous
ly modified at ${oldTime})"); | 6466 writer.println("Modified Dart source: ${debuggingString(source)} (previous
ly modified at ${oldTime})"); |
| 6036 for (Source library in librariesToInvalidate) { | 6467 for (Source library in librariesToInvalidate) { |
| 6037 // for (Source library : containingLibraries) { | 6468 // for (Source library : containingLibraries) { |
| 6038 invalidateLibraryResolution(library, writer); | 6469 invalidateLibraryResolution(library, writer); |
| 6039 } | 6470 } |
| 6471 removeFromParts(source, sourceEntry); |
| 6040 DartEntryImpl dartCopy = sourceEntry.writableCopy; | 6472 DartEntryImpl dartCopy = sourceEntry.writableCopy; |
| 6041 dartCopy.modificationTime = source.modificationStamp; | 6473 dartCopy.modificationTime = source.modificationStamp; |
| 6042 dartCopy.invalidateAllInformation(); | 6474 dartCopy.invalidateAllInformation(); |
| 6043 _cache.put(source, dartCopy); | 6475 _cache.put(source, dartCopy); |
| 6476 _cache.removedAst(source); |
| 6477 _workManager.add(source, WorkManagerPriority.UNKNOWN); |
| 6044 logInformation(writer.toString()); | 6478 logInformation(writer.toString()); |
| 6045 } | 6479 } |
| 6046 } | 6480 } |
| 6047 | 6481 |
| 6048 /** | 6482 /** |
| 6049 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 6483 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 6050 * | 6484 * |
| 6051 * @param source the source that has been deleted | 6485 * @param source the source that has been deleted |
| 6052 */ | 6486 */ |
| 6053 void sourceRemoved(Source source) { | 6487 void sourceRemoved(Source source) { |
| 6054 PrintStringWriter writer = new PrintStringWriter(); | 6488 PrintStringWriter writer = new PrintStringWriter(); |
| 6055 writer.println("Removed source: ${debuggingString(source)}"); | 6489 writer.println("Removed source: ${debuggingString(source)}"); |
| 6056 SourceEntry sourceEntry = _cache.get(source); | 6490 SourceEntry sourceEntry = _cache.get(source); |
| 6057 if (sourceEntry is DartEntry) { | 6491 if (sourceEntry is DartEntry) { |
| 6058 Set<Source> libraries = new Set<Source>(); | 6492 Set<Source> libraries = new Set<Source>(); |
| 6059 for (Source librarySource in getLibrariesContaining(source)) { | 6493 for (Source librarySource in getLibrariesContaining(source)) { |
| 6060 libraries.add(librarySource); | 6494 libraries.add(librarySource); |
| 6061 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ | 6495 for (Source dependentLibrary in getLibrariesDependingOn(librarySource))
{ |
| 6062 libraries.add(dependentLibrary); | 6496 libraries.add(dependentLibrary); |
| 6063 } | 6497 } |
| 6064 } | 6498 } |
| 6065 for (Source librarySource in libraries) { | 6499 for (Source librarySource in libraries) { |
| 6066 invalidateLibraryResolution(librarySource, writer); | 6500 invalidateLibraryResolution(librarySource, writer); |
| 6067 } | 6501 } |
| 6068 } | 6502 } |
| 6069 _cache.remove(source); | 6503 _cache.remove(source); |
| 6504 _workManager.remove(source); |
| 6505 removeFromPriorityOrder(source); |
| 6070 logInformation(writer.toString()); | 6506 logInformation(writer.toString()); |
| 6071 } | 6507 } |
| 6072 | 6508 |
| 6073 /** | 6509 /** |
| 6074 * Check the cache for any invalid entries (entries whose modification time do
es not match the | 6510 * Check the cache for any invalid entries (entries whose modification time do
es not match the |
| 6075 * modification time of the source associated with the entry). Invalid entries
will be marked as | 6511 * modification time of the source associated with the entry). Invalid entries
will be marked as |
| 6076 * invalid so that the source will be re-analyzed. | 6512 * invalid so that the source will be re-analyzed. |
| 6077 * | 6513 * |
| 6078 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. | 6514 * <b>Note:</b> This method must only be invoked while we are synchronized on
[cacheLock]. |
| 6079 * | 6515 * |
| 6080 * @return `true` if at least one entry was invalid | 6516 * @return `true` if at least one entry was invalid |
| 6081 */ | 6517 */ |
| 6082 bool validateCacheConsistency() { | 6518 bool validateCacheConsistency() { |
| 6083 int consistencyCheckStart = JavaSystem.nanoTime(); | 6519 int consistencyCheckStart = JavaSystem.nanoTime(); |
| 6520 List<Source> missingSources = new List<Source>(); |
| 6084 int inconsistentCount = 0; | 6521 int inconsistentCount = 0; |
| 6085 { | 6522 { |
| 6086 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { | 6523 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { |
| 6087 Source source = entry.getKey(); | 6524 Source source = entry.getKey(); |
| 6088 SourceEntry sourceEntry = entry.getValue(); | 6525 SourceEntry sourceEntry = entry.getValue(); |
| 6089 int sourceTime = source.modificationStamp; | 6526 int sourceTime = source.modificationStamp; |
| 6090 if (sourceTime != sourceEntry.modificationTime) { | 6527 if (sourceTime != sourceEntry.modificationTime) { |
| 6091 sourceChanged(source); | 6528 sourceChanged(source); |
| 6092 inconsistentCount++; | 6529 inconsistentCount++; |
| 6093 } | 6530 } |
| 6531 if (sourceEntry.exception != null) { |
| 6532 if (!source.exists()) { |
| 6533 missingSources.add(source); |
| 6534 } |
| 6535 } |
| 6094 } | 6536 } |
| 6095 } | 6537 } |
| 6096 int consistencyCheckEnd = JavaSystem.nanoTime(); | 6538 int consistencyCheckEnd = JavaSystem.nanoTime(); |
| 6097 logInformation("Consistency check found ${inconsistentCount} inconsistent en
tries in ${((consistencyCheckEnd - consistencyCheckStart) / 1000000.0)} ms"); | 6539 PrintStringWriter writer = new PrintStringWriter(); |
| 6540 writer.print("Consistency check took "); |
| 6541 writer.print((consistencyCheckEnd - consistencyCheckStart) / 1000000.0); |
| 6542 writer.println(" ms and found"); |
| 6543 writer.print(" "); |
| 6544 writer.print(inconsistentCount); |
| 6545 writer.println(" inconsistent entries"); |
| 6546 writer.print(" "); |
| 6547 writer.print(missingSources.length); |
| 6548 writer.println(" missing sources"); |
| 6549 for (Source source in missingSources) { |
| 6550 writer.print(" "); |
| 6551 writer.println(source.fullName); |
| 6552 } |
| 6553 logInformation(writer.toString()); |
| 6098 return inconsistentCount > 0; | 6554 return inconsistentCount > 0; |
| 6099 } | 6555 } |
| 6100 } | 6556 } |
| 6101 | 6557 |
| 6102 /** | 6558 /** |
| 6103 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c
ontext to | 6559 * Instances of the class `AnalysisTaskResultRecorder` are used by an analysis c
ontext to |
| 6104 * record the results of a task. | 6560 * record the results of a task. |
| 6105 */ | 6561 */ |
| 6106 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi
tor<SourceEntry> { | 6562 class AnalysisContextImpl_AnalysisTaskResultRecorder implements AnalysisTaskVisi
tor<SourceEntry> { |
| 6107 final AnalysisContextImpl AnalysisContextImpl_this; | 6563 final AnalysisContextImpl AnalysisContextImpl_this; |
| 6108 | 6564 |
| 6109 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); | 6565 AnalysisContextImpl_AnalysisTaskResultRecorder(this.AnalysisContextImpl_this); |
| 6110 | 6566 |
| 6111 SourceEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analys
isContextImpl_this.recordGenerateDartErrorsTask(task); | 6567 SourceEntry visitGenerateDartErrorsTask(GenerateDartErrorsTask task) => Analys
isContextImpl_this.recordGenerateDartErrorsTask(task); |
| 6112 | 6568 |
| 6113 SourceEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => Analysis
ContextImpl_this.recordGenerateDartHintsTask(task); | 6569 SourceEntry visitGenerateDartHintsTask(GenerateDartHintsTask task) => Analysis
ContextImpl_this.recordGenerateDartHintsTask(task); |
| 6114 | 6570 |
| 6115 SourceEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Anal
ysisContextImpl_this.recordIncrementalAnalysisTaskResults(task); | 6571 SourceEntry visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => Anal
ysisContextImpl_this.recordIncrementalAnalysisTaskResults(task); |
| 6116 | 6572 |
| 6117 DartEntry visitParseDartTask(ParseDartTask task) => AnalysisContextImpl_this.r
ecordParseDartTaskResults(task); | 6573 DartEntry visitParseDartTask(ParseDartTask task) => AnalysisContextImpl_this.r
ecordParseDartTaskResults(task); |
| 6118 | 6574 |
| 6119 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this.r
ecordParseHtmlTaskResults(task); | 6575 HtmlEntry visitParseHtmlTask(ParseHtmlTask task) => AnalysisContextImpl_this.r
ecordParseHtmlTaskResults(task); |
| 6120 | 6576 |
| 6121 HtmlEntry visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemp
lateTask task) => AnalysisContextImpl_this.recordResolveAngularComponentTemplate
TaskResults(task); | 6577 HtmlEntry visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemp
lateTask task) => AnalysisContextImpl_this.recordResolveAngularComponentTemplate
TaskResults(task); |
| 6122 | 6578 |
| 6579 SourceEntry visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task)
=> AnalysisContextImpl_this.recordResolveAngularEntryHtmlTaskResults(task); |
| 6580 |
| 6123 DartEntry visitResolveDartDependenciesTask(ResolveDartDependenciesTask task) =
> AnalysisContextImpl_this.recordResolveDartDependenciesTaskResults(task); | 6581 DartEntry visitResolveDartDependenciesTask(ResolveDartDependenciesTask task) =
> AnalysisContextImpl_this.recordResolveDartDependenciesTaskResults(task); |
| 6124 | 6582 |
| 6125 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis
ContextImpl_this.recordResolveDartLibraryTaskResults(task); | 6583 DartEntry visitResolveDartLibraryTask(ResolveDartLibraryTask task) => Analysis
ContextImpl_this.recordResolveDartLibraryTaskResults(task); |
| 6126 | 6584 |
| 6127 SourceEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisCont
extImpl_this.recordResolveDartUnitTaskResults(task); | 6585 SourceEntry visitResolveDartUnitTask(ResolveDartUnitTask task) => AnalysisCont
extImpl_this.recordResolveDartUnitTaskResults(task); |
| 6128 | 6586 |
| 6129 SourceEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_
this.recordResolveHtmlTaskResults(task); | 6587 SourceEntry visitResolveHtmlTask(ResolveHtmlTask task) => AnalysisContextImpl_
this.recordResolveHtmlTaskResults(task); |
| 6130 } | 6588 } |
| 6131 | 6589 |
| 6132 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy
{ | 6590 class AnalysisContextImpl_ContextRetentionPolicy implements CacheRetentionPolicy
{ |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6910 instrumentation.metric3("contextId", _contextId); | 7368 instrumentation.metric3("contextId", _contextId); |
| 6911 return _basis.computeLineInfo(source); | 7369 return _basis.computeLineInfo(source); |
| 6912 } on AnalysisException catch (e) { | 7370 } on AnalysisException catch (e) { |
| 6913 recordAnalysisException(instrumentation, e); | 7371 recordAnalysisException(instrumentation, e); |
| 6914 throw e; | 7372 throw e; |
| 6915 } finally { | 7373 } finally { |
| 6916 instrumentation.log(); | 7374 instrumentation.log(); |
| 6917 } | 7375 } |
| 6918 } | 7376 } |
| 6919 | 7377 |
| 7378 ResolvableHtmlUnit computeResolvableAngularComponentHtmlUnit(Source source) =>
_basis.computeResolvableAngularComponentHtmlUnit(source); |
| 7379 |
| 6920 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => _
basis.computeResolvableCompilationUnit(source); | 7380 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source) => _
basis.computeResolvableCompilationUnit(source); |
| 6921 | 7381 |
| 6922 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) => _basis.computeR
esolvableHtmlUnit(source); | 7382 ResolvableHtmlUnit computeResolvableHtmlUnit(Source source) => _basis.computeR
esolvableHtmlUnit(source); |
| 6923 | 7383 |
| 6924 AnalysisContext extractContext(SourceContainer container) { | 7384 AnalysisContext extractContext(SourceContainer container) { |
| 6925 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
extractContext"); | 7385 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
extractContext"); |
| 6926 try { | 7386 try { |
| 6927 instrumentation.metric3("contextId", _contextId); | 7387 instrumentation.metric3("contextId", _contextId); |
| 6928 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte
xtImpl(); | 7388 InstrumentedAnalysisContextImpl newContext = new InstrumentedAnalysisConte
xtImpl(); |
| 6929 _basis.extractContextInto(container, newContext._basis); | 7389 _basis.extractContextInto(container, newContext._basis); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7071 List<Source> ret = _basis.getLibrariesDependingOn(librarySource); | 7531 List<Source> ret = _basis.getLibrariesDependingOn(librarySource); |
| 7072 if (ret != null) { | 7532 if (ret != null) { |
| 7073 instrumentation.metric2("Source-count", ret.length); | 7533 instrumentation.metric2("Source-count", ret.length); |
| 7074 } | 7534 } |
| 7075 return ret; | 7535 return ret; |
| 7076 } finally { | 7536 } finally { |
| 7077 instrumentation.log(); | 7537 instrumentation.log(); |
| 7078 } | 7538 } |
| 7079 } | 7539 } |
| 7080 | 7540 |
| 7081 List<AngularElement> getLibraryAngularElements(Source source) { | |
| 7082 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibraryAngularElements"); | |
| 7083 try { | |
| 7084 instrumentation.metric3("contextId", _contextId); | |
| 7085 return _basis.getLibraryAngularElements(source); | |
| 7086 } finally { | |
| 7087 instrumentation.log(); | |
| 7088 } | |
| 7089 } | |
| 7090 | |
| 7091 LibraryElement getLibraryElement(Source source) { | 7541 LibraryElement getLibraryElement(Source source) { |
| 7092 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibraryElement"); | 7542 InstrumentationBuilder instrumentation = Instrumentation.builder2("Analysis-
getLibraryElement"); |
| 7093 try { | 7543 try { |
| 7094 instrumentation.metric3("contextId", _contextId); | 7544 instrumentation.metric3("contextId", _contextId); |
| 7095 return _basis.getLibraryElement(source); | 7545 return _basis.getLibraryElement(source); |
| 7096 } finally { | 7546 } finally { |
| 7097 instrumentation.log(); | 7547 instrumentation.log(); |
| 7098 } | 7548 } |
| 7099 } | 7549 } |
| 7100 | 7550 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7381 * does not represent a library, or if the library does not import any other l
ibraries. | 7831 * does not represent a library, or if the library does not import any other l
ibraries. |
| 7382 * | 7832 * |
| 7383 * @param source the source representing the library whose imports are to be r
eturned | 7833 * @param source the source representing the library whose imports are to be r
eturned |
| 7384 * @return the sources of the libraries that are imported by the given library | 7834 * @return the sources of the libraries that are imported by the given library |
| 7385 * @throws AnalysisException if the imported libraries could not be computed | 7835 * @throws AnalysisException if the imported libraries could not be computed |
| 7386 */ | 7836 */ |
| 7387 List<Source> computeImportedLibraries(Source source); | 7837 List<Source> computeImportedLibraries(Source source); |
| 7388 | 7838 |
| 7389 /** | 7839 /** |
| 7390 * Return an AST structure corresponding to the given source, but ensure that
the structure has | 7840 * Return an AST structure corresponding to the given source, but ensure that
the structure has |
| 7841 * not already been resolved and will not be resolved by any other threads. |
| 7842 * |
| 7843 * @param source the compilation unit for which an AST structure should be ret
urned |
| 7844 * @return the AST structure representing the content of the source |
| 7845 * @throws AnalysisException if the analysis could not be performed |
| 7846 */ |
| 7847 ResolvableHtmlUnit computeResolvableAngularComponentHtmlUnit(Source source); |
| 7848 |
| 7849 /** |
| 7850 * Return an AST structure corresponding to the given source, but ensure that
the structure has |
| 7391 * not already been resolved and will not be resolved by any other threads or
in any other | 7851 * not already been resolved and will not be resolved by any other threads or
in any other |
| 7392 * library. | 7852 * library. |
| 7393 * | 7853 * |
| 7394 * @param source the compilation unit for which an AST structure should be ret
urned | 7854 * @param source the compilation unit for which an AST structure should be ret
urned |
| 7395 * @return the AST structure representing the content of the source | 7855 * @return the AST structure representing the content of the source |
| 7396 * @throws AnalysisException if the analysis could not be performed | 7856 * @throws AnalysisException if the analysis could not be performed |
| 7397 */ | 7857 */ |
| 7398 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source); | 7858 ResolvableCompilationUnit computeResolvableCompilationUnit(Source source); |
| 7399 | 7859 |
| 7400 /** | 7860 /** |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7734 /** | 8194 /** |
| 7735 * Initialize a newly created holder to hold the given values. | 8195 * Initialize a newly created holder to hold the given values. |
| 7736 * | 8196 * |
| 7737 * @param modificationTime the modification time of the source from which the
data was created | 8197 * @param modificationTime the modification time of the source from which the
data was created |
| 7738 * @param unit the data that was created from the source | 8198 * @param unit the data that was created from the source |
| 7739 */ | 8199 */ |
| 7740 TimestampedData(this.modificationTime, this.data); | 8200 TimestampedData(this.modificationTime, this.data); |
| 7741 } | 8201 } |
| 7742 | 8202 |
| 7743 /** | 8203 /** |
| 8204 * Instances of the class `WorkManager` manage a list of sources that need to ha
ve analysis |
| 8205 * work performed on them. |
| 8206 */ |
| 8207 class WorkManager { |
| 8208 /** |
| 8209 * An array containing the various queues is priority order. |
| 8210 */ |
| 8211 List<List<Source>> _workQueues; |
| 8212 |
| 8213 /** |
| 8214 * Initialize a newly created manager to have no work queued up. |
| 8215 */ |
| 8216 WorkManager() { |
| 8217 int queueCount = WorkManagerPriority.values.length; |
| 8218 _workQueues = new List<List>(queueCount); |
| 8219 for (int i = 0; i < queueCount; i++) { |
| 8220 _workQueues[i] = new List<Source>(); |
| 8221 } |
| 8222 } |
| 8223 |
| 8224 /** |
| 8225 * Record that the given source needs to be analyzed. The priority level is us
ed to control when |
| 8226 * the source will be analyzed with respect to other sources. |
| 8227 * |
| 8228 * @param source the source that needs to be analyzed |
| 8229 * @param priority the priority level of the source |
| 8230 */ |
| 8231 void add(Source source, WorkManagerPriority priority) { |
| 8232 // TODO(brianwilkerson) Optimize the order of the libraries so that librarie
s that depend on |
| 8233 // other libraries get analyzed after the other libraries. |
| 8234 int queueCount = _workQueues.length; |
| 8235 int ordinal = priority.ordinal; |
| 8236 for (int i = 0; i < queueCount; i++) { |
| 8237 List<Source> queue = _workQueues[i]; |
| 8238 if (i == ordinal) { |
| 8239 if (!queue.contains(source)) { |
| 8240 queue.add(source); |
| 8241 } |
| 8242 } else { |
| 8243 queue.remove(source); |
| 8244 } |
| 8245 } |
| 8246 } |
| 8247 |
| 8248 /** |
| 8249 * Return the next source for which some analysis work needs to be done. |
| 8250 * |
| 8251 * @return the next source for which some analysis work needs to be done |
| 8252 */ |
| 8253 Source get nextSource { |
| 8254 int queueCount = _workQueues.length; |
| 8255 for (int i = 0; i < queueCount; i++) { |
| 8256 List<Source> queue = _workQueues[i]; |
| 8257 if (!queue.isEmpty) { |
| 8258 return queue[0]; |
| 8259 } |
| 8260 } |
| 8261 return null; |
| 8262 } |
| 8263 |
| 8264 /** |
| 8265 * Record that the given source is fully analyzed. |
| 8266 * |
| 8267 * @param source the source that is fully analyzed |
| 8268 */ |
| 8269 void remove(Source source) { |
| 8270 int queueCount = _workQueues.length; |
| 8271 for (int i = 0; i < queueCount; i++) { |
| 8272 _workQueues[i].remove(source); |
| 8273 } |
| 8274 } |
| 8275 } |
| 8276 |
| 8277 /** |
| 8278 * The enumerated type `Priority` defines the priority levels used to return sou
rces in an |
| 8279 * optimal order. |
| 8280 */ |
| 8281 class WorkManagerPriority extends Enum<WorkManagerPriority> { |
| 8282 /** |
| 8283 * Used for a Dart source that is known to be a part contained in a library th
at was recently |
| 8284 * resolved. These parts are given a higher priority because there is a high p
robability that |
| 8285 * their AST structure is still in the cache and therefore would not need to b
e re-created. |
| 8286 */ |
| 8287 static final WorkManagerPriority PRIORITY_PART = new WorkManagerPriority('PRIO
RITY_PART', 0); |
| 8288 |
| 8289 /** |
| 8290 * Used for a Dart source that is known to be a library. |
| 8291 */ |
| 8292 static final WorkManagerPriority LIBRARY = new WorkManagerPriority('LIBRARY',
1); |
| 8293 |
| 8294 /** |
| 8295 * Used for a Dart source that is known to be a part but whose library has not
yet been |
| 8296 * resolved. |
| 8297 */ |
| 8298 static final WorkManagerPriority NORMAL_PART = new WorkManagerPriority('NORMAL
_PART', 2); |
| 8299 |
| 8300 /** |
| 8301 * Used for a Dart source whose kind is unknown. |
| 8302 */ |
| 8303 static final WorkManagerPriority UNKNOWN = new WorkManagerPriority('UNKNOWN',
3); |
| 8304 |
| 8305 /** |
| 8306 * Used for an HTML source. |
| 8307 */ |
| 8308 static final WorkManagerPriority HTML = new WorkManagerPriority('HTML', 4); |
| 8309 |
| 8310 static final List<WorkManagerPriority> values = [PRIORITY_PART, LIBRARY, NORMA
L_PART, UNKNOWN, HTML]; |
| 8311 |
| 8312 WorkManagerPriority(String name, int ordinal) : super(name, ordinal); |
| 8313 } |
| 8314 |
| 8315 /** |
| 8316 * An [Expression] with optional [AngularFilterNode]s. |
| 8317 * |
| 8318 * @coverage dart.engine.ast |
| 8319 */ |
| 8320 class AngularExpression { |
| 8321 /** |
| 8322 * The [Expression] to apply filters to. |
| 8323 */ |
| 8324 final Expression expression; |
| 8325 |
| 8326 /** |
| 8327 * The filters to apply. |
| 8328 */ |
| 8329 final List<AngularFilterNode> filters; |
| 8330 |
| 8331 AngularExpression(this.expression, this.filters); |
| 8332 |
| 8333 /** |
| 8334 * Return the offset of the character immediately following the last character
of this node's |
| 8335 * source range. This is equivalent to `node.getOffset() + node.getLength()`. |
| 8336 * |
| 8337 * @return the offset of the character just past the node's source range |
| 8338 */ |
| 8339 int get end { |
| 8340 if (filters.isEmpty) { |
| 8341 return expression.end; |
| 8342 } |
| 8343 AngularFilterNode lastFilter = filters[filters.length - 1]; |
| 8344 List<AngularFilterArgument> filterArguments = lastFilter.arguments; |
| 8345 if (filterArguments.isEmpty) { |
| 8346 return lastFilter.name.end; |
| 8347 } |
| 8348 return filterArguments[filterArguments.length - 1].expression.end; |
| 8349 } |
| 8350 |
| 8351 /** |
| 8352 * Return Dart [Expression]s this Angular expression consists of. |
| 8353 */ |
| 8354 List<Expression> get expressions { |
| 8355 List<Expression> expressions = []; |
| 8356 expressions.add(expression); |
| 8357 for (AngularFilterNode filter in filters) { |
| 8358 expressions.add(filter.name); |
| 8359 for (AngularFilterArgument filterArgument in filter.arguments) { |
| 8360 expressions.addAll(filterArgument.subExpressions); |
| 8361 expressions.add(filterArgument.expression); |
| 8362 } |
| 8363 } |
| 8364 return expressions; |
| 8365 } |
| 8366 |
| 8367 /** |
| 8368 * Return the number of characters in the expression's source range. |
| 8369 */ |
| 8370 int get length => end - offset; |
| 8371 |
| 8372 /** |
| 8373 * Return the offset of the first character in the expression's source range. |
| 8374 */ |
| 8375 int get offset => expression.offset; |
| 8376 } |
| 8377 |
| 8378 /** |
| 8379 * Angular filter argument. |
| 8380 * |
| 8381 * @coverage dart.engine.ast |
| 8382 */ |
| 8383 class AngularFilterArgument { |
| 8384 /** |
| 8385 * The [TokenType#COLON] token. |
| 8386 */ |
| 8387 final Token token; |
| 8388 |
| 8389 /** |
| 8390 * The argument expression. |
| 8391 */ |
| 8392 final Expression expression; |
| 8393 |
| 8394 /** |
| 8395 * The optional sub-[Expression]s. |
| 8396 */ |
| 8397 List<Expression> subExpressions = Expression.EMPTY_ARRAY; |
| 8398 |
| 8399 AngularFilterArgument(this.token, this.expression); |
| 8400 } |
| 8401 |
| 8402 /** |
| 8403 * Angular filter node. |
| 8404 * |
| 8405 * @coverage dart.engine.ast |
| 8406 */ |
| 8407 class AngularFilterNode { |
| 8408 /** |
| 8409 * The [TokenType#BAR] token. |
| 8410 */ |
| 8411 final Token token; |
| 8412 |
| 8413 /** |
| 8414 * The name of the filter. |
| 8415 */ |
| 8416 final SimpleIdentifier name; |
| 8417 |
| 8418 /** |
| 8419 * The arguments for this filter. |
| 8420 */ |
| 8421 final List<AngularFilterArgument> arguments; |
| 8422 |
| 8423 AngularFilterNode(this.token, this.name, this.arguments); |
| 8424 } |
| 8425 |
| 8426 /** |
| 7744 * Instances of the class [AngularHtmlUnitResolver] resolve Angular specific exp
ressions. | 8427 * Instances of the class [AngularHtmlUnitResolver] resolve Angular specific exp
ressions. |
| 7745 */ | 8428 */ |
| 7746 class AngularHtmlUnitResolver extends ht.RecursiveXmlVisitor<Object> { | 8429 class AngularHtmlUnitResolver extends ht.RecursiveXmlVisitor<Object> { |
| 7747 static int _OPENING_DELIMITER_CHAR = 0x7B; | |
| 7748 | |
| 7749 static int _CLOSING_DELIMITER_CHAR = 0x7D; | |
| 7750 | |
| 7751 static String _OPENING_DELIMITER = "{{"; | |
| 7752 | |
| 7753 static String _CLOSING_DELIMITER = "}}"; | |
| 7754 | |
| 7755 static int _OPENING_DELIMITER_LENGTH = _OPENING_DELIMITER.length; | |
| 7756 | |
| 7757 static int _CLOSING_DELIMITER_LENGTH = _CLOSING_DELIMITER.length; | |
| 7758 | |
| 7759 static String _NG_APP = "ng-app"; | 8430 static String _NG_APP = "ng-app"; |
| 7760 | 8431 |
| 7761 /** | 8432 /** |
| 7762 * Checks if given [Element] is an artificial local variable and returns corre
sponding | 8433 * Checks if given [Element] is an artificial local variable and returns corre
sponding |
| 7763 * [AngularElement], or `null` otherwise. | 8434 * [AngularElement], or `null` otherwise. |
| 7764 */ | 8435 */ |
| 7765 static AngularElement getAngularElement(Element element) { | 8436 static AngularElement getAngularElement(Element element) { |
| 7766 // may be artificial local variable, replace with AngularElement | 8437 // may be artificial local variable, replace with AngularElement |
| 7767 if (element is LocalVariableElement) { | 8438 if (element is LocalVariableElement) { |
| 7768 LocalVariableElement local = element; | 8439 LocalVariableElement local = element; |
| 7769 List<ToolkitObjectElement> toolkitObjects = local.toolkitObjects; | 8440 List<ToolkitObjectElement> toolkitObjects = local.toolkitObjects; |
| 7770 if (toolkitObjects.length == 1 && toolkitObjects[0] is AngularElement) { | 8441 if (toolkitObjects.length == 1 && toolkitObjects[0] is AngularElement) { |
| 7771 return toolkitObjects[0] as AngularElement; | 8442 return toolkitObjects[0] as AngularElement; |
| 7772 } | 8443 } |
| 7773 } | 8444 } |
| 7774 // not a special Element | 8445 // not a special Element |
| 7775 return null; | 8446 return null; |
| 7776 } | 8447 } |
| 7777 | 8448 |
| 7778 /** | 8449 /** |
| 8450 * Returns the array of all top-level Angular elements that could be used in t
he application with |
| 8451 * this entry point. Maybe `null` of not an Angular entry point. |
| 8452 */ |
| 8453 static List<AngularElement> getAngularElements(AnalysisContext context, ht.Htm
lUnit unit) { |
| 8454 if (hasAngularAnnotation(unit)) { |
| 8455 CompilationUnit dartUnit = getDartUnit(context, unit); |
| 8456 if (dartUnit != null) { |
| 8457 LibraryElement libraryElement = dartUnit.element.library; |
| 8458 return getAngularElements2(libraryElement); |
| 8459 } |
| 8460 } |
| 8461 return null; |
| 8462 } |
| 8463 |
| 8464 /** |
| 7779 * @return `true` if the given [HtmlUnit] has <code>ng-app</code> annotation. | 8465 * @return `true` if the given [HtmlUnit] has <code>ng-app</code> annotation. |
| 7780 */ | 8466 */ |
| 7781 static bool hasAngularAnnotation(ht.HtmlUnit htmlUnit) { | 8467 static bool hasAngularAnnotation(ht.HtmlUnit htmlUnit) { |
| 7782 try { | 8468 try { |
| 7783 htmlUnit.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_hasAngular
Annotation()); | 8469 htmlUnit.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_hasAngular
Annotation()); |
| 7784 } on AngularHtmlUnitResolver_FoundAppError catch (e) { | 8470 } on AngularHtmlUnitResolver_FoundAppError catch (e) { |
| 7785 return true; | 8471 return true; |
| 7786 } | 8472 } |
| 7787 return false; | 8473 return false; |
| 7788 } | 8474 } |
| 7789 | 8475 |
| 7790 static SimpleIdentifier createIdentifier(String name, int offset) { | 8476 static SimpleIdentifier createIdentifier(String name, int offset) { |
| 7791 StringToken token = createStringToken(name, offset); | 8477 StringToken token = createStringToken(name, offset); |
| 7792 return new SimpleIdentifier(token); | 8478 return new SimpleIdentifier(token); |
| 7793 } | 8479 } |
| 7794 | 8480 |
| 8481 /** |
| 8482 * Adds [AngularElement] declared by the given top-level [Element]. |
| 8483 * |
| 8484 * @param angularElements the list to fill with top-level [AngularElement]s |
| 8485 * @param classElement the [ClassElement] to get [AngularElement]s from |
| 8486 */ |
| 8487 static void addAngularElements(Set<AngularElement> angularElements, ClassEleme
nt classElement) { |
| 8488 for (ToolkitObjectElement toolkitObject in classElement.toolkitObjects) { |
| 8489 if (toolkitObject is AngularElement) { |
| 8490 angularElements.add(toolkitObject); |
| 8491 } |
| 8492 } |
| 8493 } |
| 8494 |
| 8495 /** |
| 8496 * Returns the array of all top-level Angular elements that could be used in t
his library. |
| 8497 * |
| 8498 * @param libraryElement the [LibraryElement] to analyze |
| 8499 * @return the array of all top-level Angular elements that could be used in t
his library |
| 8500 */ |
| 8501 static void addAngularElements2(Set<AngularElement> angularElements, LibraryEl
ement library, Set<LibraryElement> visited) { |
| 8502 if (!visited.add(library)) { |
| 8503 return; |
| 8504 } |
| 8505 // add Angular elements from current library |
| 8506 for (CompilationUnitElement unit in library.units) { |
| 8507 for (ClassElement type in unit.types) { |
| 8508 addAngularElements(angularElements, type); |
| 8509 } |
| 8510 } |
| 8511 // handle imports |
| 8512 for (ImportElement importElement in library.imports) { |
| 8513 LibraryElement importedLibrary = importElement.importedLibrary; |
| 8514 addAngularElements2(angularElements, importedLibrary, visited); |
| 8515 } |
| 8516 } |
| 8517 |
| 7795 static StringToken createStringToken(String name, int offset) => new StringTok
en(TokenType.IDENTIFIER, name, offset); | 8518 static StringToken createStringToken(String name, int offset) => new StringTok
en(TokenType.IDENTIFIER, name, offset); |
| 7796 | 8519 |
| 8520 /** |
| 8521 * Returns the array of all top-level Angular elements that could be used in t
his library. |
| 8522 * |
| 8523 * @param libraryElement the [LibraryElement] to analyze |
| 8524 * @return the array of all top-level Angular elements that could be used in t
his library |
| 8525 */ |
| 8526 static List<AngularElement> getAngularElements2(LibraryElement libraryElement)
{ |
| 8527 Set<AngularElement> angularElements = new Set(); |
| 8528 addAngularElements2(angularElements, libraryElement, new Set()); |
| 8529 return new List.from(angularElements); |
| 8530 } |
| 8531 |
| 8532 /** |
| 8533 * Returns the external Dart [CompilationUnit] referenced by the given [HtmlUn
it]. |
| 8534 */ |
| 8535 static CompilationUnit getDartUnit(AnalysisContext context, ht.HtmlUnit unit)
{ |
| 8536 for (HtmlScriptElement script in unit.element.scripts) { |
| 8537 if (script is ExternalHtmlScriptElement) { |
| 8538 Source scriptSource = script.scriptSource; |
| 8539 if (scriptSource != null) { |
| 8540 return context.resolveCompilationUnit2(scriptSource, scriptSource); |
| 8541 } |
| 8542 } |
| 8543 } |
| 8544 return null; |
| 8545 } |
| 8546 |
| 7797 InternalAnalysisContext _context; | 8547 InternalAnalysisContext _context; |
| 7798 | 8548 |
| 7799 TypeProvider _typeProvider; | 8549 TypeProvider _typeProvider; |
| 7800 | 8550 |
| 7801 AnalysisErrorListener _errorListener; | 8551 AnalysisErrorListener _errorListener; |
| 7802 | 8552 |
| 7803 Source _source; | 8553 Source _source; |
| 7804 | 8554 |
| 7805 LineInfo _lineInfo; | 8555 LineInfo _lineInfo; |
| 7806 | 8556 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 7831 AngularHtmlUnitResolver(InternalAnalysisContext context, AnalysisErrorListener
errorListener, Source source, LineInfo lineInfo, ht.HtmlUnit unit) { | 8581 AngularHtmlUnitResolver(InternalAnalysisContext context, AnalysisErrorListener
errorListener, Source source, LineInfo lineInfo, ht.HtmlUnit unit) { |
| 7832 this._context = context; | 8582 this._context = context; |
| 7833 this._typeProvider = context.typeProvider; | 8583 this._typeProvider = context.typeProvider; |
| 7834 this._errorListener = errorListener; | 8584 this._errorListener = errorListener; |
| 7835 this._source = source; | 8585 this._source = source; |
| 7836 this._lineInfo = lineInfo; | 8586 this._lineInfo = lineInfo; |
| 7837 this._unit = unit; | 8587 this._unit = unit; |
| 7838 } | 8588 } |
| 7839 | 8589 |
| 7840 /** | 8590 /** |
| 8591 * The [AngularApplicationInfo] for the Web application with this entry point,
may be |
| 8592 * `null` if not an entry point. |
| 8593 */ |
| 8594 AngularApplicationInfo calculateAngularApplication() { |
| 8595 // check if Angular at all |
| 8596 if (!hasAngularAnnotation(_unit)) { |
| 8597 return null; |
| 8598 } |
| 8599 // prepare resolved Dart unit |
| 8600 CompilationUnit dartUnit = getDartUnit(_context, _unit); |
| 8601 if (dartUnit == null) { |
| 8602 return null; |
| 8603 } |
| 8604 // prepare accessible Angular elements |
| 8605 LibraryElement libraryElement = dartUnit.element.library; |
| 8606 List<AngularElement> angularElements = getAngularElements2(libraryElement); |
| 8607 // resolve template URIs |
| 8608 // TODO(scheglov) resolve to HtmlElement to allow F3 ? |
| 8609 for (AngularElement angularElement in angularElements) { |
| 8610 if (angularElement is AngularComponentElement) { |
| 8611 AngularComponentElement component = angularElement; |
| 8612 String templateUri = component.templateUri; |
| 8613 if (templateUri == null) { |
| 8614 continue; |
| 8615 } |
| 8616 try { |
| 8617 Source templateSource = _source.resolveRelative(parseUriWithException(
templateUri)); |
| 8618 if (templateSource == null || !templateSource.exists()) { |
| 8619 templateSource = _context.sourceFactory.resolveUri(_source, "package
:${templateUri}"); |
| 8620 if (templateSource == null || !templateSource.exists()) { |
| 8621 reportError7(component.templateUriOffset, templateUri.length, Angu
larCode.URI_DOES_NOT_EXIST, [templateUri]); |
| 8622 continue; |
| 8623 } |
| 8624 } |
| 8625 if (!AnalysisEngine.isHtmlFileName(templateUri)) { |
| 8626 continue; |
| 8627 } |
| 8628 (component as AngularComponentElementImpl).templateSource = templateSo
urce; |
| 8629 } on URISyntaxException catch (exception) { |
| 8630 reportError7(component.templateUriOffset, templateUri.length, AngularC
ode.INVALID_URI, [templateUri]); |
| 8631 } |
| 8632 } |
| 8633 } |
| 8634 // done |
| 8635 return new AngularApplicationInfo(_source, angularElements); |
| 8636 } |
| 8637 |
| 8638 /** |
| 7841 * Resolves [source] as an [AngularComponentElement] template file. | 8639 * Resolves [source] as an [AngularComponentElement] template file. |
| 7842 * | 8640 * |
| 7843 * @param angularElements the [AngularElement]s accessible in the component's
library, not | 8641 * @param application the Angular application we are resolving for |
| 7844 * `null` | |
| 7845 * @param component the [AngularComponentElement] to resolve template for, not
`null` | 8642 * @param component the [AngularComponentElement] to resolve template for, not
`null` |
| 7846 */ | 8643 */ |
| 7847 void resolveComponentTemplate(List<AngularElement> angularElements, AngularCom
ponentElement component) { | 8644 void resolveComponentTemplate(AngularApplicationInfo application, AngularCompo
nentElement component) { |
| 7848 _isAngular = true; | 8645 _isAngular = true; |
| 7849 resolveInternal(angularElements, component); | 8646 resolveInternal(application.elements, component); |
| 7850 } | 8647 } |
| 7851 | 8648 |
| 7852 /** | 8649 /** |
| 7853 * Resolves [source] as an entry-point HTML file, that references an external
Dart script. | 8650 * Resolves [source] as an Angular application entry point. |
| 7854 */ | 8651 */ |
| 7855 void resolveEntryPoint() { | 8652 void resolveEntryPoint(AngularApplicationInfo application) { |
| 7856 // check if Angular at all | 8653 resolveInternal(application.elements, null); |
| 7857 if (!hasAngularAnnotation(_unit)) { | |
| 7858 return; | |
| 7859 } | |
| 7860 // prepare accessible Angular elements | |
| 7861 List<AngularElement> angularElements; | |
| 7862 { | |
| 7863 // prepare external Dart script source | |
| 7864 Source dartSource = getDartSource(_unit); | |
| 7865 if (dartSource == null) { | |
| 7866 return; | |
| 7867 } | |
| 7868 // ensure resolved | |
| 7869 _context.resolveCompilationUnit2(dartSource, dartSource); | |
| 7870 // get cached Angular elements | |
| 7871 angularElements = _context.getLibraryAngularElements(dartSource); | |
| 7872 } | |
| 7873 // perform resolution | |
| 7874 resolveInternal(angularElements, null); | |
| 7875 } | 8654 } |
| 7876 | 8655 |
| 7877 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { | 8656 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { |
| 7878 parseEmbeddedExpressions2(node); | 8657 parseEmbeddedExpressions2(node); |
| 7879 resolveExpressions(node.expressions); | 8658 resolveExpressions(node.expressions); |
| 7880 return super.visitXmlAttributeNode(node); | 8659 return super.visitXmlAttributeNode(node); |
| 7881 } | 8660 } |
| 7882 | 8661 |
| 7883 Object visitXmlTagNode(ht.XmlTagNode node) { | 8662 Object visitXmlTagNode(ht.XmlTagNode node) { |
| 7884 bool wasAngular = _isAngular; | 8663 bool wasAngular = _isAngular; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7969 } | 8748 } |
| 7970 return null; | 8749 return null; |
| 7971 } | 8750 } |
| 7972 | 8751 |
| 7973 /** | 8752 /** |
| 7974 * @return the [TypeProvider] of the [AnalysisContext]. | 8753 * @return the [TypeProvider] of the [AnalysisContext]. |
| 7975 */ | 8754 */ |
| 7976 TypeProvider get typeProvider => _typeProvider; | 8755 TypeProvider get typeProvider => _typeProvider; |
| 7977 | 8756 |
| 7978 /** | 8757 /** |
| 8758 * Parses given [String] as an [AngularExpression] at the given offset. |
| 8759 */ |
| 8760 AngularExpression parseAngularExpression(String contents, int offset) => parse
AngularExpression2(contents, 0, contents.length, offset); |
| 8761 |
| 8762 AngularExpression parseAngularExpression2(String contents, int startIndex, int
endIndex, int offset) { |
| 8763 Token token = scanDart(contents, startIndex, endIndex, offset); |
| 8764 return parseAngularExpression3(token); |
| 8765 } |
| 8766 |
| 8767 AngularExpression parseAngularExpression3(Token token) { |
| 8768 List<Token> tokens = splitAtBar(token); |
| 8769 Expression mainExpression = parseDartExpression3(tokens[0]); |
| 8770 // parse filters |
| 8771 List<AngularFilterNode> filters = []; |
| 8772 for (int i = 1; i < tokens.length; i++) { |
| 8773 Token filterToken = tokens[i]; |
| 8774 Token barToken = filterToken; |
| 8775 filterToken = filterToken.next; |
| 8776 // TODO(scheglov) report missing identifier |
| 8777 SimpleIdentifier name = parseDartExpression3(filterToken) as SimpleIdentif
ier; |
| 8778 filterToken = name.endToken.next; |
| 8779 // parse arguments |
| 8780 List<AngularFilterArgument> arguments = []; |
| 8781 while (filterToken.type != TokenType.EOF) { |
| 8782 // skip ":" |
| 8783 Token colonToken = filterToken; |
| 8784 if (identical(colonToken.type, TokenType.COLON)) { |
| 8785 filterToken = filterToken.next; |
| 8786 } else { |
| 8787 reportError8(colonToken, AngularCode.MISSING_FILTER_COLON, []); |
| 8788 } |
| 8789 // parse argument |
| 8790 Expression argument = parseDartExpression3(filterToken); |
| 8791 arguments.add(new AngularFilterArgument(colonToken, argument)); |
| 8792 // next token |
| 8793 filterToken = argument.endToken.next; |
| 8794 } |
| 8795 filters.add(new AngularFilterNode(barToken, name, arguments)); |
| 8796 } |
| 8797 // done |
| 8798 return new AngularExpression(mainExpression, filters); |
| 8799 } |
| 8800 |
| 8801 /** |
| 7979 * Parses given [String] as an [Expression] at the given offset. | 8802 * Parses given [String] as an [Expression] at the given offset. |
| 7980 */ | 8803 */ |
| 7981 Expression parseExpression(String contents, int offset) => parseExpression2(co
ntents, 0, contents.length, offset); | 8804 Expression parseDartExpression(String contents, int offset) => parseDartExpres
sion2(contents, 0, contents.length, offset); |
| 7982 | 8805 |
| 7983 Expression parseExpression2(String contents, int startIndex, int endIndex, int
offset) { | 8806 Expression parseDartExpression2(String contents, int startIndex, int endIndex,
int offset) { |
| 7984 Token token = scanDart(contents, startIndex, endIndex, offset); | 8807 Token token = scanDart(contents, startIndex, endIndex, offset); |
| 7985 return parseExpression3(token); | 8808 return parseDartExpression3(token); |
| 7986 } | 8809 } |
| 7987 | 8810 |
| 7988 Expression parseExpression3(Token token) => ht.HtmlParser.parseEmbeddedExpress
ion(_source, token, _errorListener); | 8811 Expression parseDartExpression3(Token token) { |
| 8812 Parser parser = new Parser(_source, _errorListener); |
| 8813 return parser.parseExpression(token); |
| 8814 } |
| 7989 | 8815 |
| 7990 void popNameScope() { | 8816 void popNameScope() { |
| 7991 _nameScope = _resolver.popNameScope(); | 8817 _nameScope = _resolver.popNameScope(); |
| 7992 } | 8818 } |
| 7993 | 8819 |
| 7994 void pushNameScope() { | 8820 void pushNameScope() { |
| 7995 _nameScope = _resolver.pushNameScope(); | 8821 _nameScope = _resolver.pushNameScope(); |
| 7996 } | 8822 } |
| 7997 | 8823 |
| 7998 /** | 8824 /** |
| 7999 * Reports given [ErrorCode] at the given [ASTNode]. | 8825 * Reports given [ErrorCode] at the given [ASTNode]. |
| 8000 */ | 8826 */ |
| 8001 void reportError(ASTNode node, ErrorCode errorCode, List<Object> arguments) { | 8827 void reportError(ASTNode node, ErrorCode errorCode, List<Object> arguments) { |
| 8002 reportError7(node.offset, node.length, errorCode, arguments); | 8828 reportError7(node.offset, node.length, errorCode, arguments); |
| 8003 } | 8829 } |
| 8004 | 8830 |
| 8005 /** | 8831 /** |
| 8006 * Reports given [ErrorCode] at the given position. | 8832 * Reports given [ErrorCode] at the given position. |
| 8007 */ | 8833 */ |
| 8008 void reportError7(int offset, int length, ErrorCode errorCode, List<Object> ar
guments) { | 8834 void reportError7(int offset, int length, ErrorCode errorCode, List<Object> ar
guments) { |
| 8009 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error
Code, arguments)); | 8835 _errorListener.onError(new AnalysisError.con2(_source, offset, length, error
Code, arguments)); |
| 8010 } | 8836 } |
| 8011 | 8837 |
| 8012 /** | 8838 /** |
| 8839 * Reports given [ErrorCode] at the given [Token]. |
| 8840 */ |
| 8841 void reportError8(Token token, ErrorCode errorCode, List<Object> arguments) { |
| 8842 reportError7(token.offset, token.length, errorCode, arguments); |
| 8843 } |
| 8844 |
| 8845 void resolveExpression(AngularExpression angularExpression) { |
| 8846 List<Expression> dartExpressions = angularExpression.expressions; |
| 8847 for (Expression dartExpression in dartExpressions) { |
| 8848 resolveNode(dartExpression); |
| 8849 } |
| 8850 } |
| 8851 |
| 8852 /** |
| 8013 * Resolves given [ASTNode] using [resolver]. | 8853 * Resolves given [ASTNode] using [resolver]. |
| 8014 */ | 8854 */ |
| 8015 void resolveNode(ASTNode node) { | 8855 void resolveNode(ASTNode node) { |
| 8016 node.accept(_resolver); | 8856 node.accept(_resolver); |
| 8017 } | 8857 } |
| 8018 | 8858 |
| 8019 Token scanDart(String contents, int startIndex, int endIndex, int offset) => h
t.HtmlParser.scanDartSource(_source, _lineInfo, contents.substring(startIndex, e
ndIndex), offset + startIndex, _errorListener); | 8859 Token scanDart(String contents, int startIndex, int endIndex, int offset) => h
t.HtmlParser.scanDartSource(_source, _lineInfo, contents.substring(startIndex, e
ndIndex), offset + startIndex, _errorListener); |
| 8020 | 8860 |
| 8021 /** | 8861 /** |
| 8022 * Puts into [libraryElement] an artificial [LibraryElementImpl] for this HTML | 8862 * Puts into [libraryElement] an artificial [LibraryElementImpl] for this HTML |
| 8023 * [Source]. | 8863 * [Source]. |
| 8024 */ | 8864 */ |
| 8025 void createLibraryElement() { | 8865 void createLibraryElement() { |
| 8026 // create CompilationUnitElementImpl | 8866 // create CompilationUnitElementImpl |
| 8027 String unitName = _source.shortName; | 8867 String unitName = _source.shortName; |
| 8028 _unitElement = new CompilationUnitElementImpl(unitName); | 8868 _unitElement = new CompilationUnitElementImpl(unitName); |
| 8029 _unitElement.source = _source; | 8869 _unitElement.source = _source; |
| 8030 // create LibraryElementImpl | 8870 // create LibraryElementImpl |
| 8031 _libraryElement = new LibraryElementImpl(_context, null); | 8871 _libraryElement = new LibraryElementImpl(_context, null); |
| 8032 _libraryElement.definingCompilationUnit = _unitElement; | 8872 _libraryElement.definingCompilationUnit = _unitElement; |
| 8873 _libraryElement.angularHtml = true; |
| 8874 _injectedLibraries.add(_libraryElement); |
| 8033 // create FunctionElementImpl | 8875 // create FunctionElementImpl |
| 8034 _functionElement = new FunctionElementImpl.con2(0); | 8876 _functionElement = new FunctionElementImpl.con2(0); |
| 8035 _unitElement.functions = <FunctionElement> [_functionElement]; | 8877 _unitElement.functions = <FunctionElement> [_functionElement]; |
| 8036 } | 8878 } |
| 8037 | 8879 |
| 8038 /** | 8880 /** |
| 8039 * Creates new [NgProcessor] for the given [AngularElement], maybe `null` if n
ot | 8881 * Creates new [NgProcessor] for the given [AngularElement], maybe `null` if n
ot |
| 8040 * supported. | 8882 * supported. |
| 8041 */ | 8883 */ |
| 8042 NgProcessor createProcessor(AngularElement element) { | 8884 NgProcessor createProcessor(AngularElement element) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 8066 // add Scope variables - no type, no location, just to avoid warnings | 8908 // add Scope variables - no type, no location, just to avoid warnings |
| 8067 { | 8909 { |
| 8068 Type2 type = _typeProvider.dynamicType; | 8910 Type2 type = _typeProvider.dynamicType; |
| 8069 _topNameScope.define(createLocalVariable2(type, "\$id")); | 8911 _topNameScope.define(createLocalVariable2(type, "\$id")); |
| 8070 _topNameScope.define(createLocalVariable2(type, "\$parent")); | 8912 _topNameScope.define(createLocalVariable2(type, "\$parent")); |
| 8071 _topNameScope.define(createLocalVariable2(type, "\$root")); | 8913 _topNameScope.define(createLocalVariable2(type, "\$root")); |
| 8072 } | 8914 } |
| 8073 } | 8915 } |
| 8074 | 8916 |
| 8075 /** | 8917 /** |
| 8076 * Returns the external Dart script [Source] referenced by the given [HtmlUnit
]. | 8918 * Defines variable for the given [AngularElement]. |
| 8077 */ | 8919 */ |
| 8078 Source getDartSource(ht.HtmlUnit unit) { | 8920 void defineTopElementVariable(AngularElement element) { |
| 8079 for (HtmlScriptElement script in unit.element.scripts) { | 8921 ClassElement classElement = element.enclosingElement as ClassElement; |
| 8080 if (script is ExternalHtmlScriptElement) { | 8922 InterfaceType type = classElement.type; |
| 8081 Source scriptSource = script.scriptSource; | 8923 LocalVariableElementImpl variable = createLocalVariable2(type, element.name)
; |
| 8082 if (scriptSource != null) { | 8924 defineTopVariable(variable); |
| 8083 return scriptSource; | 8925 variable.toolkitObjects = <AngularElement> [element]; |
| 8084 } | |
| 8085 } | |
| 8086 } | |
| 8087 return null; | |
| 8088 } | 8926 } |
| 8089 | 8927 |
| 8090 /** | 8928 /** |
| 8091 * Parse the value of the given token for embedded expressions, and add any em
bedded expressions | 8929 * Parse the value of the given token for embedded expressions, and add any em
bedded expressions |
| 8092 * that are found to the given list of expressions. | 8930 * that are found to the given list of expressions. |
| 8093 * | 8931 * |
| 8094 * @param expressions the list to which embedded expressions are to be added | 8932 * @param expressions the list to which embedded expressions are to be added |
| 8095 * @param token the token whose value is to be parsed | 8933 * @param token the token whose value is to be parsed |
| 8096 */ | 8934 */ |
| 8097 void parseEmbeddedExpressions(List<ht.EmbeddedExpression> expressions, ht.Toke
n token) { | 8935 void parseEmbeddedExpressions(List<AngularMoustacheXmlExpression> expressions,
ht.Token token) { |
| 8098 // prepare Token information | 8936 // prepare Token information |
| 8099 String lexeme = token.lexeme; | 8937 String lexeme = token.lexeme; |
| 8100 int offset = token.offset; | 8938 int offset = token.offset; |
| 8101 // find expressions between {{ and }} | 8939 // find expressions between {{ and }} |
| 8102 int startIndex = StringUtilities.indexOf2(lexeme, 0, _OPENING_DELIMITER_CHAR
, _OPENING_DELIMITER_CHAR); | 8940 int startIndex = StringUtilities.indexOf2(lexeme, 0, AngularMoustacheXmlExpr
ession.OPENING_DELIMITER_CHAR, AngularMoustacheXmlExpression.OPENING_DELIMITER_C
HAR); |
| 8103 while (startIndex >= 0) { | 8941 while (startIndex >= 0) { |
| 8104 int endIndex = StringUtilities.indexOf2(lexeme, startIndex + _OPENING_DELI
MITER_LENGTH, _CLOSING_DELIMITER_CHAR, _CLOSING_DELIMITER_CHAR); | 8942 int endIndex = StringUtilities.indexOf2(lexeme, startIndex + AngularMousta
cheXmlExpression.OPENING_DELIMITER_LENGTH, AngularMoustacheXmlExpression.CLOSING
_DELIMITER_CHAR, AngularMoustacheXmlExpression.CLOSING_DELIMITER_CHAR); |
| 8105 if (endIndex < 0) { | 8943 if (endIndex < 0) { |
| 8106 // TODO(brianwilkerson) Should we report this error or will it be report
ed by something else? | 8944 // TODO(brianwilkerson) Should we report this error or will it be report
ed by something else? |
| 8107 return; | 8945 return; |
| 8108 } else if (startIndex + _OPENING_DELIMITER_LENGTH < endIndex) { | 8946 } else if (startIndex + AngularMoustacheXmlExpression.OPENING_DELIMITER_LE
NGTH < endIndex) { |
| 8109 startIndex += _OPENING_DELIMITER_LENGTH; | 8947 startIndex += AngularMoustacheXmlExpression.OPENING_DELIMITER_LENGTH; |
| 8110 Expression expression = parseExpression2(lexeme, startIndex, endIndex, o
ffset); | 8948 AngularExpression expression = parseAngularExpression2(lexeme, startInde
x, endIndex, offset); |
| 8111 expressions.add(new ht.EmbeddedExpression(startIndex, expression, endInd
ex)); | 8949 expressions.add(new AngularMoustacheXmlExpression(startIndex, endIndex,
expression)); |
| 8112 } | 8950 } |
| 8113 startIndex = StringUtilities.indexOf2(lexeme, endIndex + _CLOSING_DELIMITE
R_LENGTH, _OPENING_DELIMITER_CHAR, _OPENING_DELIMITER_CHAR); | 8951 startIndex = StringUtilities.indexOf2(lexeme, endIndex + AngularMoustacheX
mlExpression.CLOSING_DELIMITER_LENGTH, AngularMoustacheXmlExpression.OPENING_DEL
IMITER_CHAR, AngularMoustacheXmlExpression.OPENING_DELIMITER_CHAR); |
| 8114 } | 8952 } |
| 8115 } | 8953 } |
| 8116 | 8954 |
| 8117 void parseEmbeddedExpressions2(ht.XmlAttributeNode node) { | 8955 void parseEmbeddedExpressions2(ht.XmlAttributeNode node) { |
| 8118 List<ht.EmbeddedExpression> expressions = new List<ht.EmbeddedExpression>(); | 8956 List<AngularMoustacheXmlExpression> expressions = []; |
| 8119 parseEmbeddedExpressions(expressions, node.valueToken); | 8957 parseEmbeddedExpressions(expressions, node.valueToken); |
| 8120 if (!expressions.isEmpty) { | 8958 if (!expressions.isEmpty) { |
| 8121 node.expressions = new List.from(expressions); | 8959 node.expressions = new List.from(expressions); |
| 8122 } | 8960 } |
| 8123 } | 8961 } |
| 8124 | 8962 |
| 8125 void parseEmbeddedExpressions3(ht.XmlTagNode node) { | 8963 void parseEmbeddedExpressions3(ht.XmlTagNode node) { |
| 8126 List<ht.EmbeddedExpression> expressions = new List<ht.EmbeddedExpression>(); | 8964 List<AngularMoustacheXmlExpression> expressions = []; |
| 8127 ht.Token token = node.attributeEnd; | 8965 ht.Token token = node.attributeEnd; |
| 8128 ht.Token endToken = node.endToken; | 8966 ht.Token endToken = node.endToken; |
| 8129 bool inChild = false; | 8967 bool inChild = false; |
| 8130 while (token != endToken) { | 8968 while (token != endToken) { |
| 8131 for (ht.XmlTagNode child in node.tagNodes) { | 8969 for (ht.XmlTagNode child in node.tagNodes) { |
| 8132 if (identical(token, child.beginToken)) { | 8970 if (identical(token, child.beginToken)) { |
| 8133 inChild = true; | 8971 inChild = true; |
| 8134 break; | 8972 break; |
| 8135 } | 8973 } |
| 8136 if (identical(token, child.endToken)) { | 8974 if (identical(token, child.endToken)) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 8152 } | 8990 } |
| 8153 | 8991 |
| 8154 /** | 8992 /** |
| 8155 * When we inject variable, we give access to the library of its type. | 8993 * When we inject variable, we give access to the library of its type. |
| 8156 */ | 8994 */ |
| 8157 void recordTypeLibraryInjected(LocalVariableElementImpl variable) { | 8995 void recordTypeLibraryInjected(LocalVariableElementImpl variable) { |
| 8158 LibraryElement typeLibrary = variable.type.element.library; | 8996 LibraryElement typeLibrary = variable.type.element.library; |
| 8159 _injectedLibraries.add(typeLibrary); | 8997 _injectedLibraries.add(typeLibrary); |
| 8160 } | 8998 } |
| 8161 | 8999 |
| 8162 void resolveExpressions(List<ht.EmbeddedExpression> expressions) { | 9000 void resolveExpression2(AngularXmlExpression angularXmlExpression) { |
| 8163 for (ht.EmbeddedExpression embeddedExpression in expressions) { | 9001 AngularExpression angularExpression = angularXmlExpression.expression; |
| 8164 Expression expression = embeddedExpression.expression; | 9002 resolveExpression(angularExpression); |
| 8165 resolveNode(expression); | 9003 } |
| 9004 |
| 9005 void resolveExpressions(List<ht.XmlExpression> expressions) { |
| 9006 for (ht.XmlExpression xmlExpression in expressions) { |
| 9007 if (xmlExpression is AngularXmlExpression) { |
| 9008 AngularXmlExpression angularXmlExpression = xmlExpression; |
| 9009 resolveExpression2(angularXmlExpression); |
| 9010 } |
| 8166 } | 9011 } |
| 8167 } | 9012 } |
| 8168 | 9013 |
| 8169 /** | 9014 /** |
| 8170 * Resolves Angular specific expressions and elements in the [source]. | 9015 * Resolves Angular specific expressions and elements in the [source]. |
| 8171 * | 9016 * |
| 8172 * @param angularElements the [AngularElement]s accessible in the component's
library, not | 9017 * @param angularElements the [AngularElement]s accessible in the component's
library, not |
| 8173 * `null` | 9018 * `null` |
| 8174 * @param component the [AngularComponentElement] to resolve template for, may
be | 9019 * @param component the [AngularComponentElement] to resolve template for, may
be |
| 8175 * `null` if not a component template | 9020 * `null` if not a component template |
| 8176 */ | 9021 */ |
| 8177 void resolveInternal(List<AngularElement> angularElements, AngularComponentEle
ment component) { | 9022 void resolveInternal(List<AngularElement> angularElements, AngularComponentEle
ment component) { |
| 8178 this._angularElements = angularElements; | 9023 this._angularElements = angularElements; |
| 8179 // add built-in processors | 9024 // add built-in processors |
| 8180 _processors.add(NgModelProcessor.INSTANCE); | 9025 _processors.add(NgModelProcessor.INSTANCE); |
| 8181 // _processors.add(NgRepeatProcessor.INSTANCE); | 9026 // _processors.add(NgRepeatProcessor.INSTANCE); |
| 9027 // add element's libraries |
| 9028 for (AngularElement angularElement in angularElements) { |
| 9029 _injectedLibraries.add(angularElement.library); |
| 9030 } |
| 8182 // add accessible processors | 9031 // add accessible processors |
| 8183 for (AngularElement angularElement in angularElements) { | 9032 for (AngularElement angularElement in angularElements) { |
| 8184 NgProcessor processor = createProcessor(angularElement); | 9033 NgProcessor processor = createProcessor(angularElement); |
| 8185 if (processor != null) { | 9034 if (processor != null) { |
| 8186 _processors.add(processor); | 9035 _processors.add(processor); |
| 8187 } | 9036 } |
| 8188 } | 9037 } |
| 8189 // prepare Dart library | 9038 // prepare Dart library |
| 8190 createLibraryElement(); | 9039 createLibraryElement(); |
| 8191 _unit.compilationUnitElement = _libraryElement.definingCompilationUnit; | 9040 (_unit.element as HtmlElementImpl).angularCompilationUnit = _unitElement; |
| 8192 // prepare Dart resolver | 9041 // prepare Dart resolver |
| 8193 createResolver(); | 9042 createResolver(); |
| 8194 // may be resolving component template | 9043 // maybe resolving component template |
| 8195 LocalVariableElementImpl componentVariable = null; | |
| 8196 if (component != null) { | 9044 if (component != null) { |
| 8197 ClassElement componentClassElement = component.enclosingElement as ClassEl
ement; | 9045 defineTopElementVariable(component); |
| 8198 InterfaceType componentType = componentClassElement.type; | 9046 } |
| 8199 componentVariable = createLocalVariable2(componentType, component.name); | 9047 // define filters |
| 8200 defineTopVariable(componentVariable); | 9048 for (AngularElement angularElement in angularElements) { |
| 8201 componentVariable.toolkitObjects = <AngularElement> [component]; | 9049 if (angularElement is AngularFilterElement) { |
| 9050 defineTopElementVariable(angularElement); |
| 9051 } |
| 8202 } | 9052 } |
| 8203 // run this HTML visitor | 9053 // run this HTML visitor |
| 8204 _unit.accept(this); | 9054 _unit.accept(this); |
| 8205 // simulate imports for injects | 9055 // simulate imports for injects |
| 8206 { | 9056 { |
| 8207 List<ImportElement> imports = []; | 9057 List<ImportElement> imports = []; |
| 8208 for (LibraryElement injectedLibrary in _injectedLibraries) { | 9058 for (LibraryElement injectedLibrary in _injectedLibraries) { |
| 8209 ImportElementImpl importElement = new ImportElementImpl(-1); | 9059 ImportElementImpl importElement = new ImportElementImpl(-1); |
| 8210 importElement.importedLibrary = injectedLibrary; | 9060 importElement.importedLibrary = injectedLibrary; |
| 8211 imports.add(importElement); | 9061 imports.add(importElement); |
| 8212 } | 9062 } |
| 8213 _libraryElement.imports = new List.from(imports); | 9063 _libraryElement.imports = new List.from(imports); |
| 8214 } | 9064 } |
| 8215 // push conditional errors | 9065 // push conditional errors |
| 8216 for (ProxyConditionalAnalysisError conditionalCode in _resolver.proxyConditi
onalAnalysisErrors) { | 9066 for (ProxyConditionalAnalysisError conditionalCode in _resolver.proxyConditi
onalAnalysisErrors) { |
| 8217 _resolver.reportError(conditionalCode.analysisError); | 9067 _resolver.reportError(conditionalCode.analysisError); |
| 8218 } | 9068 } |
| 8219 } | 9069 } |
| 8220 | 9070 |
| 9071 List<Token> splitAtBar(Token token) { |
| 9072 List<Token> tokens = []; |
| 9073 tokens.add(token); |
| 9074 while (token.type != TokenType.EOF) { |
| 9075 if (identical(token.type, TokenType.BAR)) { |
| 9076 tokens.add(token); |
| 9077 Token eofToken = new Token(TokenType.EOF, 0); |
| 9078 token.previous.setNext(eofToken); |
| 9079 } |
| 9080 token = token.next; |
| 9081 } |
| 9082 return tokens; |
| 9083 } |
| 9084 |
| 8221 /** | 9085 /** |
| 8222 * The "ng-model" directive is special, it contributes to the top-level name s
cope. These models | 9086 * The "ng-model" directive is special, it contributes to the top-level name s
cope. These models |
| 8223 * can be used before actual "ng-model" attribute in HTML. So, we need to defi
ne them once we | 9087 * can be used before actual "ng-model" attribute in HTML. So, we need to defi
ne them once we |
| 8224 * found [NG_APP] context. | 9088 * found [NG_APP] context. |
| 8225 */ | 9089 */ |
| 8226 void visitModelDirectives(ht.XmlTagNode appNode) { | 9090 void visitModelDirectives(ht.XmlTagNode appNode) { |
| 8227 appNode.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDir
ectives(this)); | 9091 appNode.accept(new RecursiveXmlVisitor_AngularHtmlUnitResolver_visitModelDir
ectives(this)); |
| 8228 } | 9092 } |
| 8229 } | 9093 } |
| 8230 | 9094 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 8248 Object visitXmlTagNode(ht.XmlTagNode node) { | 9112 Object visitXmlTagNode(ht.XmlTagNode node) { |
| 8249 NgModelProcessor directive = NgModelProcessor.INSTANCE; | 9113 NgModelProcessor directive = NgModelProcessor.INSTANCE; |
| 8250 if (directive.canApply(node)) { | 9114 if (directive.canApply(node)) { |
| 8251 directive.applyTopDeclarations(AngularHtmlUnitResolver_this, node); | 9115 directive.applyTopDeclarations(AngularHtmlUnitResolver_this, node); |
| 8252 } | 9116 } |
| 8253 return super.visitXmlTagNode(node); | 9117 return super.visitXmlTagNode(node); |
| 8254 } | 9118 } |
| 8255 } | 9119 } |
| 8256 | 9120 |
| 8257 /** | 9121 /** |
| 9122 * Implementation of [AngularXmlExpression] for an [AngularExpression] enclosed
between |
| 9123 * <code>{{</code> and <code>}}</code>. |
| 9124 */ |
| 9125 class AngularMoustacheXmlExpression extends AngularXmlExpression { |
| 9126 static int OPENING_DELIMITER_CHAR = 0x7B; |
| 9127 |
| 9128 static int CLOSING_DELIMITER_CHAR = 0x7D; |
| 9129 |
| 9130 static String OPENING_DELIMITER = "{{"; |
| 9131 |
| 9132 static String CLOSING_DELIMITER = "}}"; |
| 9133 |
| 9134 static int OPENING_DELIMITER_LENGTH = OPENING_DELIMITER.length; |
| 9135 |
| 9136 static int CLOSING_DELIMITER_LENGTH = CLOSING_DELIMITER.length; |
| 9137 |
| 9138 /** |
| 9139 * The offset of the first character of the opening delimiter. |
| 9140 */ |
| 9141 int _openingOffset = 0; |
| 9142 |
| 9143 /** |
| 9144 * The offset of the first character of the closing delimiter. |
| 9145 */ |
| 9146 int _closingOffset = 0; |
| 9147 |
| 9148 AngularMoustacheXmlExpression(int openingOffset, int closingOffset, AngularExp
ression expression) : super(expression) { |
| 9149 this._openingOffset = openingOffset; |
| 9150 this._closingOffset = closingOffset; |
| 9151 } |
| 9152 |
| 9153 int get end => _closingOffset + CLOSING_DELIMITER_LENGTH; |
| 9154 |
| 9155 int get length => _closingOffset + CLOSING_DELIMITER_LENGTH - _openingOffset; |
| 9156 |
| 9157 int get offset => _openingOffset; |
| 9158 } |
| 9159 |
| 9160 /** |
| 9161 * Implementation of [AngularXmlExpression] for an [AngularExpression] embedded
without |
| 9162 * any wrapping characters. |
| 9163 */ |
| 9164 class AngularRawXmlExpression extends AngularXmlExpression { |
| 9165 AngularRawXmlExpression(AngularExpression expression) : super(expression); |
| 9166 |
| 9167 int get end => expression.end; |
| 9168 |
| 9169 int get length => expression.length; |
| 9170 |
| 9171 int get offset => expression.offset; |
| 9172 } |
| 9173 |
| 9174 /** |
| 9175 * Abstract Angular specific [XmlExpression]. |
| 9176 */ |
| 9177 abstract class AngularXmlExpression extends ht.XmlExpression { |
| 9178 /** |
| 9179 * The expression that is enclosed between the delimiters. |
| 9180 */ |
| 9181 final AngularExpression expression; |
| 9182 |
| 9183 AngularXmlExpression(this.expression); |
| 9184 |
| 9185 ht.XmlExpression_Reference getReference(int offset) { |
| 9186 // main expression |
| 9187 ht.XmlExpression_Reference reference = getReference2(expression.expression,
offset); |
| 9188 if (reference != null) { |
| 9189 return reference; |
| 9190 } |
| 9191 // filters |
| 9192 for (AngularFilterNode filter in expression.filters) { |
| 9193 // filter name |
| 9194 reference = getReference2(filter.name, offset); |
| 9195 if (reference != null) { |
| 9196 return reference; |
| 9197 } |
| 9198 // filter arguments |
| 9199 for (AngularFilterArgument filterArgument in filter.arguments) { |
| 9200 reference = getReference2(filterArgument.expression, offset); |
| 9201 if (reference != null) { |
| 9202 return reference; |
| 9203 } |
| 9204 } |
| 9205 } |
| 9206 return null; |
| 9207 } |
| 9208 |
| 9209 /** |
| 9210 * If the given [ASTNode] has an [Element] at the given offset, then returns |
| 9211 * [Reference] with this [Element]. |
| 9212 */ |
| 9213 ht.XmlExpression_Reference getReference2(ASTNode root, int offset) { |
| 9214 ASTNode node = new NodeLocator.con1(offset).searchWithin(root); |
| 9215 if (node != null) { |
| 9216 Element element = ElementLocator.locate(node); |
| 9217 return new ht.XmlExpression_Reference(element, node.offset, node.length); |
| 9218 } |
| 9219 return null; |
| 9220 } |
| 9221 } |
| 9222 |
| 9223 /** |
| 8258 * Recursively visits [HtmlUnit] and every embedded [Expression]. | 9224 * Recursively visits [HtmlUnit] and every embedded [Expression]. |
| 8259 */ | 9225 */ |
| 8260 abstract class ExpressionVisitor extends ht.RecursiveXmlVisitor<Object> { | 9226 abstract class ExpressionVisitor extends ht.RecursiveXmlVisitor<Object> { |
| 8261 /** | 9227 /** |
| 8262 * Visits the given [Expression]s embedded into tag or attribute. | 9228 * Visits the given [Expression]s embedded into tag or attribute. |
| 8263 * | 9229 * |
| 8264 * @param expression the [Expression] to visit, not `null` | 9230 * @param expression the [Expression] to visit, not `null` |
| 8265 */ | 9231 */ |
| 8266 void visitExpression(Expression expression); | 9232 void visitExpression(Expression expression); |
| 8267 | 9233 |
| 8268 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { | 9234 Object visitXmlAttributeNode(ht.XmlAttributeNode node) { |
| 8269 visitExpressions(node.expressions); | 9235 visitExpressions(node.expressions); |
| 8270 return super.visitXmlAttributeNode(node); | 9236 return super.visitXmlAttributeNode(node); |
| 8271 } | 9237 } |
| 8272 | 9238 |
| 8273 Object visitXmlTagNode(ht.XmlTagNode node) { | 9239 Object visitXmlTagNode(ht.XmlTagNode node) { |
| 8274 visitExpressions(node.expressions); | 9240 visitExpressions(node.expressions); |
| 8275 return super.visitXmlTagNode(node); | 9241 return super.visitXmlTagNode(node); |
| 8276 } | 9242 } |
| 8277 | 9243 |
| 8278 /** | 9244 /** |
| 8279 * Visits [Expression]s of the given [EmbeddedExpression]s. | 9245 * Visits [Expression]s of the given [XmlExpression]s. |
| 8280 */ | 9246 */ |
| 8281 void visitExpressions(List<ht.EmbeddedExpression> expressions) { | 9247 void visitExpressions(List<ht.XmlExpression> expressions) { |
| 8282 for (ht.EmbeddedExpression embeddedExpression in expressions) { | 9248 for (ht.XmlExpression xmlExpression in expressions) { |
| 8283 Expression expression = embeddedExpression.expression; | 9249 if (xmlExpression is AngularXmlExpression) { |
| 8284 visitExpression(expression); | 9250 AngularXmlExpression angularXmlExpression = xmlExpression; |
| 9251 List<Expression> dartExpressions = angularXmlExpression.expression.expre
ssions; |
| 9252 for (Expression dartExpression in dartExpressions) { |
| 9253 visitExpression(dartExpression); |
| 9254 } |
| 9255 } |
| 9256 if (xmlExpression is ht.RawXmlExpression) { |
| 9257 ht.RawXmlExpression rawXmlExpression = xmlExpression; |
| 9258 visitExpression(rawXmlExpression.expression); |
| 9259 } |
| 8285 } | 9260 } |
| 8286 } | 9261 } |
| 8287 } | 9262 } |
| 8288 | 9263 |
| 8289 /** | 9264 /** |
| 8290 * [NgComponentElementProcessor] applies [AngularComponentElement] by parsing ma
pped | 9265 * [NgComponentElementProcessor] applies [AngularComponentElement] by parsing ma
pped |
| 8291 * attributes as expressions. | 9266 * attributes as expressions. |
| 8292 */ | 9267 */ |
| 8293 class NgComponentElementProcessor extends NgDirectiveProcessor { | 9268 class NgComponentElementProcessor extends NgDirectiveProcessor { |
| 8294 AngularComponentElement _element; | 9269 AngularComponentElement _element; |
| 8295 | 9270 |
| 8296 NgComponentElementProcessor(AngularComponentElement element) { | 9271 NgComponentElementProcessor(AngularComponentElement element) { |
| 8297 this._element = element; | 9272 this._element = element; |
| 8298 } | 9273 } |
| 8299 | 9274 |
| 8300 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { | 9275 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { |
| 8301 node.element = _element.selector; | 9276 node.element = _element.selector; |
| 8302 for (AngularPropertyElement property in _element.properties) { | 9277 for (AngularPropertyElement property in _element.properties) { |
| 8303 String name = property.name; | 9278 String name = property.name; |
| 8304 ht.XmlAttributeNode attribute = node.getAttribute(name); | 9279 ht.XmlAttributeNode attribute = node.getAttribute(name); |
| 8305 if (attribute != null) { | 9280 if (attribute != null) { |
| 8306 attribute.element = property; | 9281 attribute.element = property; |
| 8307 // resolve if binding | 9282 // resolve if binding |
| 8308 if (property.propertyKind != AngularPropertyKind.ATTR) { | 9283 if (property.propertyKind != AngularPropertyKind.ATTR) { |
| 8309 Expression expression = parseExpression(resolver, attribute); | 9284 AngularExpression expression = parseAngularExpression(resolver, attrib
ute); |
| 8310 resolver.resolveNode(expression); | 9285 resolver.resolveExpression(expression); |
| 8311 setExpression(attribute, expression); | 9286 setExpression(attribute, expression); |
| 8312 } | 9287 } |
| 8313 } | 9288 } |
| 8314 } | 9289 } |
| 8315 } | 9290 } |
| 8316 | 9291 |
| 8317 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); | 9292 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); |
| 8318 } | 9293 } |
| 8319 | 9294 |
| 8320 /** | 9295 /** |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8361 } | 9336 } |
| 8362 // resolve attribute expression | 9337 // resolve attribute expression |
| 8363 ht.XmlAttributeNode attribute = node.getAttribute(name); | 9338 ht.XmlAttributeNode attribute = node.getAttribute(name); |
| 8364 if (attribute != null) { | 9339 if (attribute != null) { |
| 8365 attribute.element = property; | 9340 attribute.element = property; |
| 8366 // resolve if binding | 9341 // resolve if binding |
| 8367 if (property.propertyKind != AngularPropertyKind.ATTR) { | 9342 if (property.propertyKind != AngularPropertyKind.ATTR) { |
| 8368 resolver.pushNameScope(); | 9343 resolver.pushNameScope(); |
| 8369 try { | 9344 try { |
| 8370 onNgEventDirective(resolver); | 9345 onNgEventDirective(resolver); |
| 8371 Expression expression = parseExpression(resolver, attribute); | 9346 AngularExpression expression = parseAngularExpression(resolver, attr
ibute); |
| 8372 resolver.resolveNode(expression); | 9347 resolver.resolveExpression(expression); |
| 8373 setExpression(attribute, expression); | 9348 setExpression(attribute, expression); |
| 8374 } finally { | 9349 } finally { |
| 8375 resolver.popNameScope(); | 9350 resolver.popNameScope(); |
| 8376 } | 9351 } |
| 8377 } | 9352 } |
| 8378 } | 9353 } |
| 8379 } | 9354 } |
| 8380 } | 9355 } |
| 8381 | 9356 |
| 8382 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); | 9357 bool canApply(ht.XmlTagNode node) => _element.selector.apply(node); |
| 8383 | 9358 |
| 8384 /** | 9359 /** |
| 8385 * Support for <code>$event</code> variable in <code>NgEventDirective</code>. | 9360 * Support for <code>$event</code> variable in <code>NgEventDirective</code>. |
| 8386 */ | 9361 */ |
| 8387 void onNgEventDirective(AngularHtmlUnitResolver resolver) { | 9362 void onNgEventDirective(AngularHtmlUnitResolver resolver) { |
| 8388 if (_element.isClass("NgEventDirective")) { | 9363 if (_element.isClass("NgEventDirective")) { |
| 8389 Type2 dynamicType = resolver.typeProvider.dynamicType; | 9364 Type2 dynamicType = resolver.typeProvider.dynamicType; |
| 8390 resolver.defineVariable(resolver.createLocalVariable2(dynamicType, "\$even
t")); | 9365 resolver.defineVariable(resolver.createLocalVariable2(dynamicType, "\$even
t")); |
| 8391 } | 9366 } |
| 8392 } | 9367 } |
| 8393 } | 9368 } |
| 8394 | 9369 |
| 8395 /** | 9370 /** |
| 8396 * [NgDirectiveProcessor] describes any <code>NgDirective</code> annotation inst
ance. | 9371 * [NgDirectiveProcessor] describes any <code>NgDirective</code> annotation inst
ance. |
| 8397 */ | 9372 */ |
| 8398 abstract class NgDirectiveProcessor extends NgProcessor { | 9373 abstract class NgDirectiveProcessor extends NgProcessor { |
| 8399 static ht.EmbeddedExpression newEmbeddedExpression(Expression e) => new ht.Emb
eddedExpression(e.offset, e, e.end); | 9374 static AngularRawXmlExpression newAngularRawXmlExpression(AngularExpression e)
=> new AngularRawXmlExpression(e); |
| 8400 | 9375 |
| 8401 Expression parseExpression(AngularHtmlUnitResolver resolver, ht.XmlAttributeNo
de attribute) { | 9376 static ht.RawXmlExpression newRawXmlExpression(Expression e) => new ht.RawXmlE
xpression(e); |
| 8402 int offset = attribute.valueToken.offset + 1; | 9377 |
| 8403 String value = attribute.text; | 9378 AngularExpression parseAngularExpression(AngularHtmlUnitResolver resolver, ht.
XmlAttributeNode attribute) { |
| 8404 Token token = resolver.scanDart(value, 0, value.length, offset); | 9379 Token token = scanAttribute(resolver, attribute); |
| 8405 return resolver.parseExpression3(token); | 9380 return resolver.parseAngularExpression3(token); |
| 9381 } |
| 9382 |
| 9383 Expression parseDartExpression(AngularHtmlUnitResolver resolver, ht.XmlAttribu
teNode attribute) { |
| 9384 Token token = scanAttribute(resolver, attribute); |
| 9385 return resolver.parseDartExpression3(token); |
| 9386 } |
| 9387 |
| 9388 /** |
| 9389 * Sets single [AngularExpression] for [XmlAttributeNode]. |
| 9390 */ |
| 9391 void setExpression(ht.XmlAttributeNode attribute, AngularExpression expression
) { |
| 9392 setExpression3(attribute, newAngularRawXmlExpression(expression)); |
| 8406 } | 9393 } |
| 8407 | 9394 |
| 8408 /** | 9395 /** |
| 8409 * Sets single [Expression] for [XmlAttributeNode]. | 9396 * Sets single [Expression] for [XmlAttributeNode]. |
| 8410 */ | 9397 */ |
| 8411 void setExpression(ht.XmlAttributeNode attribute, Expression expression) { | 9398 void setExpression2(ht.XmlAttributeNode attribute, Expression expression) { |
| 8412 attribute.expressions = <ht.EmbeddedExpression> [newEmbeddedExpression(expre
ssion)]; | 9399 setExpression3(attribute, newRawXmlExpression(expression)); |
| 8413 } | 9400 } |
| 8414 | 9401 |
| 8415 /** | 9402 void setExpressions(ht.XmlAttributeNode attribute, List<ht.XmlExpression> xmlE
xpressions) { |
| 8416 * Sets [Expression]s for [XmlAttributeNode]. | 9403 attribute.expressions = new List.from(xmlExpressions); |
| 8417 */ | 9404 } |
| 8418 void setExpressions(ht.XmlAttributeNode attribute, List<Expression> expression
s) { | 9405 |
| 8419 List<ht.EmbeddedExpression> embExpressions = []; | 9406 Token scanAttribute(AngularHtmlUnitResolver resolver, ht.XmlAttributeNode attr
ibute) { |
| 8420 for (Expression expression in expressions) { | 9407 int offset = attribute.valueToken.offset + 1; |
| 8421 embExpressions.add(newEmbeddedExpression(expression)); | 9408 String value = attribute.text; |
| 8422 } | 9409 return resolver.scanDart(value, 0, value.length, offset); |
| 8423 attribute.expressions = new List.from(embExpressions); | 9410 } |
| 9411 |
| 9412 void setExpression3(ht.XmlAttributeNode attribute, ht.XmlExpression xmlExpress
ion) { |
| 9413 attribute.expressions = <ht.XmlExpression> [xmlExpression]; |
| 8424 } | 9414 } |
| 8425 } | 9415 } |
| 8426 | 9416 |
| 8427 /** | 9417 /** |
| 8428 * [NgModelProcessor] describes built-in <code>NgModel</code> directive. | 9418 * [NgModelProcessor] describes built-in <code>NgModel</code> directive. |
| 8429 */ | 9419 */ |
| 8430 class NgModelProcessor extends NgDirectiveProcessor { | 9420 class NgModelProcessor extends NgDirectiveProcessor { |
| 8431 static String _NG_MODEL = "ng-model"; | 9421 static String _NG_MODEL = "ng-model"; |
| 8432 | 9422 |
| 8433 static NgModelProcessor INSTANCE = new NgModelProcessor(); | 9423 static NgModelProcessor INSTANCE = new NgModelProcessor(); |
| 8434 | 9424 |
| 8435 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { | 9425 void apply(AngularHtmlUnitResolver resolver, ht.XmlTagNode node) { |
| 8436 ht.XmlAttributeNode attribute = node.getAttribute(_NG_MODEL); | 9426 ht.XmlAttributeNode attribute = node.getAttribute(_NG_MODEL); |
| 8437 Expression expression = parseExpression(resolver, attribute); | 9427 Expression expression = parseDartExpression(resolver, attribute); |
| 8438 // identifiers have been already handled by "apply top" | 9428 // identifiers have been already handled by "apply top" |
| 8439 if (expression is SimpleIdentifier) { | 9429 if (expression is SimpleIdentifier) { |
| 8440 return; | 9430 return; |
| 8441 } | 9431 } |
| 8442 // resolve | 9432 // resolve |
| 8443 resolver.resolveNode(expression); | 9433 resolver.resolveNode(expression); |
| 8444 // remember expression | 9434 // remember expression |
| 8445 setExpression(attribute, expression); | 9435 setExpression2(attribute, expression); |
| 8446 } | 9436 } |
| 8447 | 9437 |
| 8448 bool canApply(ht.XmlTagNode node) => node.getAttribute(_NG_MODEL) != null; | 9438 bool canApply(ht.XmlTagNode node) => node.getAttribute(_NG_MODEL) != null; |
| 8449 | 9439 |
| 8450 /** | 9440 /** |
| 8451 * This method is used to define top-level [VariableElement]s for each "ng-mod
el" with | 9441 * This method is used to define top-level [VariableElement]s for each "ng-mod
el" with |
| 8452 * simple identifier model. | 9442 * simple identifier model. |
| 8453 */ | 9443 */ |
| 8454 void applyTopDeclarations(AngularHtmlUnitResolver resolver, ht.XmlTagNode node
) { | 9444 void applyTopDeclarations(AngularHtmlUnitResolver resolver, ht.XmlTagNode node
) { |
| 8455 ht.XmlAttributeNode attribute = node.getAttribute(_NG_MODEL); | 9445 ht.XmlAttributeNode attribute = node.getAttribute(_NG_MODEL); |
| 8456 Expression expression = parseExpression(resolver, attribute); | 9446 Expression expression = parseDartExpression(resolver, attribute); |
| 8457 // if not identifier, then not a top-level model, delay until "apply" | 9447 // if not identifier, then not a top-level model, delay until "apply" |
| 8458 if (expression is! SimpleIdentifier) { | 9448 if (expression is! SimpleIdentifier) { |
| 8459 return; | 9449 return; |
| 8460 } | 9450 } |
| 8461 SimpleIdentifier identifier = expression as SimpleIdentifier; | 9451 SimpleIdentifier identifier = expression as SimpleIdentifier; |
| 8462 // define variable Element | 9452 // define variable Element |
| 8463 InterfaceType type = resolver.typeProvider.stringType; | 9453 InterfaceType type = resolver.typeProvider.stringType; |
| 8464 LocalVariableElementImpl element = resolver.createLocalVariable(type, identi
fier); | 9454 LocalVariableElementImpl element = resolver.createLocalVariable(type, identi
fier); |
| 8465 resolver.defineTopVariable(element); | 9455 resolver.defineTopVariable(element); |
| 8466 // remember expression | 9456 // remember expression |
| 8467 identifier.staticElement = element; | 9457 identifier.staticElement = element; |
| 8468 identifier.staticType = type; | 9458 identifier.staticType = type; |
| 8469 setExpression(attribute, identifier); | 9459 setExpression2(attribute, identifier); |
| 8470 } | 9460 } |
| 8471 } | 9461 } |
| 8472 | 9462 |
| 8473 /** | 9463 /** |
| 8474 * [NgProcessor] is used to apply an Angular feature. | 9464 * [NgProcessor] is used to apply an Angular feature. |
| 8475 */ | 9465 */ |
| 8476 abstract class NgProcessor { | 9466 abstract class NgProcessor { |
| 8477 /** | 9467 /** |
| 8478 * Applies this [NgProcessor] to the resolver. | 9468 * Applies this [NgProcessor] to the resolver. |
| 8479 * | 9469 * |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8635 /** | 9625 /** |
| 8636 * Visit a [ResolveAngularComponentTemplateTask]. | 9626 * Visit a [ResolveAngularComponentTemplateTask]. |
| 8637 * | 9627 * |
| 8638 * @param task the task to be visited | 9628 * @param task the task to be visited |
| 8639 * @return the result of visiting the task | 9629 * @return the result of visiting the task |
| 8640 * @throws AnalysisException if the visitor throws an exception for some reaso
n | 9630 * @throws AnalysisException if the visitor throws an exception for some reaso
n |
| 8641 */ | 9631 */ |
| 8642 E visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemplateTask
task); | 9632 E visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemplateTask
task); |
| 8643 | 9633 |
| 8644 /** | 9634 /** |
| 9635 * Visit a [ResolveAngularEntryHtmlTask]. |
| 9636 * |
| 9637 * @param task the task to be visited |
| 9638 * @return the result of visiting the task |
| 9639 * @throws AnalysisException if the visitor throws an exception for some reaso
n |
| 9640 */ |
| 9641 E visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task); |
| 9642 |
| 9643 /** |
| 8645 * Visit a [ResolveDartDependenciesTask]. | 9644 * Visit a [ResolveDartDependenciesTask]. |
| 8646 * | 9645 * |
| 8647 * @param task the task to be visited | 9646 * @param task the task to be visited |
| 8648 * @return the result of visiting the task | 9647 * @return the result of visiting the task |
| 8649 * @throws AnalysisException if the visitor throws an exception for some reaso
n | 9648 * @throws AnalysisException if the visitor throws an exception for some reaso
n |
| 8650 */ | 9649 */ |
| 8651 E visitResolveDartDependenciesTask(ResolveDartDependenciesTask task); | 9650 E visitResolveDartDependenciesTask(ResolveDartDependenciesTask task); |
| 8652 | 9651 |
| 8653 /** | 9652 /** |
| 8654 * Visit a [ResolveDartLibraryTask]. | 9653 * Visit a [ResolveDartLibraryTask]. |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9090 | 10089 |
| 9091 class Source_ContentReceiver_ParseDartTask_internalPerform implements Source_Con
tentReceiver { | 10090 class Source_ContentReceiver_ParseDartTask_internalPerform implements Source_Con
tentReceiver { |
| 9092 final ParseDartTask ParseDartTask_this; | 10091 final ParseDartTask ParseDartTask_this; |
| 9093 | 10092 |
| 9094 RecordingErrorListener errorListener; | 10093 RecordingErrorListener errorListener; |
| 9095 | 10094 |
| 9096 List<Token> token; | 10095 List<Token> token; |
| 9097 | 10096 |
| 9098 Source_ContentReceiver_ParseDartTask_internalPerform(this.ParseDartTask_this,
this.errorListener, this.token); | 10097 Source_ContentReceiver_ParseDartTask_internalPerform(this.ParseDartTask_this,
this.errorListener, this.token); |
| 9099 | 10098 |
| 9100 void accept(CharBuffer contents, int modificationTime) { | 10099 void accept(CharSequence contents, int modificationTime) { |
| 9101 doScan(contents, modificationTime); | |
| 9102 } | |
| 9103 | |
| 9104 void accept2(String contents, int modificationTime) { | |
| 9105 doScan(new CharSequence(contents), modificationTime); | |
| 9106 } | |
| 9107 | |
| 9108 void doScan(CharSequence contents, int modificationTime) { | |
| 9109 ParseDartTask_this._modificationTime = modificationTime; | 10100 ParseDartTask_this._modificationTime = modificationTime; |
| 9110 TimeCounter_TimeCounterHandle timeCounterScan = PerformanceStatistics.scan.s
tart(); | 10101 TimeCounter_TimeCounterHandle timeCounterScan = PerformanceStatistics.scan.s
tart(); |
| 9111 try { | 10102 try { |
| 9112 Scanner scanner = new Scanner(ParseDartTask_this.source, new CharSequenceR
eader(contents), errorListener); | 10103 Scanner scanner = new Scanner(ParseDartTask_this.source, new CharSequenceR
eader(contents), errorListener); |
| 9113 scanner.preserveComments = ParseDartTask_this.context.analysisOptions.pres
erveComments; | 10104 scanner.preserveComments = ParseDartTask_this.context.analysisOptions.pres
erveComments; |
| 9114 token[0] = scanner.tokenize(); | 10105 token[0] = scanner.tokenize(); |
| 9115 ParseDartTask_this._lineInfo = new LineInfo(scanner.lineStarts); | 10106 ParseDartTask_this._lineInfo = new LineInfo(scanner.lineStarts); |
| 9116 } finally { | 10107 } finally { |
| 9117 timeCounterScan.stop(); | 10108 timeCounterScan.stop(); |
| 9118 } | 10109 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9294 * Instances of the class `ResolveAngularComponentTemplateTask` resolve HTML tem
plate | 10285 * Instances of the class `ResolveAngularComponentTemplateTask` resolve HTML tem
plate |
| 9295 * referenced by [AngularComponentElement]. | 10286 * referenced by [AngularComponentElement]. |
| 9296 */ | 10287 */ |
| 9297 class ResolveAngularComponentTemplateTask extends AnalysisTask { | 10288 class ResolveAngularComponentTemplateTask extends AnalysisTask { |
| 9298 /** | 10289 /** |
| 9299 * The [AngularComponentElement] to resolve template for. | 10290 * The [AngularComponentElement] to resolve template for. |
| 9300 */ | 10291 */ |
| 9301 AngularComponentElement _component; | 10292 AngularComponentElement _component; |
| 9302 | 10293 |
| 9303 /** | 10294 /** |
| 9304 * All Angular elements accessible in the component library. | 10295 * The Angular application to resolve in context of. |
| 9305 */ | 10296 */ |
| 9306 List<AngularElement> _angularElements; | 10297 AngularApplicationInfo _application; |
| 9307 | 10298 |
| 9308 /** | 10299 /** |
| 9309 * The source to be resolved. | 10300 * The source to be resolved. |
| 9310 */ | 10301 */ |
| 9311 final Source source; | 10302 final Source source; |
| 9312 | 10303 |
| 9313 /** | 10304 /** |
| 9314 * The time at which the contents of the source were last modified. | 10305 * The time at which the contents of the source were last modified. |
| 9315 */ | 10306 */ |
| 9316 int _modificationTime = -1; | 10307 int _modificationTime = -1; |
| 9317 | 10308 |
| 9318 /** | 10309 /** |
| 9319 * The [HtmlUnit] that was resolved by this task. | 10310 * The [HtmlUnit] that was resolved by this task. |
| 9320 */ | 10311 */ |
| 9321 ht.HtmlUnit _resolvedUnit; | 10312 ht.HtmlUnit _resolvedUnit; |
| 9322 | 10313 |
| 9323 /** | 10314 /** |
| 9324 * The resolution errors that were discovered while resolving the source. | 10315 * The resolution errors that were discovered while resolving the source. |
| 9325 */ | 10316 */ |
| 9326 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 10317 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 9327 | 10318 |
| 9328 /** | 10319 /** |
| 9329 * Initialize a newly created task to perform analysis within the given contex
t. | 10320 * Initialize a newly created task to perform analysis within the given contex
t. |
| 9330 * | 10321 * |
| 9331 * @param context the context in which the task is to be performed | 10322 * @param context the context in which the task is to be performed |
| 9332 * @param source the source to be resolved | 10323 * @param source the source to be resolved |
| 9333 * @param component the component that uses this HTML template, not `null` | 10324 * @param component the component that uses this HTML template, not `null` |
| 9334 * @param angularElements all Angular elements accessible in the component lib
rary | 10325 * @param application the Angular application to resolve in context of |
| 9335 */ | 10326 */ |
| 9336 ResolveAngularComponentTemplateTask(InternalAnalysisContext context, this.sour
ce, AngularComponentElement component, List<AngularElement> angularElements) : s
uper(context) { | 10327 ResolveAngularComponentTemplateTask(InternalAnalysisContext context, this.sour
ce, AngularComponentElement component, AngularApplicationInfo application) : sup
er(context) { |
| 9337 this._component = component; | 10328 this._component = component; |
| 9338 this._angularElements = angularElements; | 10329 this._application = application; |
| 9339 } | 10330 } |
| 9340 | 10331 |
| 9341 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularComponentTem
plateTask(this); | 10332 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularComponentTem
plateTask(this); |
| 9342 | 10333 |
| 9343 /** | 10334 /** |
| 9344 * Return the time at which the contents of the source that was parsed were la
st modified, or a | 10335 * Return the time at which the contents of the source that was parsed were la
st modified, or a |
| 9345 * negative value if the task has not yet been performed or if an exception oc
curred. | 10336 * negative value if the task has not yet been performed or if an exception oc
curred. |
| 9346 * | 10337 * |
| 9347 * @return the time at which the contents of the source that was parsed were l
ast modified | 10338 * @return the time at which the contents of the source that was parsed were l
ast modified |
| 9348 */ | 10339 */ |
| 9349 int get modificationTime => _modificationTime; | 10340 int get modificationTime => _modificationTime; |
| 9350 | 10341 |
| 9351 List<AnalysisError> get resolutionErrors => _resolutionErrors; | 10342 List<AnalysisError> get resolutionErrors => _resolutionErrors; |
| 9352 | 10343 |
| 9353 /** | 10344 /** |
| 9354 * Return the [HtmlUnit] that was resolved by this task. | 10345 * Return the [HtmlUnit] that was resolved by this task. |
| 9355 * | 10346 * |
| 9356 * @return the [HtmlUnit] that was resolved by this task | 10347 * @return the [HtmlUnit] that was resolved by this task |
| 9357 */ | 10348 */ |
| 9358 ht.HtmlUnit get resolvedUnit => _resolvedUnit; | 10349 ht.HtmlUnit get resolvedUnit => _resolvedUnit; |
| 9359 | 10350 |
| 9360 String get taskDescription => "resolving Angular template ${source}"; | 10351 String get taskDescription => "resolving Angular template ${source}"; |
| 9361 | 10352 |
| 9362 void internalPerform() { | 10353 void internalPerform() { |
| 9363 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableHtmlUnit(so
urce); | 10354 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableAngularComp
onentHtmlUnit(source); |
| 9364 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit; | 10355 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit; |
| 9365 if (unit == null) { | 10356 if (unit == null) { |
| 9366 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni
t returned a value without a parsed HTML unit"); | 10357 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni
t returned a value without a parsed HTML unit"); |
| 9367 } | 10358 } |
| 9368 _modificationTime = resolvableHtmlUnit.modificationTime; | 10359 _modificationTime = resolvableHtmlUnit.modificationTime; |
| 9369 // prepare for resolution | 10360 // prepare for resolution |
| 9370 RecordingErrorListener errorListener = new RecordingErrorListener(); | 10361 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 9371 LineInfo lineInfo = context.getLineInfo(source); | 10362 LineInfo lineInfo = context.getLineInfo(source); |
| 9372 // do resolve | 10363 // do resolve |
| 9373 AngularHtmlUnitResolver resolver = new AngularHtmlUnitResolver(context, erro
rListener, source, lineInfo, unit); | 10364 AngularHtmlUnitResolver resolver = new AngularHtmlUnitResolver(context, erro
rListener, source, lineInfo, unit); |
| 9374 resolver.resolveComponentTemplate(_angularElements, _component); | 10365 resolver.resolveComponentTemplate(_application, _component); |
| 9375 // remember errors | 10366 // remember errors |
| 9376 _resolutionErrors = errorListener.getErrors2(source); | 10367 _resolutionErrors = errorListener.getErrors2(source); |
| 9377 // remember resolved unit | 10368 // remember resolved unit |
| 10369 _resolvedUnit = unit; |
| 10370 } |
| 10371 } |
| 10372 |
| 10373 /** |
| 10374 * Instances of the class `ResolveAngularEntryHtmlTask` resolve a specific HTML
file as an |
| 10375 * Angular entry point. |
| 10376 */ |
| 10377 class ResolveAngularEntryHtmlTask extends AnalysisTask { |
| 10378 /** |
| 10379 * The source to be resolved. |
| 10380 */ |
| 10381 final Source source; |
| 10382 |
| 10383 /** |
| 10384 * The Angular application to resolve in context of. |
| 10385 */ |
| 10386 AngularApplicationInfo _application; |
| 10387 |
| 10388 /** |
| 10389 * The time at which the contents of the source were last modified. |
| 10390 */ |
| 10391 int _modificationTime = -1; |
| 10392 |
| 10393 /** |
| 10394 * The [HtmlUnit] that was resolved by this task. |
| 10395 */ |
| 10396 ht.HtmlUnit _resolvedUnit; |
| 10397 |
| 10398 /** |
| 10399 * The element produced by resolving the source. |
| 10400 */ |
| 10401 HtmlElement _element = null; |
| 10402 |
| 10403 /** |
| 10404 * The resolution errors that were discovered while resolving the source. |
| 10405 */ |
| 10406 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 10407 |
| 10408 /** |
| 10409 * Initialize a newly created task to perform analysis within the given contex
t. |
| 10410 * |
| 10411 * @param context the context in which the task is to be performed |
| 10412 * @param source the source to be resolved |
| 10413 * @param application the Angular application to resolve in context of |
| 10414 */ |
| 10415 ResolveAngularEntryHtmlTask(InternalAnalysisContext context, this.source, Angu
larApplicationInfo application) : super(context) { |
| 10416 this._application = application; |
| 10417 } |
| 10418 |
| 10419 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveAngularEntryHtmlTas
k(this); |
| 10420 |
| 10421 HtmlElement get element => _element; |
| 10422 |
| 10423 /** |
| 10424 * Return the time at which the contents of the source that was parsed were la
st modified, or a |
| 10425 * negative value if the task has not yet been performed or if an exception oc
curred. |
| 10426 * |
| 10427 * @return the time at which the contents of the source that was parsed were l
ast modified |
| 10428 */ |
| 10429 int get modificationTime => _modificationTime; |
| 10430 |
| 10431 List<AnalysisError> get resolutionErrors => _resolutionErrors; |
| 10432 |
| 10433 /** |
| 10434 * Return the [HtmlUnit] that was resolved by this task. |
| 10435 * |
| 10436 * @return the [HtmlUnit] that was resolved by this task |
| 10437 */ |
| 10438 ht.HtmlUnit get resolvedUnit => _resolvedUnit; |
| 10439 |
| 10440 String get taskDescription { |
| 10441 if (source == null) { |
| 10442 return "resolve as Angular entry point null source"; |
| 10443 } |
| 10444 return "resolve as Angular entry point ${source.fullName}"; |
| 10445 } |
| 10446 |
| 10447 void internalPerform() { |
| 10448 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableAngularComp
onentHtmlUnit(source); |
| 10449 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit; |
| 10450 if (unit == null) { |
| 10451 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni
t returned a value without a parsed HTML unit"); |
| 10452 } |
| 10453 _modificationTime = resolvableHtmlUnit.modificationTime; |
| 10454 // prepare for resolution |
| 10455 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 10456 LineInfo lineInfo = context.getLineInfo(source); |
| 10457 // do resolve |
| 10458 new AngularHtmlUnitResolver(context, errorListener, source, lineInfo, unit).
resolveEntryPoint(_application); |
| 10459 // remember errors |
| 10460 _resolutionErrors = errorListener.getErrors2(source); |
| 10461 // remember resolved unit |
| 9378 _resolvedUnit = unit; | 10462 _resolvedUnit = unit; |
| 9379 } | 10463 } |
| 9380 } | 10464 } |
| 9381 | 10465 |
| 9382 /** | 10466 /** |
| 9383 * Instances of the class `ResolveDartDependenciesTask` resolve the import, expo
rt, and part | 10467 * Instances of the class `ResolveDartDependenciesTask` resolve the import, expo
rt, and part |
| 9384 * directives in a single source. | 10468 * directives in a single source. |
| 9385 */ | 10469 */ |
| 9386 class ResolveDartDependenciesTask extends AnalysisTask { | 10470 class ResolveDartDependenciesTask extends AnalysisTask { |
| 9387 /** | 10471 /** |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9743 * The element produced by resolving the source. | 10827 * The element produced by resolving the source. |
| 9744 */ | 10828 */ |
| 9745 HtmlElement _element = null; | 10829 HtmlElement _element = null; |
| 9746 | 10830 |
| 9747 /** | 10831 /** |
| 9748 * The resolution errors that were discovered while resolving the source. | 10832 * The resolution errors that were discovered while resolving the source. |
| 9749 */ | 10833 */ |
| 9750 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; | 10834 List<AnalysisError> _resolutionErrors = AnalysisError.NO_ERRORS; |
| 9751 | 10835 |
| 9752 /** | 10836 /** |
| 10837 * The flag that says is this unit is an Angular application. |
| 10838 */ |
| 10839 bool _isAngularApplication2 = false; |
| 10840 |
| 10841 /** |
| 10842 * The Angular application information, maybe `null` |
| 10843 */ |
| 10844 AngularApplicationInfo _angularApplication; |
| 10845 |
| 10846 /** |
| 9753 * Initialize a newly created task to perform analysis within the given contex
t. | 10847 * Initialize a newly created task to perform analysis within the given contex
t. |
| 9754 * | 10848 * |
| 9755 * @param context the context in which the task is to be performed | 10849 * @param context the context in which the task is to be performed |
| 9756 * @param source the source to be resolved | 10850 * @param source the source to be resolved |
| 9757 */ | 10851 */ |
| 9758 ResolveHtmlTask(InternalAnalysisContext context, this.source) : super(context)
; | 10852 ResolveHtmlTask(InternalAnalysisContext context, this.source) : super(context)
; |
| 9759 | 10853 |
| 9760 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this); | 10854 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveHtmlTask(this); |
| 9761 | 10855 |
| 10856 /** |
| 10857 * Returns the [AngularApplicationInfo] for the Web application with this Angu
lar entry |
| 10858 * point, maybe `null` if not an Angular entry point. |
| 10859 */ |
| 10860 AngularApplicationInfo get angularApplication => _angularApplication; |
| 10861 |
| 9762 HtmlElement get element => _element; | 10862 HtmlElement get element => _element; |
| 9763 | 10863 |
| 9764 /** | 10864 /** |
| 9765 * Return the time at which the contents of the source that was parsed were la
st modified, or a | 10865 * Return the time at which the contents of the source that was parsed were la
st modified, or a |
| 9766 * negative value if the task has not yet been performed or if an exception oc
curred. | 10866 * negative value if the task has not yet been performed or if an exception oc
curred. |
| 9767 * | 10867 * |
| 9768 * @return the time at which the contents of the source that was parsed were l
ast modified | 10868 * @return the time at which the contents of the source that was parsed were l
ast modified |
| 9769 */ | 10869 */ |
| 9770 int get modificationTime => _modificationTime; | 10870 int get modificationTime => _modificationTime; |
| 9771 | 10871 |
| 9772 List<AnalysisError> get resolutionErrors => _resolutionErrors; | 10872 List<AnalysisError> get resolutionErrors => _resolutionErrors; |
| 9773 | 10873 |
| 9774 /** | 10874 /** |
| 9775 * Return the [HtmlUnit] that was resolved by this task. | 10875 * Return the [HtmlUnit] that was resolved by this task. |
| 9776 * | 10876 * |
| 9777 * @return the [HtmlUnit] that was resolved by this task | 10877 * @return the [HtmlUnit] that was resolved by this task |
| 9778 */ | 10878 */ |
| 9779 ht.HtmlUnit get resolvedUnit => _resolvedUnit; | 10879 ht.HtmlUnit get resolvedUnit => _resolvedUnit; |
| 9780 | 10880 |
| 10881 /** |
| 10882 * Returns `true` if analyzed unit is an Angular application. |
| 10883 */ |
| 10884 bool get isAngularApplication => _isAngularApplication2; |
| 10885 |
| 9781 String get taskDescription { | 10886 String get taskDescription { |
| 9782 if (source == null) { | 10887 if (source == null) { |
| 9783 return "resolve as html null source"; | 10888 return "resolve as html null source"; |
| 9784 } | 10889 } |
| 9785 return "resolve as html ${source.fullName}"; | 10890 return "resolve as html ${source.fullName}"; |
| 9786 } | 10891 } |
| 9787 | 10892 |
| 9788 void internalPerform() { | 10893 void internalPerform() { |
| 9789 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableHtmlUnit(so
urce); | 10894 ResolvableHtmlUnit resolvableHtmlUnit = context.computeResolvableHtmlUnit(so
urce); |
| 9790 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit; | 10895 ht.HtmlUnit unit = resolvableHtmlUnit.compilationUnit; |
| 9791 if (unit == null) { | 10896 if (unit == null) { |
| 9792 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni
t returned a value without a parsed HTML unit"); | 10897 throw new AnalysisException.con1("Internal error: computeResolvableHtmlUni
t returned a value without a parsed HTML unit"); |
| 9793 } | 10898 } |
| 9794 _modificationTime = resolvableHtmlUnit.modificationTime; | 10899 _modificationTime = resolvableHtmlUnit.modificationTime; |
| 9795 // build standard HTML element | 10900 // build standard HTML element |
| 9796 HtmlUnitBuilder builder = new HtmlUnitBuilder(context); | 10901 HtmlUnitBuilder builder = new HtmlUnitBuilder(context); |
| 9797 _element = builder.buildHtmlElement2(source, _modificationTime, unit); | 10902 _element = builder.buildHtmlElement2(source, _modificationTime, unit); |
| 9798 // resolve toolkit-specific features | 10903 RecordingErrorListener errorListener = builder.errorListener; |
| 9799 LineInfo lineInfo = context.getLineInfo(source); | 10904 LineInfo lineInfo = context.getLineInfo(source); |
| 9800 new AngularHtmlUnitResolver(context, builder.errorListener, source, lineInfo
, unit).resolveEntryPoint(); | 10905 // try to resolve as an Angular entry point |
| 10906 _isAngularApplication2 = AngularHtmlUnitResolver.hasAngularAnnotation(unit); |
| 10907 _angularApplication = new AngularHtmlUnitResolver(context, errorListener, so
urce, lineInfo, unit).calculateAngularApplication(); |
| 9801 // record all resolution errors | 10908 // record all resolution errors |
| 9802 _resolutionErrors = builder.errorListener.getErrors2(source); | 10909 _resolutionErrors = errorListener.getErrors2(source); |
| 9803 // remember resolved unit | 10910 // remember resolved unit |
| 9804 _resolvedUnit = unit; | 10911 _resolvedUnit = unit; |
| 9805 } | 10912 } |
| 9806 } | 10913 } |
| 9807 | 10914 |
| 9808 /** | 10915 /** |
| 9809 * The interface `Logger` defines the behavior of objects that can be used to re
ceive | 10916 * The interface `Logger` defines the behavior of objects that can be used to re
ceive |
| 9810 * information about errors within the analysis engine. Implementations usually
write this | 10917 * information about errors within the analysis engine. Implementations usually
write this |
| 9811 * information to a file, but can also record the information for later use (suc
h as during testing) | 10918 * information to a file, but can also record the information for later use (suc
h as during testing) |
| 9812 * or even ignore the information. | 10919 * or even ignore the information. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 9825 | 10932 |
| 9826 /** | 10933 /** |
| 9827 * Log the given exception as one representing an error. | 10934 * Log the given exception as one representing an error. |
| 9828 * | 10935 * |
| 9829 * @param message an explanation of why the error occurred or what it means | 10936 * @param message an explanation of why the error occurred or what it means |
| 9830 * @param exception the exception being logged | 10937 * @param exception the exception being logged |
| 9831 */ | 10938 */ |
| 9832 void logError2(String message, Exception exception); | 10939 void logError2(String message, Exception exception); |
| 9833 | 10940 |
| 9834 /** | 10941 /** |
| 9835 * Log the given exception as one representing an error. | |
| 9836 * | |
| 9837 * @param exception the exception being logged | |
| 9838 */ | |
| 9839 void logError3(Exception exception); | |
| 9840 | |
| 9841 /** | |
| 9842 * Log the given informational message. | 10942 * Log the given informational message. |
| 9843 * | 10943 * |
| 9844 * @param message an explanation of why the error occurred or what it means | 10944 * @param message an explanation of why the error occurred or what it means |
| 9845 * @param exception the exception being logged | 10945 * @param exception the exception being logged |
| 9846 */ | 10946 */ |
| 9847 void logInformation(String message); | 10947 void logInformation(String message); |
| 9848 | 10948 |
| 9849 /** | 10949 /** |
| 9850 * Log the given exception as one representing an informational message. | 10950 * Log the given exception as one representing an informational message. |
| 9851 * | 10951 * |
| 9852 * @param message an explanation of why the error occurred or what it means | 10952 * @param message an explanation of why the error occurred or what it means |
| 9853 * @param exception the exception being logged | 10953 * @param exception the exception being logged |
| 9854 */ | 10954 */ |
| 9855 void logInformation3(String message, Exception exception); | 10955 void logInformation3(String message, Exception exception); |
| 9856 } | 10956 } |
| 9857 | 10957 |
| 9858 /** | 10958 /** |
| 9859 * Implementation of [Logger] that does nothing. | 10959 * Implementation of [Logger] that does nothing. |
| 9860 */ | 10960 */ |
| 9861 class Logger_NullLogger implements Logger { | 10961 class Logger_NullLogger implements Logger { |
| 9862 void logError(String message) { | 10962 void logError(String message) { |
| 9863 } | 10963 } |
| 9864 | 10964 |
| 9865 void logError2(String message, Exception exception) { | 10965 void logError2(String message, Exception exception) { |
| 9866 } | 10966 } |
| 9867 | 10967 |
| 9868 void logError3(Exception exception) { | |
| 9869 } | |
| 9870 | |
| 9871 void logInformation(String message) { | 10968 void logInformation(String message) { |
| 9872 } | 10969 } |
| 9873 | 10970 |
| 9874 void logInformation3(String message, Exception exception) { | 10971 void logInformation3(String message, Exception exception) { |
| 9875 } | 10972 } |
| 9876 } | 10973 } |
| OLD | NEW |