| 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 library analyzer.src.dart.element.element; | 5 library analyzer.src.dart.element.element; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 * A table mapping the offset of a directive to the annotations associated | 1078 * A table mapping the offset of a directive to the annotations associated |
| 1079 * with that directive, or `null` if none of the annotations in the | 1079 * with that directive, or `null` if none of the annotations in the |
| 1080 * compilation unit have annotations. | 1080 * compilation unit have annotations. |
| 1081 */ | 1081 */ |
| 1082 Map<int, List<ElementAnnotation>> annotationMap = null; | 1082 Map<int, List<ElementAnnotation>> annotationMap = null; |
| 1083 | 1083 |
| 1084 /** | 1084 /** |
| 1085 * A list containing all of the top-level accessors (getters and setters) | 1085 * A list containing all of the top-level accessors (getters and setters) |
| 1086 * contained in this compilation unit. | 1086 * contained in this compilation unit. |
| 1087 */ | 1087 */ |
| 1088 List<PropertyAccessorElement> _accessors = PropertyAccessorElement.EMPTY_LIST; | 1088 List<PropertyAccessorElement> _accessors; |
| 1089 | 1089 |
| 1090 /** | 1090 /** |
| 1091 * A list containing all of the enums contained in this compilation unit. | 1091 * A list containing all of the enums contained in this compilation unit. |
| 1092 */ | 1092 */ |
| 1093 List<ClassElement> _enums = ClassElement.EMPTY_LIST; | 1093 List<ClassElement> _enums = ClassElement.EMPTY_LIST; |
| 1094 | 1094 |
| 1095 /** | 1095 /** |
| 1096 * A list containing all of the top-level functions contained in this | 1096 * A list containing all of the top-level functions contained in this |
| 1097 * compilation unit. | 1097 * compilation unit. |
| 1098 */ | 1098 */ |
| 1099 List<FunctionElement> _functions = FunctionElement.EMPTY_LIST; | 1099 List<FunctionElement> _functions = FunctionElement.EMPTY_LIST; |
| 1100 | 1100 |
| 1101 /** | 1101 /** |
| 1102 * A list containing all of the function type aliases contained in this | 1102 * A list containing all of the function type aliases contained in this |
| 1103 * compilation unit. | 1103 * compilation unit. |
| 1104 */ | 1104 */ |
| 1105 List<FunctionTypeAliasElement> _typeAliases = | 1105 List<FunctionTypeAliasElement> _typeAliases = |
| 1106 FunctionTypeAliasElement.EMPTY_LIST; | 1106 FunctionTypeAliasElement.EMPTY_LIST; |
| 1107 | 1107 |
| 1108 /** | 1108 /** |
| 1109 * A list containing all of the types contained in this compilation unit. | 1109 * A list containing all of the types contained in this compilation unit. |
| 1110 */ | 1110 */ |
| 1111 List<ClassElement> _types = ClassElement.EMPTY_LIST; | 1111 List<ClassElement> _types = ClassElement.EMPTY_LIST; |
| 1112 | 1112 |
| 1113 /** | 1113 /** |
| 1114 * A list containing all of the variables contained in this compilation unit. | 1114 * A list containing all of the variables contained in this compilation unit. |
| 1115 */ | 1115 */ |
| 1116 List<TopLevelVariableElement> _variables = TopLevelVariableElement.EMPTY_LIST; | 1116 List<TopLevelVariableElement> _variables; |
| 1117 | 1117 |
| 1118 /** | 1118 /** |
| 1119 * A map from offsets to elements of this unit at these offsets. | 1119 * A map from offsets to elements of this unit at these offsets. |
| 1120 */ | 1120 */ |
| 1121 final Map<int, Element> _offsetToElementMap = new HashMap<int, Element>(); | 1121 final Map<int, Element> _offsetToElementMap = new HashMap<int, Element>(); |
| 1122 | 1122 |
| 1123 /** | 1123 /** |
| 1124 * Resynthesized explicit top-level property accessors. |
| 1125 */ |
| 1126 UnitExplicitTopLevelAccessors _explicitTopLevelAccessors; |
| 1127 |
| 1128 /** |
| 1129 * Resynthesized explicit top-level variables. |
| 1130 */ |
| 1131 UnitExplicitTopLevelVariables _explicitTopLevelVariables; |
| 1132 |
| 1133 /** |
| 1134 * Description of top-level variable replacements that should be applied |
| 1135 * to implicit top-level variables because of re-linking top-level property |
| 1136 * accessors between different unit of the same library. |
| 1137 */ |
| 1138 Map<TopLevelVariableElement, TopLevelVariableElement> |
| 1139 _topLevelVariableReplaceMap; |
| 1140 |
| 1141 /** |
| 1124 * Initialize a newly created compilation unit element to have the given | 1142 * Initialize a newly created compilation unit element to have the given |
| 1125 * [name]. | 1143 * [name]. |
| 1126 */ | 1144 */ |
| 1127 CompilationUnitElementImpl(String name) | 1145 CompilationUnitElementImpl(String name) |
| 1128 : resynthesizerContext = null, | 1146 : resynthesizerContext = null, |
| 1129 _unlinkedUnit = null, | 1147 _unlinkedUnit = null, |
| 1130 _unlinkedPart = null, | 1148 _unlinkedPart = null, |
| 1131 super(name, -1); | 1149 super(name, -1); |
| 1132 | 1150 |
| 1133 /** | 1151 /** |
| 1134 * Initialize using the given serialized information. | 1152 * Initialize using the given serialized information. |
| 1135 */ | 1153 */ |
| 1136 CompilationUnitElementImpl.forSerialized( | 1154 CompilationUnitElementImpl.forSerialized( |
| 1137 LibraryElementImpl enclosingLibrary, | 1155 LibraryElementImpl enclosingLibrary, |
| 1138 this.resynthesizerContext, | 1156 this.resynthesizerContext, |
| 1139 this._unlinkedUnit, | 1157 this._unlinkedUnit, |
| 1140 this._unlinkedPart, | 1158 this._unlinkedPart, |
| 1141 String name) | 1159 String name) |
| 1142 : super.forSerialized(null) { | 1160 : super.forSerialized(null) { |
| 1143 _enclosingElement = enclosingLibrary; | 1161 _enclosingElement = enclosingLibrary; |
| 1144 _name = name; | 1162 _name = name; |
| 1145 _nameOffset = -1; | 1163 _nameOffset = -1; |
| 1146 } | 1164 } |
| 1147 | 1165 |
| 1148 @override | 1166 @override |
| 1149 List<PropertyAccessorElement> get accessors => _accessors; | 1167 List<PropertyAccessorElement> get accessors { |
| 1168 if (_unlinkedUnit != null) { |
| 1169 if (_accessors == null) { |
| 1170 _explicitTopLevelAccessors ??= |
| 1171 resynthesizerContext.buildTopLevelAccessors(); |
| 1172 _explicitTopLevelVariables ??= |
| 1173 resynthesizerContext.buildTopLevelVariables(); |
| 1174 List<PropertyAccessorElementImpl> accessors = |
| 1175 <PropertyAccessorElementImpl>[]; |
| 1176 accessors.addAll(_explicitTopLevelAccessors.accessors); |
| 1177 accessors.addAll(_explicitTopLevelVariables.implicitAccessors); |
| 1178 _accessors = accessors; |
| 1179 } |
| 1180 } |
| 1181 return _accessors ?? PropertyAccessorElement.EMPTY_LIST; |
| 1182 } |
| 1150 | 1183 |
| 1151 /** | 1184 /** |
| 1152 * Set the top-level accessors (getters and setters) contained in this | 1185 * Set the top-level accessors (getters and setters) contained in this |
| 1153 * compilation unit to the given [accessors]. | 1186 * compilation unit to the given [accessors]. |
| 1154 */ | 1187 */ |
| 1155 void set accessors(List<PropertyAccessorElement> accessors) { | 1188 void set accessors(List<PropertyAccessorElement> accessors) { |
| 1156 for (PropertyAccessorElement accessor in accessors) { | 1189 for (PropertyAccessorElement accessor in accessors) { |
| 1157 (accessor as PropertyAccessorElementImpl).enclosingElement = this; | 1190 (accessor as PropertyAccessorElementImpl).enclosingElement = this; |
| 1158 } | 1191 } |
| 1159 this._accessors = accessors; | 1192 this._accessors = accessors; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 for (int i = 0; i < _functions.length; i++) { | 1255 for (int i = 0; i < _functions.length; i++) { |
| 1223 if (_functions[i].name == FunctionElement.LOAD_LIBRARY_NAME) { | 1256 if (_functions[i].name == FunctionElement.LOAD_LIBRARY_NAME) { |
| 1224 return true; | 1257 return true; |
| 1225 } | 1258 } |
| 1226 } | 1259 } |
| 1227 return false; | 1260 return false; |
| 1228 } | 1261 } |
| 1229 | 1262 |
| 1230 @override | 1263 @override |
| 1231 String get identifier => source.encoding; | 1264 String get identifier => source.encoding; |
| 1232 | |
| 1233 @override | 1265 @override |
| 1234 ElementKind get kind => ElementKind.COMPILATION_UNIT; | 1266 ElementKind get kind => ElementKind.COMPILATION_UNIT; |
| 1235 | 1267 |
| 1236 @override | 1268 @override |
| 1237 List<ElementAnnotation> get metadata { | 1269 List<ElementAnnotation> get metadata { |
| 1238 if (_unlinkedPart != null) { | 1270 if (_unlinkedPart != null) { |
| 1239 CompilationUnitElementImpl definingUnit = | 1271 CompilationUnitElementImpl definingUnit = |
| 1240 library.definingCompilationUnit as CompilationUnitElementImpl; | 1272 library.definingCompilationUnit as CompilationUnitElementImpl; |
| 1241 return _metadata ??= _unlinkedPart.annotations | 1273 return _metadata ??= _unlinkedPart.annotations |
| 1242 .map(definingUnit.resynthesizerContext.buildAnnotation) | 1274 .map(definingUnit.resynthesizerContext.buildAnnotation) |
| 1243 .toList(); | 1275 .toList(); |
| 1244 } | 1276 } |
| 1245 return super.metadata; | 1277 return super.metadata; |
| 1246 } | 1278 } |
| 1247 | 1279 |
| 1248 @override | 1280 @override |
| 1249 List<TopLevelVariableElement> get topLevelVariables => _variables; | 1281 List<TopLevelVariableElement> get topLevelVariables { |
| 1282 if (_unlinkedUnit != null) { |
| 1283 if (_variables == null) { |
| 1284 _explicitTopLevelAccessors ??= |
| 1285 resynthesizerContext.buildTopLevelAccessors(); |
| 1286 _explicitTopLevelVariables ??= |
| 1287 resynthesizerContext.buildTopLevelVariables(); |
| 1288 List<TopLevelVariableElementImpl> variables = |
| 1289 <TopLevelVariableElementImpl>[]; |
| 1290 variables.addAll(_explicitTopLevelVariables.variables); |
| 1291 variables.addAll(_explicitTopLevelAccessors.implicitVariables); |
| 1292 // Ensure that getters and setters in different units use |
| 1293 // the same top-level variables. |
| 1294 (enclosingElement as LibraryElementImpl) |
| 1295 .resynthesizerContext |
| 1296 .patchTopLevelAccessors(); |
| 1297 _variables = variables; |
| 1298 _topLevelVariableReplaceMap?.forEach((from, to) { |
| 1299 int index = _variables.indexOf(from); |
| 1300 _variables[index] = to; |
| 1301 }); |
| 1302 _topLevelVariableReplaceMap = null; |
| 1303 } |
| 1304 } |
| 1305 return _variables ?? TopLevelVariableElement.EMPTY_LIST; |
| 1306 } |
| 1250 | 1307 |
| 1251 /** | 1308 /** |
| 1252 * Set the top-level variables contained in this compilation unit to the given | 1309 * Set the top-level variables contained in this compilation unit to the given |
| 1253 * [variables]. | 1310 * [variables]. |
| 1254 */ | 1311 */ |
| 1255 void set topLevelVariables(List<TopLevelVariableElement> variables) { | 1312 void set topLevelVariables(List<TopLevelVariableElement> variables) { |
| 1313 assert(!isResynthesized); |
| 1256 for (TopLevelVariableElement field in variables) { | 1314 for (TopLevelVariableElement field in variables) { |
| 1257 (field as TopLevelVariableElementImpl).enclosingElement = this; | 1315 (field as TopLevelVariableElementImpl).enclosingElement = this; |
| 1258 } | 1316 } |
| 1259 this._variables = variables; | 1317 this._variables = variables; |
| 1260 } | 1318 } |
| 1261 | 1319 |
| 1262 /** | 1320 /** |
| 1263 * Set the function type aliases contained in this compilation unit to the | 1321 * Set the function type aliases contained in this compilation unit to the |
| 1264 * given [typeAliases]. | 1322 * given [typeAliases]. |
| 1265 */ | 1323 */ |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1327 return annotationMap[offset] ?? const <ElementAnnotation>[]; | 1385 return annotationMap[offset] ?? const <ElementAnnotation>[]; |
| 1328 } | 1386 } |
| 1329 | 1387 |
| 1330 @override | 1388 @override |
| 1331 ElementImpl getChild(String identifier) { | 1389 ElementImpl getChild(String identifier) { |
| 1332 // | 1390 // |
| 1333 // The casts in this method are safe because the set methods would have | 1391 // The casts in this method are safe because the set methods would have |
| 1334 // thrown a CCE if any of the elements in the arrays were not of the | 1392 // thrown a CCE if any of the elements in the arrays were not of the |
| 1335 // expected types. | 1393 // expected types. |
| 1336 // | 1394 // |
| 1337 for (PropertyAccessorElement accessor in _accessors) { | 1395 for (PropertyAccessorElement accessor in accessors) { |
| 1338 PropertyAccessorElementImpl accessorImpl = accessor; | 1396 PropertyAccessorElementImpl accessorImpl = accessor; |
| 1339 if (accessorImpl.identifier == identifier) { | 1397 if (accessorImpl.identifier == identifier) { |
| 1340 return accessorImpl; | 1398 return accessorImpl; |
| 1341 } | 1399 } |
| 1342 } | 1400 } |
| 1343 for (TopLevelVariableElement variable in _variables) { | 1401 for (TopLevelVariableElement variable in topLevelVariables) { |
| 1344 TopLevelVariableElementImpl variableImpl = variable; | 1402 TopLevelVariableElementImpl variableImpl = variable; |
| 1345 if (variableImpl.identifier == identifier) { | 1403 if (variableImpl.identifier == identifier) { |
| 1346 return variableImpl; | 1404 return variableImpl; |
| 1347 } | 1405 } |
| 1348 } | 1406 } |
| 1349 for (FunctionElement function in _functions) { | 1407 for (FunctionElement function in _functions) { |
| 1350 FunctionElementImpl functionImpl = function; | 1408 FunctionElementImpl functionImpl = function; |
| 1351 if (functionImpl.identifier == identifier) { | 1409 if (functionImpl.identifier == identifier) { |
| 1352 return functionImpl; | 1410 return functionImpl; |
| 1353 } | 1411 } |
| 1354 } | 1412 } |
| 1355 for (FunctionTypeAliasElement typeAlias in _typeAliases) { | 1413 for (FunctionTypeAliasElement typeAlias in _typeAliases) { |
| 1356 FunctionTypeAliasElementImpl typeAliasImpl = typeAlias; | 1414 FunctionTypeAliasElementImpl typeAliasImpl = typeAlias; |
| 1357 if (typeAliasImpl.identifier == identifier) { | 1415 if (typeAliasImpl.identifier == identifier) { |
| 1358 return typeAliasImpl; | 1416 return typeAliasImpl; |
| 1359 } | 1417 } |
| 1360 } | 1418 } |
| 1361 for (ClassElement type in _types) { | 1419 for (ClassElement type in _types) { |
| 1362 ClassElementImpl typeImpl = type; | 1420 ClassElementImpl typeImpl = type; |
| 1363 if (typeImpl.identifier == identifier) { | 1421 if (typeImpl.name == identifier) { |
| 1364 return typeImpl; | 1422 return typeImpl; |
| 1365 } | 1423 } |
| 1366 } | 1424 } |
| 1367 for (ClassElement type in _enums) { | 1425 for (ClassElement type in _enums) { |
| 1368 ClassElementImpl typeImpl = type; | 1426 ClassElementImpl typeImpl = type; |
| 1369 if (typeImpl.identifier == identifier) { | 1427 if (typeImpl.identifier == identifier) { |
| 1370 return typeImpl; | 1428 return typeImpl; |
| 1371 } | 1429 } |
| 1372 } | 1430 } |
| 1373 return null; | 1431 return null; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1399 } | 1457 } |
| 1400 } | 1458 } |
| 1401 return null; | 1459 return null; |
| 1402 } | 1460 } |
| 1403 | 1461 |
| 1404 /** | 1462 /** |
| 1405 * Replace the given [from] top-level variable with [to] in this compilation u
nit. | 1463 * Replace the given [from] top-level variable with [to] in this compilation u
nit. |
| 1406 */ | 1464 */ |
| 1407 void replaceTopLevelVariable( | 1465 void replaceTopLevelVariable( |
| 1408 TopLevelVariableElement from, TopLevelVariableElement to) { | 1466 TopLevelVariableElement from, TopLevelVariableElement to) { |
| 1409 int index = _variables.indexOf(from); | 1467 if (_unlinkedUnit != null) { |
| 1410 _variables[index] = to; | 1468 // Getters and setter in different units should be patched to use the |
| 1469 // same variables before these variables were asked and returned. |
| 1470 assert(_variables == null); |
| 1471 _topLevelVariableReplaceMap ??= |
| 1472 <TopLevelVariableElement, TopLevelVariableElement>{}; |
| 1473 _topLevelVariableReplaceMap[from] = to; |
| 1474 } else { |
| 1475 int index = _variables.indexOf(from); |
| 1476 _variables[index] = to; |
| 1477 } |
| 1411 } | 1478 } |
| 1412 | 1479 |
| 1413 /** | 1480 /** |
| 1414 * Set the annotations associated with the directive at the given [offset] to | 1481 * Set the annotations associated with the directive at the given [offset] to |
| 1415 * the given list of [annotations]. | 1482 * the given list of [annotations]. |
| 1416 */ | 1483 */ |
| 1417 void setAnnotations(int offset, List<ElementAnnotation> annotations) { | 1484 void setAnnotations(int offset, List<ElementAnnotation> annotations) { |
| 1418 annotationMap ??= new HashMap<int, List<ElementAnnotation>>(); | 1485 annotationMap ??= new HashMap<int, List<ElementAnnotation>>(); |
| 1419 annotationMap[offset] = annotations; | 1486 annotationMap[offset] = annotations; |
| 1420 } | 1487 } |
| 1421 | 1488 |
| 1422 @override | 1489 @override |
| 1423 void visitChildren(ElementVisitor visitor) { | 1490 void visitChildren(ElementVisitor visitor) { |
| 1424 super.visitChildren(visitor); | 1491 super.visitChildren(visitor); |
| 1425 safelyVisitChildren(_accessors, visitor); | 1492 safelyVisitChildren(accessors, visitor); |
| 1426 safelyVisitChildren(_enums, visitor); | 1493 safelyVisitChildren(_enums, visitor); |
| 1427 safelyVisitChildren(_functions, visitor); | 1494 safelyVisitChildren(_functions, visitor); |
| 1428 safelyVisitChildren(_typeAliases, visitor); | 1495 safelyVisitChildren(_typeAliases, visitor); |
| 1429 safelyVisitChildren(_types, visitor); | 1496 safelyVisitChildren(_types, visitor); |
| 1430 safelyVisitChildren(_variables, visitor); | 1497 safelyVisitChildren(topLevelVariables, visitor); |
| 1431 } | 1498 } |
| 1432 } | 1499 } |
| 1433 | 1500 |
| 1434 /** | 1501 /** |
| 1435 * A [FieldElement] for a 'const' or 'final' field that has an initializer. | 1502 * A [FieldElement] for a 'const' or 'final' field that has an initializer. |
| 1436 * | 1503 * |
| 1437 * TODO(paulberry): we should rename this class to reflect the fact that it's | 1504 * TODO(paulberry): we should rename this class to reflect the fact that it's |
| 1438 * used for both const and final fields. However, we shouldn't do so until | 1505 * used for both const and final fields. However, we shouldn't do so until |
| 1439 * we've created an API for reading the values of constants; until that API is | 1506 * we've created an API for reading the values of constants; until that API is |
| 1440 * available, clients are likely to read constant values by casting to | 1507 * available, clients are likely to read constant values by casting to |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 */ | 1699 */ |
| 1633 ConstTopLevelVariableElementImpl(String name, int offset) | 1700 ConstTopLevelVariableElementImpl(String name, int offset) |
| 1634 : super(name, offset); | 1701 : super(name, offset); |
| 1635 | 1702 |
| 1636 /** | 1703 /** |
| 1637 * Initialize a newly created top-level variable element to have the given | 1704 * Initialize a newly created top-level variable element to have the given |
| 1638 * [name]. | 1705 * [name]. |
| 1639 */ | 1706 */ |
| 1640 ConstTopLevelVariableElementImpl.forNode(Identifier name) | 1707 ConstTopLevelVariableElementImpl.forNode(Identifier name) |
| 1641 : super.forNode(name); | 1708 : super.forNode(name); |
| 1709 |
| 1710 /** |
| 1711 * Initialize using the given serialized information. |
| 1712 */ |
| 1713 ConstTopLevelVariableElementImpl.forSerialized( |
| 1714 UnlinkedVariable unlinkedVariable, ElementImpl enclosingElement) |
| 1715 : super.forSerialized(unlinkedVariable, enclosingElement); |
| 1642 } | 1716 } |
| 1643 | 1717 |
| 1644 /** | 1718 /** |
| 1645 * Mixin used by elements that represent constant variables and have | 1719 * Mixin used by elements that represent constant variables and have |
| 1646 * initializers. | 1720 * initializers. |
| 1647 * | 1721 * |
| 1648 * Note that in correct Dart code, all constant variables must have | 1722 * Note that in correct Dart code, all constant variables must have |
| 1649 * initializers. However, analyzer also needs to handle incorrect Dart code, | 1723 * initializers. However, analyzer also needs to handle incorrect Dart code, |
| 1650 * in which case there might be some constant variables that lack initializers. | 1724 * in which case there might be some constant variables that lack initializers. |
| 1651 * This interface is only used for constant variables that have initializers. | 1725 * This interface is only used for constant variables that have initializers. |
| (...skipping 1985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3637 | 3711 |
| 3638 /** | 3712 /** |
| 3639 * A concrete implementation of a [LibraryElement]. | 3713 * A concrete implementation of a [LibraryElement]. |
| 3640 */ | 3714 */ |
| 3641 class LibraryElementImpl extends ElementImpl implements LibraryElement { | 3715 class LibraryElementImpl extends ElementImpl implements LibraryElement { |
| 3642 /** | 3716 /** |
| 3643 * The analysis context in which this library is defined. | 3717 * The analysis context in which this library is defined. |
| 3644 */ | 3718 */ |
| 3645 final AnalysisContext context; | 3719 final AnalysisContext context; |
| 3646 | 3720 |
| 3721 final LibraryResynthesizerContext resynthesizerContext; |
| 3722 |
| 3723 final UnlinkedUnit _unlinkedDefiningUnit; |
| 3724 |
| 3647 /** | 3725 /** |
| 3648 * The compilation unit that defines this library. | 3726 * The compilation unit that defines this library. |
| 3649 */ | 3727 */ |
| 3650 CompilationUnitElement _definingCompilationUnit; | 3728 CompilationUnitElement _definingCompilationUnit; |
| 3651 | 3729 |
| 3652 /** | 3730 /** |
| 3653 * The entry point for this library, or `null` if this library does not have | 3731 * The entry point for this library, or `null` if this library does not have |
| 3654 * an entry point. | 3732 * an entry point. |
| 3655 */ | 3733 */ |
| 3656 FunctionElement entryPoint; | 3734 FunctionElement _entryPoint; |
| 3657 | 3735 |
| 3658 /** | 3736 /** |
| 3659 * A list containing specifications of all of the imports defined in this | 3737 * A list containing specifications of all of the imports defined in this |
| 3660 * library. | 3738 * library. |
| 3661 */ | 3739 */ |
| 3662 List<ImportElement> _imports = ImportElement.EMPTY_LIST; | 3740 List<ImportElement> _imports = ImportElement.EMPTY_LIST; |
| 3663 | 3741 |
| 3664 /** | 3742 /** |
| 3665 * A list containing specifications of all of the exports defined in this | 3743 * A list containing specifications of all of the exports defined in this |
| 3666 * library. | 3744 * library. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3688 */ | 3766 */ |
| 3689 FunctionElement _loadLibraryFunction; | 3767 FunctionElement _loadLibraryFunction; |
| 3690 | 3768 |
| 3691 @override | 3769 @override |
| 3692 final int nameLength; | 3770 final int nameLength; |
| 3693 | 3771 |
| 3694 /** | 3772 /** |
| 3695 * The export [Namespace] of this library, `null` if it has not been | 3773 * The export [Namespace] of this library, `null` if it has not been |
| 3696 * computed yet. | 3774 * computed yet. |
| 3697 */ | 3775 */ |
| 3698 @override | 3776 Namespace _exportNamespace; |
| 3699 Namespace exportNamespace; | |
| 3700 | 3777 |
| 3701 /** | 3778 /** |
| 3702 * The public [Namespace] of this library, `null` if it has not been | 3779 * The public [Namespace] of this library, `null` if it has not been |
| 3703 * computed yet. | 3780 * computed yet. |
| 3704 */ | 3781 */ |
| 3705 @override | 3782 Namespace _publicNamespace; |
| 3706 Namespace publicNamespace; | |
| 3707 | 3783 |
| 3708 /** | 3784 /** |
| 3709 * Initialize a newly created library element in the given [context] to have | 3785 * Initialize a newly created library element in the given [context] to have |
| 3710 * the given [name] and [offset]. | 3786 * the given [name] and [offset]. |
| 3711 */ | 3787 */ |
| 3712 LibraryElementImpl(this.context, String name, int offset, this.nameLength) | 3788 LibraryElementImpl(this.context, String name, int offset, this.nameLength) |
| 3713 : super(name, offset); | 3789 : resynthesizerContext = null, |
| 3790 _unlinkedDefiningUnit = null, |
| 3791 super(name, offset); |
| 3714 | 3792 |
| 3715 /** | 3793 /** |
| 3716 * Initialize a newly created library element in the given [context] to have | 3794 * Initialize a newly created library element in the given [context] to have |
| 3717 * the given [name]. | 3795 * the given [name]. |
| 3718 */ | 3796 */ |
| 3719 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) | 3797 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) |
| 3720 : nameLength = name != null ? name.length : 0, | 3798 : nameLength = name != null ? name.length : 0, |
| 3799 resynthesizerContext = null, |
| 3800 _unlinkedDefiningUnit = null, |
| 3721 super.forNode(name); | 3801 super.forNode(name); |
| 3722 | 3802 |
| 3803 /** |
| 3804 * Initialize using the given serialized information. |
| 3805 */ |
| 3806 LibraryElementImpl.forSerialized(this.context, String name, int offset, |
| 3807 this.nameLength, this.resynthesizerContext, this._unlinkedDefiningUnit) |
| 3808 : super.forSerialized(null) { |
| 3809 _name = name; |
| 3810 _nameOffset = offset; |
| 3811 } |
| 3812 |
| 3723 @override | 3813 @override |
| 3724 int get codeLength { | 3814 int get codeLength { |
| 3725 CompilationUnitElement unit = _definingCompilationUnit; | 3815 CompilationUnitElement unit = _definingCompilationUnit; |
| 3726 if (unit is CompilationUnitElementImpl) { | 3816 if (unit is CompilationUnitElementImpl) { |
| 3727 return unit.codeLength; | 3817 return unit.codeLength; |
| 3728 } | 3818 } |
| 3729 return null; | 3819 return null; |
| 3730 } | 3820 } |
| 3731 | 3821 |
| 3732 @override | 3822 @override |
| (...skipping 13 matching lines...) Expand all Loading... |
| 3746 * Set the compilation unit that defines this library to the given compilation | 3836 * Set the compilation unit that defines this library to the given compilation |
| 3747 * [unit]. | 3837 * [unit]. |
| 3748 */ | 3838 */ |
| 3749 void set definingCompilationUnit(CompilationUnitElement unit) { | 3839 void set definingCompilationUnit(CompilationUnitElement unit) { |
| 3750 assert((unit as CompilationUnitElementImpl).librarySource == unit.source); | 3840 assert((unit as CompilationUnitElementImpl).librarySource == unit.source); |
| 3751 (unit as CompilationUnitElementImpl).enclosingElement = this; | 3841 (unit as CompilationUnitElementImpl).enclosingElement = this; |
| 3752 this._definingCompilationUnit = unit; | 3842 this._definingCompilationUnit = unit; |
| 3753 } | 3843 } |
| 3754 | 3844 |
| 3755 @override | 3845 @override |
| 3846 SourceRange get docRange { |
| 3847 if (_unlinkedDefiningUnit != null) { |
| 3848 UnlinkedDocumentationComment comment = |
| 3849 _unlinkedDefiningUnit.libraryDocumentationComment; |
| 3850 return comment != null |
| 3851 ? new SourceRange(comment.offset, comment.length) |
| 3852 : null; |
| 3853 } |
| 3854 return super.docRange; |
| 3855 } |
| 3856 |
| 3857 @override |
| 3858 String get documentationComment { |
| 3859 if (_unlinkedDefiningUnit != null) { |
| 3860 return _unlinkedDefiningUnit?.libraryDocumentationComment?.text; |
| 3861 } |
| 3862 return super.documentationComment; |
| 3863 } |
| 3864 |
| 3865 FunctionElement get entryPoint { |
| 3866 if (resynthesizerContext != null) { |
| 3867 _entryPoint ??= resynthesizerContext.findEntryPoint(); |
| 3868 } |
| 3869 return _entryPoint; |
| 3870 } |
| 3871 |
| 3872 void set entryPoint(FunctionElement entryPoint) { |
| 3873 _entryPoint = entryPoint; |
| 3874 } |
| 3875 |
| 3876 @override |
| 3756 List<LibraryElement> get exportedLibraries { | 3877 List<LibraryElement> get exportedLibraries { |
| 3757 HashSet<LibraryElement> libraries = new HashSet<LibraryElement>(); | 3878 HashSet<LibraryElement> libraries = new HashSet<LibraryElement>(); |
| 3758 for (ExportElement element in _exports) { | 3879 for (ExportElement element in _exports) { |
| 3759 LibraryElement library = element.exportedLibrary; | 3880 LibraryElement library = element.exportedLibrary; |
| 3760 if (library != null) { | 3881 if (library != null) { |
| 3761 libraries.add(library); | 3882 libraries.add(library); |
| 3762 } | 3883 } |
| 3763 } | 3884 } |
| 3764 return new List.from(libraries); | 3885 return new List.from(libraries); |
| 3765 } | 3886 } |
| 3766 | 3887 |
| 3767 @override | 3888 @override |
| 3889 Namespace get exportNamespace { |
| 3890 if (resynthesizerContext != null) { |
| 3891 _exportNamespace ??= resynthesizerContext.buildExportNamespace(); |
| 3892 } |
| 3893 return _exportNamespace; |
| 3894 } |
| 3895 |
| 3896 void set exportNamespace(Namespace exportNamespace) { |
| 3897 _exportNamespace = exportNamespace; |
| 3898 } |
| 3899 |
| 3900 @override |
| 3768 List<ExportElement> get exports => _exports; | 3901 List<ExportElement> get exports => _exports; |
| 3769 | 3902 |
| 3770 /** | 3903 /** |
| 3771 * Set the specifications of all of the exports defined in this library to the | 3904 * Set the specifications of all of the exports defined in this library to the |
| 3772 * given list of [exports]. | 3905 * given list of [exports]. |
| 3773 */ | 3906 */ |
| 3774 void set exports(List<ExportElement> exports) { | 3907 void set exports(List<ExportElement> exports) { |
| 3775 for (ExportElement exportElement in exports) { | 3908 for (ExportElement exportElement in exports) { |
| 3776 (exportElement as ExportElementImpl).enclosingElement = this; | 3909 (exportElement as ExportElementImpl).enclosingElement = this; |
| 3777 } | 3910 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3871 if (!visited.contains(exportedLibrary)) { | 4004 if (!visited.contains(exportedLibrary)) { |
| 3872 visited.add(exportedLibrary); | 4005 visited.add(exportedLibrary); |
| 3873 } | 4006 } |
| 3874 } | 4007 } |
| 3875 } | 4008 } |
| 3876 return false; | 4009 return false; |
| 3877 } | 4010 } |
| 3878 | 4011 |
| 3879 @override | 4012 @override |
| 3880 bool get isResynthesized { | 4013 bool get isResynthesized { |
| 3881 CompilationUnitElement definingUnit = _definingCompilationUnit; | 4014 return resynthesizerContext != null; |
| 3882 return definingUnit is CompilationUnitElementImpl && | |
| 3883 definingUnit.resynthesizerContext != null; | |
| 3884 } | 4015 } |
| 3885 | 4016 |
| 3886 @override | 4017 @override |
| 3887 ElementKind get kind => ElementKind.LIBRARY; | 4018 ElementKind get kind => ElementKind.LIBRARY; |
| 3888 | 4019 |
| 3889 @override | 4020 @override |
| 3890 LibraryElement get library => this; | 4021 LibraryElement get library => this; |
| 3891 | 4022 |
| 3892 @override | 4023 @override |
| 3893 List<LibraryElement> get libraryCycle { | 4024 List<LibraryElement> get libraryCycle { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3966 return _libraryCycle; | 4097 return _libraryCycle; |
| 3967 } | 4098 } |
| 3968 | 4099 |
| 3969 @override | 4100 @override |
| 3970 FunctionElement get loadLibraryFunction { | 4101 FunctionElement get loadLibraryFunction { |
| 3971 assert(_loadLibraryFunction != null); | 4102 assert(_loadLibraryFunction != null); |
| 3972 return _loadLibraryFunction; | 4103 return _loadLibraryFunction; |
| 3973 } | 4104 } |
| 3974 | 4105 |
| 3975 @override | 4106 @override |
| 4107 List<ElementAnnotation> get metadata { |
| 4108 if (_unlinkedDefiningUnit != null) { |
| 4109 if (_metadata == null) { |
| 4110 CompilationUnitElementImpl definingUnit = |
| 4111 _definingCompilationUnit as CompilationUnitElementImpl; |
| 4112 _metadata ??= _unlinkedDefiningUnit.libraryAnnotations |
| 4113 .map(definingUnit.resynthesizerContext.buildAnnotation) |
| 4114 .toList(); |
| 4115 } |
| 4116 return _metadata; |
| 4117 } |
| 4118 return super.metadata; |
| 4119 } |
| 4120 |
| 4121 @override |
| 3976 List<CompilationUnitElement> get parts => _parts; | 4122 List<CompilationUnitElement> get parts => _parts; |
| 3977 | 4123 |
| 3978 /** | 4124 /** |
| 3979 * Set the compilation units that are included in this library using a `part` | 4125 * Set the compilation units that are included in this library using a `part` |
| 3980 * directive to the given list of [parts]. | 4126 * directive to the given list of [parts]. |
| 3981 */ | 4127 */ |
| 3982 void set parts(List<CompilationUnitElement> parts) { | 4128 void set parts(List<CompilationUnitElement> parts) { |
| 3983 for (CompilationUnitElement compilationUnit in parts) { | 4129 for (CompilationUnitElement compilationUnit in parts) { |
| 3984 assert((compilationUnit as CompilationUnitElementImpl).librarySource == | 4130 assert((compilationUnit as CompilationUnitElementImpl).librarySource == |
| 3985 source); | 4131 source); |
| 3986 (compilationUnit as CompilationUnitElementImpl).enclosingElement = this; | 4132 (compilationUnit as CompilationUnitElementImpl).enclosingElement = this; |
| 3987 } | 4133 } |
| 3988 this._parts = parts; | 4134 this._parts = parts; |
| 3989 } | 4135 } |
| 3990 | 4136 |
| 3991 @override | 4137 @override |
| 3992 List<PrefixElement> get prefixes { | 4138 List<PrefixElement> get prefixes { |
| 3993 HashSet<PrefixElement> prefixes = new HashSet<PrefixElement>(); | 4139 HashSet<PrefixElement> prefixes = new HashSet<PrefixElement>(); |
| 3994 for (ImportElement element in _imports) { | 4140 for (ImportElement element in _imports) { |
| 3995 PrefixElement prefix = element.prefix; | 4141 PrefixElement prefix = element.prefix; |
| 3996 if (prefix != null) { | 4142 if (prefix != null) { |
| 3997 prefixes.add(prefix); | 4143 prefixes.add(prefix); |
| 3998 } | 4144 } |
| 3999 } | 4145 } |
| 4000 return new List.from(prefixes); | 4146 return new List.from(prefixes); |
| 4001 } | 4147 } |
| 4002 | 4148 |
| 4003 @override | 4149 @override |
| 4150 Namespace get publicNamespace { |
| 4151 if (resynthesizerContext != null) { |
| 4152 _publicNamespace ??= resynthesizerContext.buildPublicNamespace(); |
| 4153 } |
| 4154 return _publicNamespace; |
| 4155 } |
| 4156 |
| 4157 void set publicNamespace(Namespace publicNamespace) { |
| 4158 _publicNamespace = publicNamespace; |
| 4159 } |
| 4160 |
| 4161 @override |
| 4004 Source get source { | 4162 Source get source { |
| 4005 if (_definingCompilationUnit == null) { | 4163 if (_definingCompilationUnit == null) { |
| 4006 return null; | 4164 return null; |
| 4007 } | 4165 } |
| 4008 return _definingCompilationUnit.source; | 4166 return _definingCompilationUnit.source; |
| 4009 } | 4167 } |
| 4010 | 4168 |
| 4011 @override | 4169 @override |
| 4012 List<CompilationUnitElement> get units { | 4170 List<CompilationUnitElement> get units { |
| 4013 List<CompilationUnitElement> units = new List<CompilationUnitElement>(); | 4171 List<CompilationUnitElement> units = new List<CompilationUnitElement>(); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4226 if (!_safeIsUpToDate(exportedLibrary, timeStamp, visitedLibraries)) { | 4384 if (!_safeIsUpToDate(exportedLibrary, timeStamp, visitedLibraries)) { |
| 4227 return false; | 4385 return false; |
| 4228 } | 4386 } |
| 4229 } | 4387 } |
| 4230 } | 4388 } |
| 4231 return true; | 4389 return true; |
| 4232 } | 4390 } |
| 4233 } | 4391 } |
| 4234 | 4392 |
| 4235 /** | 4393 /** |
| 4394 * The context in which the library is resynthesized. |
| 4395 */ |
| 4396 abstract class LibraryResynthesizerContext { |
| 4397 /** |
| 4398 * Return the export namespace of the library. |
| 4399 */ |
| 4400 Namespace buildExportNamespace(); |
| 4401 |
| 4402 /** |
| 4403 * Return the public namespace of the library. |
| 4404 */ |
| 4405 Namespace buildPublicNamespace(); |
| 4406 |
| 4407 /** |
| 4408 * Find the entry point of the library. |
| 4409 */ |
| 4410 FunctionElement findEntryPoint(); |
| 4411 |
| 4412 /** |
| 4413 * Ensure that getters and setters in different units use the same |
| 4414 * top-level variables. |
| 4415 */ |
| 4416 void patchTopLevelAccessors(); |
| 4417 } |
| 4418 |
| 4419 /** |
| 4236 * A concrete implementation of a [LocalVariableElement]. | 4420 * A concrete implementation of a [LocalVariableElement]. |
| 4237 */ | 4421 */ |
| 4238 class LocalVariableElementImpl extends NonParameterVariableElementImpl | 4422 class LocalVariableElementImpl extends NonParameterVariableElementImpl |
| 4239 implements LocalVariableElement { | 4423 implements LocalVariableElement { |
| 4240 /** | 4424 /** |
| 4241 * The offset to the beginning of the visible range for this element. | 4425 * The offset to the beginning of the visible range for this element. |
| 4242 */ | 4426 */ |
| 4243 int _visibleRangeOffset = 0; | 4427 int _visibleRangeOffset = 0; |
| 4244 | 4428 |
| 4245 /** | 4429 /** |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4849 return super.codeOffset; | 5033 return super.codeOffset; |
| 4850 } | 5034 } |
| 4851 | 5035 |
| 4852 @override | 5036 @override |
| 4853 void set const3(bool isConst) { | 5037 void set const3(bool isConst) { |
| 4854 assert(_unlinkedVariable == null); | 5038 assert(_unlinkedVariable == null); |
| 4855 super.const3 = isConst; | 5039 super.const3 = isConst; |
| 4856 } | 5040 } |
| 4857 | 5041 |
| 4858 @override | 5042 @override |
| 5043 SourceRange get docRange { |
| 5044 if (_unlinkedVariable != null) { |
| 5045 UnlinkedDocumentationComment comment = |
| 5046 _unlinkedVariable.documentationComment; |
| 5047 return comment != null |
| 5048 ? new SourceRange(comment.offset, comment.length) |
| 5049 : null; |
| 5050 } |
| 5051 return super.docRange; |
| 5052 } |
| 5053 |
| 5054 @override |
| 5055 String get documentationComment { |
| 5056 if (_unlinkedVariable != null) { |
| 5057 return _unlinkedVariable?.documentationComment?.text; |
| 5058 } |
| 5059 return super.documentationComment; |
| 5060 } |
| 5061 |
| 5062 @override |
| 4859 void set final2(bool isFinal) { | 5063 void set final2(bool isFinal) { |
| 4860 assert(_unlinkedVariable == null); | 5064 assert(_unlinkedVariable == null); |
| 4861 super.final2 = isFinal; | 5065 super.final2 = isFinal; |
| 4862 } | 5066 } |
| 4863 | 5067 |
| 4864 @override | 5068 @override |
| 4865 bool get hasImplicitType { | 5069 bool get hasImplicitType { |
| 4866 if (_unlinkedVariable != null) { | 5070 if (_unlinkedVariable != null) { |
| 4867 return _unlinkedVariable.type == null; | 5071 return _unlinkedVariable.type == null; |
| 4868 } | 5072 } |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5483 /** | 5687 /** |
| 5484 * Initialize a newly created synthetic element to have the given [name] and | 5688 * Initialize a newly created synthetic element to have the given [name] and |
| 5485 * [offset]. | 5689 * [offset]. |
| 5486 */ | 5690 */ |
| 5487 PropertyInducingElementImpl(String name, int offset) : super(name, offset); | 5691 PropertyInducingElementImpl(String name, int offset) : super(name, offset); |
| 5488 | 5692 |
| 5489 /** | 5693 /** |
| 5490 * Initialize a newly created element to have the given [name]. | 5694 * Initialize a newly created element to have the given [name]. |
| 5491 */ | 5695 */ |
| 5492 PropertyInducingElementImpl.forNode(Identifier name) : super.forNode(name); | 5696 PropertyInducingElementImpl.forNode(Identifier name) : super.forNode(name); |
| 5697 |
| 5698 /** |
| 5699 * Initialize using the given serialized information. |
| 5700 */ |
| 5701 PropertyInducingElementImpl.forSerialized( |
| 5702 UnlinkedVariable unlinkedVariable, ElementImpl enclosingElement) |
| 5703 : super.forSerialized(unlinkedVariable, enclosingElement); |
| 5493 } | 5704 } |
| 5494 | 5705 |
| 5495 /** | 5706 /** |
| 5496 * The context in which elements are resynthesized. | 5707 * The context in which elements are resynthesized. |
| 5497 */ | 5708 */ |
| 5498 abstract class ResynthesizerContext { | 5709 abstract class ResynthesizerContext { |
| 5499 /** | 5710 /** |
| 5500 * Build [ElementAnnotationImpl] for the given [UnlinkedConst]. | 5711 * Build [ElementAnnotationImpl] for the given [UnlinkedConst]. |
| 5501 */ | 5712 */ |
| 5502 ElementAnnotationImpl buildAnnotation(UnlinkedConst uc); | 5713 ElementAnnotationImpl buildAnnotation(UnlinkedConst uc); |
| 5503 | 5714 |
| 5504 /** | 5715 /** |
| 5505 * Build [Expression] for the given [UnlinkedConst]. | 5716 * Build [Expression] for the given [UnlinkedConst]. |
| 5506 */ | 5717 */ |
| 5507 Expression buildExpression(UnlinkedConst uc); | 5718 Expression buildExpression(UnlinkedConst uc); |
| 5508 | 5719 |
| 5509 /** | 5720 /** |
| 5721 * Build explicit top-level property accessors. |
| 5722 */ |
| 5723 UnitExplicitTopLevelAccessors buildTopLevelAccessors(); |
| 5724 |
| 5725 /** |
| 5726 * Build explicit top-level variables. |
| 5727 */ |
| 5728 UnitExplicitTopLevelVariables buildTopLevelVariables(); |
| 5729 |
| 5730 /** |
| 5510 * Resolve an [EntityRef] into a type. If the reference is | 5731 * Resolve an [EntityRef] into a type. If the reference is |
| 5511 * unresolved, return [DynamicTypeImpl.instance]. | 5732 * unresolved, return [DynamicTypeImpl.instance]. |
| 5512 * | 5733 * |
| 5513 * TODO(paulberry): or should we have a class representing an | 5734 * TODO(paulberry): or should we have a class representing an |
| 5514 * unresolved type, for consistency with the full element model? | 5735 * unresolved type, for consistency with the full element model? |
| 5515 */ | 5736 */ |
| 5516 DartType resolveTypeRef( | 5737 DartType resolveTypeRef( |
| 5517 EntityRef type, TypeParameterizedElementMixin typeParameterContext, | 5738 EntityRef type, TypeParameterizedElementMixin typeParameterContext, |
| 5518 {bool defaultVoid: false, bool instantiateToBoundsAllowed: true}); | 5739 {bool defaultVoid: false, bool instantiateToBoundsAllowed: true}); |
| 5519 } | 5740 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5564 * given [name] and [offset]. | 5785 * given [name] and [offset]. |
| 5565 */ | 5786 */ |
| 5566 TopLevelVariableElementImpl(String name, int offset) : super(name, offset); | 5787 TopLevelVariableElementImpl(String name, int offset) : super(name, offset); |
| 5567 | 5788 |
| 5568 /** | 5789 /** |
| 5569 * Initialize a newly created top-level variable element to have the given | 5790 * Initialize a newly created top-level variable element to have the given |
| 5570 * [name]. | 5791 * [name]. |
| 5571 */ | 5792 */ |
| 5572 TopLevelVariableElementImpl.forNode(Identifier name) : super.forNode(name); | 5793 TopLevelVariableElementImpl.forNode(Identifier name) : super.forNode(name); |
| 5573 | 5794 |
| 5795 /** |
| 5796 * Initialize using the given serialized information. |
| 5797 */ |
| 5798 TopLevelVariableElementImpl.forSerialized( |
| 5799 UnlinkedVariable unlinkedVariable, ElementImpl enclosingElement) |
| 5800 : super.forSerialized(unlinkedVariable, enclosingElement); |
| 5801 |
| 5574 @override | 5802 @override |
| 5575 bool get isStatic => true; | 5803 bool get isStatic => true; |
| 5576 | 5804 |
| 5577 @override | 5805 @override |
| 5578 ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE; | 5806 ElementKind get kind => ElementKind.TOP_LEVEL_VARIABLE; |
| 5579 | 5807 |
| 5580 @override | 5808 @override |
| 5581 accept(ElementVisitor visitor) => visitor.visitTopLevelVariableElement(this); | 5809 accept(ElementVisitor visitor) => visitor.visitTopLevelVariableElement(this); |
| 5582 | 5810 |
| 5583 @override | 5811 @override |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5844 } else if (enclosingTypeParameterContext != null) { | 6072 } else if (enclosingTypeParameterContext != null) { |
| 5845 return enclosingTypeParameterContext | 6073 return enclosingTypeParameterContext |
| 5846 .isTypeParameterInScope(typeParameter); | 6074 .isTypeParameterInScope(typeParameter); |
| 5847 } else { | 6075 } else { |
| 5848 return false; | 6076 return false; |
| 5849 } | 6077 } |
| 5850 } | 6078 } |
| 5851 } | 6079 } |
| 5852 | 6080 |
| 5853 /** | 6081 /** |
| 6082 * Container with information about explicit top-level property accessors and |
| 6083 * corresponding implicit top-level variables. |
| 6084 */ |
| 6085 class UnitExplicitTopLevelAccessors { |
| 6086 final List<PropertyAccessorElementImpl> accessors = |
| 6087 <PropertyAccessorElementImpl>[]; |
| 6088 final List<TopLevelVariableElementImpl> implicitVariables = |
| 6089 <TopLevelVariableElementImpl>[]; |
| 6090 } |
| 6091 |
| 6092 /** |
| 6093 * Container with information about explicit top-level variables and |
| 6094 * corresponding implicit top-level property accessors. |
| 6095 */ |
| 6096 class UnitExplicitTopLevelVariables { |
| 6097 final List<TopLevelVariableElementImpl> variables = |
| 6098 <TopLevelVariableElementImpl>[]; |
| 6099 final List<PropertyAccessorElementImpl> implicitAccessors = |
| 6100 <PropertyAccessorElementImpl>[]; |
| 6101 } |
| 6102 |
| 6103 /** |
| 5854 * A concrete implementation of a [UriReferencedElement]. | 6104 * A concrete implementation of a [UriReferencedElement]. |
| 5855 */ | 6105 */ |
| 5856 abstract class UriReferencedElementImpl extends ElementImpl | 6106 abstract class UriReferencedElementImpl extends ElementImpl |
| 5857 implements UriReferencedElement { | 6107 implements UriReferencedElement { |
| 5858 /** | 6108 /** |
| 5859 * The offset of the URI in the file, may be `-1` if synthetic. | 6109 * The offset of the URI in the file, may be `-1` if synthetic. |
| 5860 */ | 6110 */ |
| 5861 int uriOffset = -1; | 6111 int uriOffset = -1; |
| 5862 | 6112 |
| 5863 /** | 6113 /** |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6037 | 6287 |
| 6038 @override | 6288 @override |
| 6039 void visitElement(Element element) { | 6289 void visitElement(Element element) { |
| 6040 int offset = element.nameOffset; | 6290 int offset = element.nameOffset; |
| 6041 if (offset != -1) { | 6291 if (offset != -1) { |
| 6042 map[offset] = element; | 6292 map[offset] = element; |
| 6043 } | 6293 } |
| 6044 super.visitElement(element); | 6294 super.visitElement(element); |
| 6045 } | 6295 } |
| 6046 } | 6296 } |
| OLD | NEW |