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