| 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.test.generated.all_the_rest_test; | 5 library analyzer.test.generated.all_the_rest_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 expect(types, hasLength(1)); | 730 expect(types, hasLength(1)); |
| 731 ClassElement type = types[0]; | 731 ClassElement type = types[0]; |
| 732 expect(type, isNotNull); | 732 expect(type, isNotNull); |
| 733 expect(type.name, className); | 733 expect(type.name, className); |
| 734 List<TypeParameterElement> typeParameters = type.typeParameters; | 734 List<TypeParameterElement> typeParameters = type.typeParameters; |
| 735 expect(typeParameters, hasLength(0)); | 735 expect(typeParameters, hasLength(0)); |
| 736 expect(type.isAbstract, isFalse); | 736 expect(type.isAbstract, isFalse); |
| 737 expect(type.isMixinApplication, isFalse); | 737 expect(type.isMixinApplication, isFalse); |
| 738 expect(type.isSynthetic, isFalse); | 738 expect(type.isSynthetic, isFalse); |
| 739 expect(type.documentationComment, '/// aaa'); | 739 expect(type.documentationComment, '/// aaa'); |
| 740 _assertHasDocRange(type, 50, 7); | |
| 741 _assertHasCodeRange(type, 50, 31); | 740 _assertHasCodeRange(type, 50, 31); |
| 742 } | 741 } |
| 743 | 742 |
| 744 void test_visitClassDeclaration_parameterized() { | 743 void test_visitClassDeclaration_parameterized() { |
| 745 ElementHolder holder = new ElementHolder(); | 744 ElementHolder holder = new ElementHolder(); |
| 746 ElementBuilder builder = _makeBuilder(holder); | 745 ElementBuilder builder = _makeBuilder(holder); |
| 747 String className = "C"; | 746 String className = "C"; |
| 748 String firstVariableName = "E"; | 747 String firstVariableName = "E"; |
| 749 String secondVariableName = "F"; | 748 String secondVariableName = "F"; |
| 750 ClassDeclaration classDeclaration = AstFactory.classDeclaration( | 749 ClassDeclaration classDeclaration = AstFactory.classDeclaration( |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 996 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 998 constructorDeclaration.endToken.offset = 80; | 997 constructorDeclaration.endToken.offset = 80; |
| 999 constructorDeclaration.accept(builder); | 998 constructorDeclaration.accept(builder); |
| 1000 | 999 |
| 1001 List<ConstructorElement> constructors = holder.constructors; | 1000 List<ConstructorElement> constructors = holder.constructors; |
| 1002 expect(constructors, hasLength(1)); | 1001 expect(constructors, hasLength(1)); |
| 1003 ConstructorElement constructor = constructors[0]; | 1002 ConstructorElement constructor = constructors[0]; |
| 1004 expect(constructor, isNotNull); | 1003 expect(constructor, isNotNull); |
| 1005 _assertHasCodeRange(constructor, 50, 31); | 1004 _assertHasCodeRange(constructor, 50, 31); |
| 1006 expect(constructor.documentationComment, '/// aaa'); | 1005 expect(constructor.documentationComment, '/// aaa'); |
| 1007 _assertHasDocRange(constructor, 50, 7); | |
| 1008 expect(constructor.isExternal, isFalse); | 1006 expect(constructor.isExternal, isFalse); |
| 1009 expect(constructor.isFactory, isFalse); | 1007 expect(constructor.isFactory, isFalse); |
| 1010 expect(constructor.name, ""); | 1008 expect(constructor.name, ""); |
| 1011 expect(constructor.functions, hasLength(0)); | 1009 expect(constructor.functions, hasLength(0)); |
| 1012 expect(constructor.labels, hasLength(0)); | 1010 expect(constructor.labels, hasLength(0)); |
| 1013 expect(constructor.localVariables, hasLength(0)); | 1011 expect(constructor.localVariables, hasLength(0)); |
| 1014 expect(constructor.parameters, hasLength(0)); | 1012 expect(constructor.parameters, hasLength(0)); |
| 1015 } | 1013 } |
| 1016 | 1014 |
| 1017 void test_visitConstructorDeclaration_named() { | 1015 void test_visitConstructorDeclaration_named() { |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 enumDeclaration.documentationComment = AstFactory.documentationComment( | 1198 enumDeclaration.documentationComment = AstFactory.documentationComment( |
| 1201 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 1199 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 1202 enumDeclaration.endToken.offset = 80; | 1200 enumDeclaration.endToken.offset = 80; |
| 1203 enumDeclaration.accept(builder); | 1201 enumDeclaration.accept(builder); |
| 1204 List<ClassElement> enums = holder.enums; | 1202 List<ClassElement> enums = holder.enums; |
| 1205 expect(enums, hasLength(1)); | 1203 expect(enums, hasLength(1)); |
| 1206 ClassElement enumElement = enums[0]; | 1204 ClassElement enumElement = enums[0]; |
| 1207 expect(enumElement, isNotNull); | 1205 expect(enumElement, isNotNull); |
| 1208 _assertHasCodeRange(enumElement, 50, 31); | 1206 _assertHasCodeRange(enumElement, 50, 31); |
| 1209 expect(enumElement.documentationComment, '/// aaa'); | 1207 expect(enumElement.documentationComment, '/// aaa'); |
| 1210 _assertHasDocRange(enumElement, 50, 7); | |
| 1211 expect(enumElement.name, enumName); | 1208 expect(enumElement.name, enumName); |
| 1212 } | 1209 } |
| 1213 | 1210 |
| 1214 void test_visitFieldDeclaration() { | 1211 void test_visitFieldDeclaration() { |
| 1215 ElementHolder holder = new ElementHolder(); | 1212 ElementHolder holder = new ElementHolder(); |
| 1216 ElementBuilder builder = _makeBuilder(holder); | 1213 ElementBuilder builder = _makeBuilder(holder); |
| 1217 String firstFieldName = "x"; | 1214 String firstFieldName = "x"; |
| 1218 String secondFieldName = "y"; | 1215 String secondFieldName = "y"; |
| 1219 FieldDeclaration fieldDeclaration = | 1216 FieldDeclaration fieldDeclaration = |
| 1220 AstFactory.fieldDeclaration2(false, null, [ | 1217 AstFactory.fieldDeclaration2(false, null, [ |
| 1221 AstFactory.variableDeclaration(firstFieldName), | 1218 AstFactory.variableDeclaration(firstFieldName), |
| 1222 AstFactory.variableDeclaration(secondFieldName) | 1219 AstFactory.variableDeclaration(secondFieldName) |
| 1223 ]); | 1220 ]); |
| 1224 fieldDeclaration.documentationComment = AstFactory.documentationComment( | 1221 fieldDeclaration.documentationComment = AstFactory.documentationComment( |
| 1225 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 1222 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 1226 fieldDeclaration.endToken.offset = 110; | 1223 fieldDeclaration.endToken.offset = 110; |
| 1227 fieldDeclaration.accept(builder); | 1224 fieldDeclaration.accept(builder); |
| 1228 | 1225 |
| 1229 List<FieldElement> fields = holder.fields; | 1226 List<FieldElement> fields = holder.fields; |
| 1230 expect(fields, hasLength(2)); | 1227 expect(fields, hasLength(2)); |
| 1231 | 1228 |
| 1232 FieldElement firstField = fields[0]; | 1229 FieldElement firstField = fields[0]; |
| 1233 expect(firstField, isNotNull); | 1230 expect(firstField, isNotNull); |
| 1234 _assertHasCodeRange(firstField, 50, 61); | 1231 _assertHasCodeRange(firstField, 50, 61); |
| 1235 expect(firstField.documentationComment, '/// aaa'); | 1232 expect(firstField.documentationComment, '/// aaa'); |
| 1236 _assertHasDocRange(firstField, 50, 7); | |
| 1237 expect(firstField.name, firstFieldName); | 1233 expect(firstField.name, firstFieldName); |
| 1238 expect(firstField.initializer, isNull); | 1234 expect(firstField.initializer, isNull); |
| 1239 expect(firstField.isConst, isFalse); | 1235 expect(firstField.isConst, isFalse); |
| 1240 expect(firstField.isFinal, isFalse); | 1236 expect(firstField.isFinal, isFalse); |
| 1241 expect(firstField.isSynthetic, isFalse); | 1237 expect(firstField.isSynthetic, isFalse); |
| 1242 | 1238 |
| 1243 FieldElement secondField = fields[1]; | 1239 FieldElement secondField = fields[1]; |
| 1244 expect(secondField, isNotNull); | 1240 expect(secondField, isNotNull); |
| 1245 _assertHasCodeRange(secondField, 50, 61); | 1241 _assertHasCodeRange(secondField, 50, 61); |
| 1246 expect(secondField.documentationComment, '/// aaa'); | 1242 expect(secondField.documentationComment, '/// aaa'); |
| 1247 _assertHasDocRange(secondField, 50, 7); | |
| 1248 expect(secondField.name, secondFieldName); | 1243 expect(secondField.name, secondFieldName); |
| 1249 expect(secondField.initializer, isNull); | 1244 expect(secondField.initializer, isNull); |
| 1250 expect(secondField.isConst, isFalse); | 1245 expect(secondField.isConst, isFalse); |
| 1251 expect(secondField.isFinal, isFalse); | 1246 expect(secondField.isFinal, isFalse); |
| 1252 expect(secondField.isSynthetic, isFalse); | 1247 expect(secondField.isSynthetic, isFalse); |
| 1253 } | 1248 } |
| 1254 | 1249 |
| 1255 void test_visitFieldFormalParameter() { | 1250 void test_visitFieldFormalParameter() { |
| 1256 ElementHolder holder = new ElementHolder(); | 1251 ElementHolder holder = new ElementHolder(); |
| 1257 ElementBuilder builder = _makeBuilder(holder); | 1252 ElementBuilder builder = _makeBuilder(holder); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1358 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 1353 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 1359 declaration.endToken.offset = 80; | 1354 declaration.endToken.offset = 80; |
| 1360 declaration.accept(builder); | 1355 declaration.accept(builder); |
| 1361 | 1356 |
| 1362 List<PropertyAccessorElement> accessors = holder.accessors; | 1357 List<PropertyAccessorElement> accessors = holder.accessors; |
| 1363 expect(accessors, hasLength(1)); | 1358 expect(accessors, hasLength(1)); |
| 1364 PropertyAccessorElement accessor = accessors[0]; | 1359 PropertyAccessorElement accessor = accessors[0]; |
| 1365 expect(accessor, isNotNull); | 1360 expect(accessor, isNotNull); |
| 1366 _assertHasCodeRange(accessor, 50, 31); | 1361 _assertHasCodeRange(accessor, 50, 31); |
| 1367 expect(accessor.documentationComment, '/// aaa'); | 1362 expect(accessor.documentationComment, '/// aaa'); |
| 1368 _assertHasDocRange(accessor, 50, 7); | |
| 1369 expect(accessor.name, functionName); | 1363 expect(accessor.name, functionName); |
| 1370 expect(declaration.element, same(accessor)); | 1364 expect(declaration.element, same(accessor)); |
| 1371 expect(declaration.functionExpression.element, same(accessor)); | 1365 expect(declaration.functionExpression.element, same(accessor)); |
| 1372 expect(accessor.hasImplicitReturnType, isTrue); | 1366 expect(accessor.hasImplicitReturnType, isTrue); |
| 1373 expect(accessor.isGetter, isTrue); | 1367 expect(accessor.isGetter, isTrue); |
| 1374 expect(accessor.isExternal, isFalse); | 1368 expect(accessor.isExternal, isFalse); |
| 1375 expect(accessor.isSetter, isFalse); | 1369 expect(accessor.isSetter, isFalse); |
| 1376 expect(accessor.isSynthetic, isFalse); | 1370 expect(accessor.isSynthetic, isFalse); |
| 1377 expect(accessor.typeParameters, hasLength(0)); | 1371 expect(accessor.typeParameters, hasLength(0)); |
| 1378 PropertyInducingElement variable = accessor.variable; | 1372 PropertyInducingElement variable = accessor.variable; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1396 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 1390 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 1397 declaration.endToken.offset = 80; | 1391 declaration.endToken.offset = 80; |
| 1398 declaration.accept(builder); | 1392 declaration.accept(builder); |
| 1399 | 1393 |
| 1400 List<FunctionElement> functions = holder.functions; | 1394 List<FunctionElement> functions = holder.functions; |
| 1401 expect(functions, hasLength(1)); | 1395 expect(functions, hasLength(1)); |
| 1402 FunctionElement function = functions[0]; | 1396 FunctionElement function = functions[0]; |
| 1403 expect(function, isNotNull); | 1397 expect(function, isNotNull); |
| 1404 _assertHasCodeRange(function, 50, 31); | 1398 _assertHasCodeRange(function, 50, 31); |
| 1405 expect(function.documentationComment, '/// aaa'); | 1399 expect(function.documentationComment, '/// aaa'); |
| 1406 _assertHasDocRange(function, 50, 7); | |
| 1407 expect(function.hasImplicitReturnType, isFalse); | 1400 expect(function.hasImplicitReturnType, isFalse); |
| 1408 expect(function.name, functionName); | 1401 expect(function.name, functionName); |
| 1409 expect(declaration.element, same(function)); | 1402 expect(declaration.element, same(function)); |
| 1410 expect(declaration.functionExpression.element, same(function)); | 1403 expect(declaration.functionExpression.element, same(function)); |
| 1411 expect(function.isExternal, isFalse); | 1404 expect(function.isExternal, isFalse); |
| 1412 expect(function.isSynthetic, isFalse); | 1405 expect(function.isSynthetic, isFalse); |
| 1413 expect(function.typeParameters, hasLength(0)); | 1406 expect(function.typeParameters, hasLength(0)); |
| 1414 } | 1407 } |
| 1415 | 1408 |
| 1416 void test_visitFunctionDeclaration_setter() { | 1409 void test_visitFunctionDeclaration_setter() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1428 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 1421 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 1429 declaration.endToken.offset = 80; | 1422 declaration.endToken.offset = 80; |
| 1430 declaration.accept(builder); | 1423 declaration.accept(builder); |
| 1431 | 1424 |
| 1432 List<PropertyAccessorElement> accessors = holder.accessors; | 1425 List<PropertyAccessorElement> accessors = holder.accessors; |
| 1433 expect(accessors, hasLength(1)); | 1426 expect(accessors, hasLength(1)); |
| 1434 PropertyAccessorElement accessor = accessors[0]; | 1427 PropertyAccessorElement accessor = accessors[0]; |
| 1435 expect(accessor, isNotNull); | 1428 expect(accessor, isNotNull); |
| 1436 _assertHasCodeRange(accessor, 50, 31); | 1429 _assertHasCodeRange(accessor, 50, 31); |
| 1437 expect(accessor.documentationComment, '/// aaa'); | 1430 expect(accessor.documentationComment, '/// aaa'); |
| 1438 _assertHasDocRange(accessor, 50, 7); | |
| 1439 expect(accessor.hasImplicitReturnType, isTrue); | 1431 expect(accessor.hasImplicitReturnType, isTrue); |
| 1440 expect(accessor.name, "$functionName="); | 1432 expect(accessor.name, "$functionName="); |
| 1441 expect(declaration.element, same(accessor)); | 1433 expect(declaration.element, same(accessor)); |
| 1442 expect(declaration.functionExpression.element, same(accessor)); | 1434 expect(declaration.functionExpression.element, same(accessor)); |
| 1443 expect(accessor.isGetter, isFalse); | 1435 expect(accessor.isGetter, isFalse); |
| 1444 expect(accessor.isExternal, isFalse); | 1436 expect(accessor.isExternal, isFalse); |
| 1445 expect(accessor.isSetter, isTrue); | 1437 expect(accessor.isSetter, isTrue); |
| 1446 expect(accessor.isSynthetic, isFalse); | 1438 expect(accessor.isSynthetic, isFalse); |
| 1447 expect(accessor.typeParameters, hasLength(0)); | 1439 expect(accessor.typeParameters, hasLength(0)); |
| 1448 PropertyInducingElement variable = accessor.variable; | 1440 PropertyInducingElement variable = accessor.variable; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 1501 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 1510 aliasNode.endToken.offset = 80; | 1502 aliasNode.endToken.offset = 80; |
| 1511 aliasNode.accept(builder); | 1503 aliasNode.accept(builder); |
| 1512 | 1504 |
| 1513 List<FunctionTypeAliasElement> aliases = holder.typeAliases; | 1505 List<FunctionTypeAliasElement> aliases = holder.typeAliases; |
| 1514 expect(aliases, hasLength(1)); | 1506 expect(aliases, hasLength(1)); |
| 1515 FunctionTypeAliasElement alias = aliases[0]; | 1507 FunctionTypeAliasElement alias = aliases[0]; |
| 1516 expect(alias, isNotNull); | 1508 expect(alias, isNotNull); |
| 1517 _assertHasCodeRange(alias, 50, 31); | 1509 _assertHasCodeRange(alias, 50, 31); |
| 1518 expect(alias.documentationComment, '/// aaa'); | 1510 expect(alias.documentationComment, '/// aaa'); |
| 1519 _assertHasDocRange(alias, 50, 7); | |
| 1520 expect(alias.name, aliasName); | 1511 expect(alias.name, aliasName); |
| 1521 expect(alias.parameters, hasLength(0)); | 1512 expect(alias.parameters, hasLength(0)); |
| 1522 List<TypeParameterElement> typeParameters = alias.typeParameters; | 1513 List<TypeParameterElement> typeParameters = alias.typeParameters; |
| 1523 expect(typeParameters, hasLength(1)); | 1514 expect(typeParameters, hasLength(1)); |
| 1524 TypeParameterElement typeParameter = typeParameters[0]; | 1515 TypeParameterElement typeParameter = typeParameters[0]; |
| 1525 expect(typeParameter, isNotNull); | 1516 expect(typeParameter, isNotNull); |
| 1526 expect(typeParameter.name, parameterName); | 1517 expect(typeParameter.name, parameterName); |
| 1527 } | 1518 } |
| 1528 | 1519 |
| 1529 void test_visitFunctionTypedFormalParameter() { | 1520 void test_visitFunctionTypedFormalParameter() { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 expect(fields, hasLength(1)); | 1701 expect(fields, hasLength(1)); |
| 1711 FieldElement field = fields[0]; | 1702 FieldElement field = fields[0]; |
| 1712 expect(field, isNotNull); | 1703 expect(field, isNotNull); |
| 1713 expect(field.name, methodName); | 1704 expect(field.name, methodName); |
| 1714 expect(field.isSynthetic, isTrue); | 1705 expect(field.isSynthetic, isTrue); |
| 1715 expect(field.setter, isNull); | 1706 expect(field.setter, isNull); |
| 1716 PropertyAccessorElement getter = field.getter; | 1707 PropertyAccessorElement getter = field.getter; |
| 1717 expect(getter, isNotNull); | 1708 expect(getter, isNotNull); |
| 1718 _assertHasCodeRange(getter, 50, 31); | 1709 _assertHasCodeRange(getter, 50, 31); |
| 1719 expect(getter.documentationComment, '/// aaa'); | 1710 expect(getter.documentationComment, '/// aaa'); |
| 1720 _assertHasDocRange(getter, 50, 7); | |
| 1721 expect(getter.hasImplicitReturnType, isTrue); | 1711 expect(getter.hasImplicitReturnType, isTrue); |
| 1722 expect(getter.isAbstract, isFalse); | 1712 expect(getter.isAbstract, isFalse); |
| 1723 expect(getter.isExternal, isFalse); | 1713 expect(getter.isExternal, isFalse); |
| 1724 expect(getter.isGetter, isTrue); | 1714 expect(getter.isGetter, isTrue); |
| 1725 expect(getter.isSynthetic, isFalse); | 1715 expect(getter.isSynthetic, isFalse); |
| 1726 expect(getter.name, methodName); | 1716 expect(getter.name, methodName); |
| 1727 expect(getter.variable, field); | 1717 expect(getter.variable, field); |
| 1728 expect(getter.functions, hasLength(0)); | 1718 expect(getter.functions, hasLength(0)); |
| 1729 expect(getter.labels, hasLength(0)); | 1719 expect(getter.labels, hasLength(0)); |
| 1730 expect(getter.localVariables, hasLength(0)); | 1720 expect(getter.localVariables, hasLength(0)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1823 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 1813 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 1824 methodDeclaration.endToken.offset = 80; | 1814 methodDeclaration.endToken.offset = 80; |
| 1825 methodDeclaration.accept(builder); | 1815 methodDeclaration.accept(builder); |
| 1826 | 1816 |
| 1827 List<MethodElement> methods = holder.methods; | 1817 List<MethodElement> methods = holder.methods; |
| 1828 expect(methods, hasLength(1)); | 1818 expect(methods, hasLength(1)); |
| 1829 MethodElement method = methods[0]; | 1819 MethodElement method = methods[0]; |
| 1830 expect(method, isNotNull); | 1820 expect(method, isNotNull); |
| 1831 _assertHasCodeRange(method, 50, 31); | 1821 _assertHasCodeRange(method, 50, 31); |
| 1832 expect(method.documentationComment, '/// aaa'); | 1822 expect(method.documentationComment, '/// aaa'); |
| 1833 _assertHasDocRange(method, 50, 7); | |
| 1834 expect(method.hasImplicitReturnType, isFalse); | 1823 expect(method.hasImplicitReturnType, isFalse); |
| 1835 expect(method.name, methodName); | 1824 expect(method.name, methodName); |
| 1836 expect(method.functions, hasLength(0)); | 1825 expect(method.functions, hasLength(0)); |
| 1837 expect(method.labels, hasLength(0)); | 1826 expect(method.labels, hasLength(0)); |
| 1838 expect(method.localVariables, hasLength(0)); | 1827 expect(method.localVariables, hasLength(0)); |
| 1839 expect(method.parameters, hasLength(0)); | 1828 expect(method.parameters, hasLength(0)); |
| 1840 expect(method.typeParameters, hasLength(0)); | 1829 expect(method.typeParameters, hasLength(0)); |
| 1841 expect(method.isAbstract, isFalse); | 1830 expect(method.isAbstract, isFalse); |
| 1842 expect(method.isExternal, isFalse); | 1831 expect(method.isExternal, isFalse); |
| 1843 expect(method.isStatic, isFalse); | 1832 expect(method.isStatic, isFalse); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1900 FieldElement field = fields[0]; | 1889 FieldElement field = fields[0]; |
| 1901 expect(field, isNotNull); | 1890 expect(field, isNotNull); |
| 1902 expect(field.name, methodName); | 1891 expect(field.name, methodName); |
| 1903 expect(field.isSynthetic, isTrue); | 1892 expect(field.isSynthetic, isTrue); |
| 1904 expect(field.getter, isNull); | 1893 expect(field.getter, isNull); |
| 1905 | 1894 |
| 1906 PropertyAccessorElement setter = field.setter; | 1895 PropertyAccessorElement setter = field.setter; |
| 1907 expect(setter, isNotNull); | 1896 expect(setter, isNotNull); |
| 1908 _assertHasCodeRange(setter, 50, 31); | 1897 _assertHasCodeRange(setter, 50, 31); |
| 1909 expect(setter.documentationComment, '/// aaa'); | 1898 expect(setter.documentationComment, '/// aaa'); |
| 1910 _assertHasDocRange(setter, 50, 7); | |
| 1911 expect(setter.hasImplicitReturnType, isTrue); | 1899 expect(setter.hasImplicitReturnType, isTrue); |
| 1912 expect(setter.isAbstract, isFalse); | 1900 expect(setter.isAbstract, isFalse); |
| 1913 expect(setter.isExternal, isFalse); | 1901 expect(setter.isExternal, isFalse); |
| 1914 expect(setter.isSetter, isTrue); | 1902 expect(setter.isSetter, isTrue); |
| 1915 expect(setter.isSynthetic, isFalse); | 1903 expect(setter.isSynthetic, isFalse); |
| 1916 expect(setter.name, "$methodName="); | 1904 expect(setter.name, "$methodName="); |
| 1917 expect(setter.displayName, methodName); | 1905 expect(setter.displayName, methodName); |
| 1918 expect(setter.variable, field); | 1906 expect(setter.variable, field); |
| 1919 expect(setter.functions, hasLength(0)); | 1907 expect(setter.functions, hasLength(0)); |
| 1920 expect(setter.labels, hasLength(0)); | 1908 expect(setter.labels, hasLength(0)); |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2489 expect(variable.hasImplicitType, isTrue); | 2477 expect(variable.hasImplicitType, isTrue); |
| 2490 expect(variable.initializer, isNull); | 2478 expect(variable.initializer, isNull); |
| 2491 expect(variable.name, variableName); | 2479 expect(variable.name, variableName); |
| 2492 expect(variable.isConst, isFalse); | 2480 expect(variable.isConst, isFalse); |
| 2493 expect(variable.isFinal, isFalse); | 2481 expect(variable.isFinal, isFalse); |
| 2494 expect(variable.isSynthetic, isFalse); | 2482 expect(variable.isSynthetic, isFalse); |
| 2495 expect(variable.getter, isNotNull); | 2483 expect(variable.getter, isNotNull); |
| 2496 expect(variable.setter, isNotNull); | 2484 expect(variable.setter, isNotNull); |
| 2497 } | 2485 } |
| 2498 | 2486 |
| 2499 void test_visitVariableDeclaration_top_const_hasInitializer() { | 2487 void test_visitVariableDeclaration_top() { |
| 2500 // const v = 42; | |
| 2501 ElementHolder holder = new ElementHolder(); | |
| 2502 ElementBuilder builder = _makeBuilder(holder); | |
| 2503 String variableName = "v"; | |
| 2504 VariableDeclaration variableDeclaration = | |
| 2505 AstFactory.variableDeclaration2(variableName, AstFactory.integer(42)); | |
| 2506 AstFactory.variableDeclarationList2(Keyword.CONST, [variableDeclaration]); | |
| 2507 variableDeclaration.accept(builder); | |
| 2508 | |
| 2509 List<TopLevelVariableElement> variables = holder.topLevelVariables; | |
| 2510 expect(variables, hasLength(1)); | |
| 2511 TopLevelVariableElement variable = variables[0]; | |
| 2512 expect(variable, new isInstanceOf<ConstTopLevelVariableElementImpl>()); | |
| 2513 expect(variable.initializer, isNotNull); | |
| 2514 expect(variable.initializer.type, isNotNull); | |
| 2515 expect(variable.initializer.hasImplicitReturnType, isTrue); | |
| 2516 expect(variable.name, variableName); | |
| 2517 expect(variable.hasImplicitType, isTrue); | |
| 2518 expect(variable.isConst, isTrue); | |
| 2519 expect(variable.isFinal, isFalse); | |
| 2520 expect(variable.isSynthetic, isFalse); | |
| 2521 expect(variable.getter, isNotNull); | |
| 2522 expect(variable.setter, isNull); | |
| 2523 } | |
| 2524 | |
| 2525 void test_visitVariableDeclaration_top_docRange() { | |
| 2526 // final a, b; | 2488 // final a, b; |
| 2527 ElementHolder holder = new ElementHolder(); | 2489 ElementHolder holder = new ElementHolder(); |
| 2528 ElementBuilder builder = _makeBuilder(holder); | 2490 ElementBuilder builder = _makeBuilder(holder); |
| 2529 VariableDeclaration variableDeclaration1 = | 2491 VariableDeclaration variableDeclaration1 = |
| 2530 AstFactory.variableDeclaration('a'); | 2492 AstFactory.variableDeclaration('a'); |
| 2531 VariableDeclaration variableDeclaration2 = | 2493 VariableDeclaration variableDeclaration2 = |
| 2532 AstFactory.variableDeclaration('b'); | 2494 AstFactory.variableDeclaration('b'); |
| 2533 TopLevelVariableDeclaration topLevelVariableDeclaration = AstFactory | 2495 TopLevelVariableDeclaration topLevelVariableDeclaration = AstFactory |
| 2534 .topLevelVariableDeclaration( | 2496 .topLevelVariableDeclaration( |
| 2535 Keyword.FINAL, null, [variableDeclaration1, variableDeclaration2]); | 2497 Keyword.FINAL, null, [variableDeclaration1, variableDeclaration2]); |
| 2536 topLevelVariableDeclaration.documentationComment = AstFactory | 2498 topLevelVariableDeclaration.documentationComment = AstFactory |
| 2537 .documentationComment( | 2499 .documentationComment( |
| 2538 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); | 2500 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); |
| 2539 | 2501 |
| 2540 topLevelVariableDeclaration.accept(builder); | 2502 topLevelVariableDeclaration.accept(builder); |
| 2541 List<TopLevelVariableElement> variables = holder.topLevelVariables; | 2503 List<TopLevelVariableElement> variables = holder.topLevelVariables; |
| 2542 expect(variables, hasLength(2)); | 2504 expect(variables, hasLength(2)); |
| 2543 | 2505 |
| 2544 TopLevelVariableElement variable1 = variables[0]; | 2506 TopLevelVariableElement variable1 = variables[0]; |
| 2545 expect(variable1, isNotNull); | 2507 expect(variable1, isNotNull); |
| 2546 expect(variable1.documentationComment, '/// aaa'); | 2508 expect(variable1.documentationComment, '/// aaa'); |
| 2547 _assertHasDocRange(variable1, 50, 7); | |
| 2548 | 2509 |
| 2549 TopLevelVariableElement variable2 = variables[1]; | 2510 TopLevelVariableElement variable2 = variables[1]; |
| 2550 expect(variable2, isNotNull); | 2511 expect(variable2, isNotNull); |
| 2551 expect(variable2.documentationComment, '/// aaa'); | 2512 expect(variable2.documentationComment, '/// aaa'); |
| 2552 _assertHasDocRange(variable2, 50, 7); | 2513 } |
| 2514 |
| 2515 void test_visitVariableDeclaration_top_const_hasInitializer() { |
| 2516 // const v = 42; |
| 2517 ElementHolder holder = new ElementHolder(); |
| 2518 ElementBuilder builder = _makeBuilder(holder); |
| 2519 String variableName = "v"; |
| 2520 VariableDeclaration variableDeclaration = |
| 2521 AstFactory.variableDeclaration2(variableName, AstFactory.integer(42)); |
| 2522 AstFactory.variableDeclarationList2(Keyword.CONST, [variableDeclaration]); |
| 2523 variableDeclaration.accept(builder); |
| 2524 |
| 2525 List<TopLevelVariableElement> variables = holder.topLevelVariables; |
| 2526 expect(variables, hasLength(1)); |
| 2527 TopLevelVariableElement variable = variables[0]; |
| 2528 expect(variable, new isInstanceOf<ConstTopLevelVariableElementImpl>()); |
| 2529 expect(variable.initializer, isNotNull); |
| 2530 expect(variable.initializer.type, isNotNull); |
| 2531 expect(variable.initializer.hasImplicitReturnType, isTrue); |
| 2532 expect(variable.name, variableName); |
| 2533 expect(variable.hasImplicitType, isTrue); |
| 2534 expect(variable.isConst, isTrue); |
| 2535 expect(variable.isFinal, isFalse); |
| 2536 expect(variable.isSynthetic, isFalse); |
| 2537 expect(variable.getter, isNotNull); |
| 2538 expect(variable.setter, isNull); |
| 2553 } | 2539 } |
| 2554 | 2540 |
| 2555 void test_visitVariableDeclaration_top_final() { | 2541 void test_visitVariableDeclaration_top_final() { |
| 2556 // final v; | 2542 // final v; |
| 2557 ElementHolder holder = new ElementHolder(); | 2543 ElementHolder holder = new ElementHolder(); |
| 2558 ElementBuilder builder = _makeBuilder(holder); | 2544 ElementBuilder builder = _makeBuilder(holder); |
| 2559 String variableName = "v"; | 2545 String variableName = "v"; |
| 2560 VariableDeclaration variableDeclaration = | 2546 VariableDeclaration variableDeclaration = |
| 2561 AstFactory.variableDeclaration2(variableName, null); | 2547 AstFactory.variableDeclaration2(variableName, null); |
| 2562 AstFactory.variableDeclarationList2(Keyword.FINAL, [variableDeclaration]); | 2548 AstFactory.variableDeclarationList2(Keyword.FINAL, [variableDeclaration]); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2574 expect(variable.getter, isNotNull); | 2560 expect(variable.getter, isNotNull); |
| 2575 expect(variable.setter, isNull); | 2561 expect(variable.setter, isNull); |
| 2576 } | 2562 } |
| 2577 | 2563 |
| 2578 void _assertHasCodeRange(Element element, int offset, int length) { | 2564 void _assertHasCodeRange(Element element, int offset, int length) { |
| 2579 ElementImpl elementImpl = element; | 2565 ElementImpl elementImpl = element; |
| 2580 expect(elementImpl.codeOffset, offset); | 2566 expect(elementImpl.codeOffset, offset); |
| 2581 expect(elementImpl.codeLength, length); | 2567 expect(elementImpl.codeLength, length); |
| 2582 } | 2568 } |
| 2583 | 2569 |
| 2584 void _assertHasDocRange( | |
| 2585 Element element, int expectedOffset, int expectedLength) { | |
| 2586 // Cast to dynamic here to avoid a hint about @deprecated docRange. | |
| 2587 SourceRange docRange = (element as dynamic).docRange; | |
| 2588 expect(docRange, isNotNull); | |
| 2589 expect(docRange.offset, expectedOffset); | |
| 2590 expect(docRange.length, expectedLength); | |
| 2591 } | |
| 2592 | |
| 2593 void _assertVisibleRange(LocalElement element, int offset, int end) { | 2570 void _assertVisibleRange(LocalElement element, int offset, int end) { |
| 2594 SourceRange visibleRange = element.visibleRange; | 2571 SourceRange visibleRange = element.visibleRange; |
| 2595 expect(visibleRange.offset, offset); | 2572 expect(visibleRange.offset, offset); |
| 2596 expect(visibleRange.end, end); | 2573 expect(visibleRange.end, end); |
| 2597 } | 2574 } |
| 2598 | 2575 |
| 2599 ElementBuilder _makeBuilder(ElementHolder holder) => | 2576 ElementBuilder _makeBuilder(ElementHolder holder) => |
| 2600 new ElementBuilder(holder, new CompilationUnitElementImpl('test.dart')); | 2577 new ElementBuilder(holder, new CompilationUnitElementImpl('test.dart')); |
| 2601 | 2578 |
| 2602 void _setBlockBodySourceRange(BlockFunctionBody body, int offset, int end) { | 2579 void _setBlockBodySourceRange(BlockFunctionBody body, int offset, int end) { |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3129 expect(field.isSynthetic, isTrue); | 3106 expect(field.isSynthetic, isTrue); |
| 3130 expect((field as FieldElementImpl).evaluationResult, isNotNull); | 3107 expect((field as FieldElementImpl).evaluationResult, isNotNull); |
| 3131 _assertGetter(field); | 3108 _assertGetter(field); |
| 3132 | 3109 |
| 3133 FieldElement constant = fields[2]; | 3110 FieldElement constant = fields[2]; |
| 3134 expect(constant, isNotNull); | 3111 expect(constant, isNotNull); |
| 3135 expect(constant.name, firstName); | 3112 expect(constant.name, firstName); |
| 3136 expect(constant.isStatic, isTrue); | 3113 expect(constant.isStatic, isTrue); |
| 3137 expect((constant as FieldElementImpl).evaluationResult, isNotNull); | 3114 expect((constant as FieldElementImpl).evaluationResult, isNotNull); |
| 3138 expect(constant.documentationComment, '/// aaa'); | 3115 expect(constant.documentationComment, '/// aaa'); |
| 3139 expect(constant.docRange.offset, 50); | |
| 3140 expect(constant.docRange.length, 7); | |
| 3141 _assertGetter(constant); | 3116 _assertGetter(constant); |
| 3142 } | 3117 } |
| 3143 | 3118 |
| 3144 void _assertGetter(FieldElement field) { | 3119 void _assertGetter(FieldElement field) { |
| 3145 PropertyAccessorElement getter = field.getter; | 3120 PropertyAccessorElement getter = field.getter; |
| 3146 expect(getter, isNotNull); | 3121 expect(getter, isNotNull); |
| 3147 expect(getter.variable, same(field)); | 3122 expect(getter.variable, same(field)); |
| 3148 expect(getter.type, isNotNull); | 3123 expect(getter.type, isNotNull); |
| 3149 } | 3124 } |
| 3150 | 3125 |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4139 if (1 < 2) { | 4114 if (1 < 2) { |
| 4140 break x; | 4115 break x; |
| 4141 } | 4116 } |
| 4142 return; | 4117 return; |
| 4143 } | 4118 } |
| 4144 } | 4119 } |
| 4145 '''); | 4120 '''); |
| 4146 _assertNthStatementDoesNotExit(source, 0); | 4121 _assertNthStatementDoesNotExit(source, 0); |
| 4147 } | 4122 } |
| 4148 | 4123 |
| 4149 void test_whileStatement_breakWithLabel_afterExting() { | 4124 void test_whileStatement_breakWithLabel_afterExiting() { |
| 4150 Source source = addSource(r''' | 4125 Source source = addSource(r''' |
| 4151 void f() { | 4126 void f() { |
| 4152 x: while (true) { | 4127 x: while (true) { |
| 4153 return; | 4128 return; |
| 4154 if (1 < 2) { | 4129 if (1 < 2) { |
| 4155 break x; | 4130 break x; |
| 4156 } | 4131 } |
| 4157 } | 4132 } |
| 4158 } | 4133 } |
| 4159 '''); | 4134 '''); |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4548 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); | 4523 expect(UriKind.fromEncoding(0x70), same(UriKind.PACKAGE_URI)); |
| 4549 expect(UriKind.fromEncoding(0x58), same(null)); | 4524 expect(UriKind.fromEncoding(0x58), same(null)); |
| 4550 } | 4525 } |
| 4551 | 4526 |
| 4552 void test_getEncoding() { | 4527 void test_getEncoding() { |
| 4553 expect(UriKind.DART_URI.encoding, 0x64); | 4528 expect(UriKind.DART_URI.encoding, 0x64); |
| 4554 expect(UriKind.FILE_URI.encoding, 0x66); | 4529 expect(UriKind.FILE_URI.encoding, 0x66); |
| 4555 expect(UriKind.PACKAGE_URI.encoding, 0x70); | 4530 expect(UriKind.PACKAGE_URI.encoding, 0x70); |
| 4556 } | 4531 } |
| 4557 } | 4532 } |
| OLD | NEW |