Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 2270903002: Remove 'Element.docRange'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/pubspec.yaml ('k') | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 700 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 expect(types, hasLength(1)); 711 expect(types, hasLength(1));
712 ClassElement type = types[0]; 712 ClassElement type = types[0];
713 expect(type, isNotNull); 713 expect(type, isNotNull);
714 expect(type.name, className); 714 expect(type.name, className);
715 List<TypeParameterElement> typeParameters = type.typeParameters; 715 List<TypeParameterElement> typeParameters = type.typeParameters;
716 expect(typeParameters, hasLength(0)); 716 expect(typeParameters, hasLength(0));
717 expect(type.isAbstract, isFalse); 717 expect(type.isAbstract, isFalse);
718 expect(type.isMixinApplication, isFalse); 718 expect(type.isMixinApplication, isFalse);
719 expect(type.isSynthetic, isFalse); 719 expect(type.isSynthetic, isFalse);
720 expect(type.documentationComment, '/// aaa'); 720 expect(type.documentationComment, '/// aaa');
721 _assertHasDocRange(type, 50, 7);
722 _assertHasCodeRange(type, 50, 31); 721 _assertHasCodeRange(type, 50, 31);
723 } 722 }
724 723
725 void test_visitClassDeclaration_parameterized() { 724 void test_visitClassDeclaration_parameterized() {
726 ElementHolder holder = new ElementHolder(); 725 ElementHolder holder = new ElementHolder();
727 ElementBuilder builder = _makeBuilder(holder); 726 ElementBuilder builder = _makeBuilder(holder);
728 String className = "C"; 727 String className = "C";
729 String firstVariableName = "E"; 728 String firstVariableName = "E";
730 String secondVariableName = "F"; 729 String secondVariableName = "F";
731 ClassDeclaration classDeclaration = AstFactory.classDeclaration( 730 ClassDeclaration classDeclaration = AstFactory.classDeclaration(
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); 977 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
979 constructorDeclaration.endToken.offset = 80; 978 constructorDeclaration.endToken.offset = 80;
980 constructorDeclaration.accept(builder); 979 constructorDeclaration.accept(builder);
981 980
982 List<ConstructorElement> constructors = holder.constructors; 981 List<ConstructorElement> constructors = holder.constructors;
983 expect(constructors, hasLength(1)); 982 expect(constructors, hasLength(1));
984 ConstructorElement constructor = constructors[0]; 983 ConstructorElement constructor = constructors[0];
985 expect(constructor, isNotNull); 984 expect(constructor, isNotNull);
986 _assertHasCodeRange(constructor, 50, 31); 985 _assertHasCodeRange(constructor, 50, 31);
987 expect(constructor.documentationComment, '/// aaa'); 986 expect(constructor.documentationComment, '/// aaa');
988 _assertHasDocRange(constructor, 50, 7);
989 expect(constructor.isExternal, isFalse); 987 expect(constructor.isExternal, isFalse);
990 expect(constructor.isFactory, isFalse); 988 expect(constructor.isFactory, isFalse);
991 expect(constructor.name, ""); 989 expect(constructor.name, "");
992 expect(constructor.functions, hasLength(0)); 990 expect(constructor.functions, hasLength(0));
993 expect(constructor.labels, hasLength(0)); 991 expect(constructor.labels, hasLength(0));
994 expect(constructor.localVariables, hasLength(0)); 992 expect(constructor.localVariables, hasLength(0));
995 expect(constructor.parameters, hasLength(0)); 993 expect(constructor.parameters, hasLength(0));
996 } 994 }
997 995
998 void test_visitConstructorDeclaration_named() { 996 void test_visitConstructorDeclaration_named() {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 enumDeclaration.documentationComment = AstFactory.documentationComment( 1179 enumDeclaration.documentationComment = AstFactory.documentationComment(
1182 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); 1180 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
1183 enumDeclaration.endToken.offset = 80; 1181 enumDeclaration.endToken.offset = 80;
1184 enumDeclaration.accept(builder); 1182 enumDeclaration.accept(builder);
1185 List<ClassElement> enums = holder.enums; 1183 List<ClassElement> enums = holder.enums;
1186 expect(enums, hasLength(1)); 1184 expect(enums, hasLength(1));
1187 ClassElement enumElement = enums[0]; 1185 ClassElement enumElement = enums[0];
1188 expect(enumElement, isNotNull); 1186 expect(enumElement, isNotNull);
1189 _assertHasCodeRange(enumElement, 50, 31); 1187 _assertHasCodeRange(enumElement, 50, 31);
1190 expect(enumElement.documentationComment, '/// aaa'); 1188 expect(enumElement.documentationComment, '/// aaa');
1191 _assertHasDocRange(enumElement, 50, 7);
1192 expect(enumElement.name, enumName); 1189 expect(enumElement.name, enumName);
1193 } 1190 }
1194 1191
1195 void test_visitFieldDeclaration() { 1192 void test_visitFieldDeclaration() {
1196 ElementHolder holder = new ElementHolder(); 1193 ElementHolder holder = new ElementHolder();
1197 ElementBuilder builder = _makeBuilder(holder); 1194 ElementBuilder builder = _makeBuilder(holder);
1198 String firstFieldName = "x"; 1195 String firstFieldName = "x";
1199 String secondFieldName = "y"; 1196 String secondFieldName = "y";
1200 FieldDeclaration fieldDeclaration = 1197 FieldDeclaration fieldDeclaration =
1201 AstFactory.fieldDeclaration2(false, null, [ 1198 AstFactory.fieldDeclaration2(false, null, [
1202 AstFactory.variableDeclaration(firstFieldName), 1199 AstFactory.variableDeclaration(firstFieldName),
1203 AstFactory.variableDeclaration(secondFieldName) 1200 AstFactory.variableDeclaration(secondFieldName)
1204 ]); 1201 ]);
1205 fieldDeclaration.documentationComment = AstFactory.documentationComment( 1202 fieldDeclaration.documentationComment = AstFactory.documentationComment(
1206 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); 1203 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
1207 fieldDeclaration.endToken.offset = 110; 1204 fieldDeclaration.endToken.offset = 110;
1208 fieldDeclaration.accept(builder); 1205 fieldDeclaration.accept(builder);
1209 1206
1210 List<FieldElement> fields = holder.fields; 1207 List<FieldElement> fields = holder.fields;
1211 expect(fields, hasLength(2)); 1208 expect(fields, hasLength(2));
1212 1209
1213 FieldElement firstField = fields[0]; 1210 FieldElement firstField = fields[0];
1214 expect(firstField, isNotNull); 1211 expect(firstField, isNotNull);
1215 _assertHasCodeRange(firstField, 50, 61); 1212 _assertHasCodeRange(firstField, 50, 61);
1216 expect(firstField.documentationComment, '/// aaa'); 1213 expect(firstField.documentationComment, '/// aaa');
1217 _assertHasDocRange(firstField, 50, 7);
1218 expect(firstField.name, firstFieldName); 1214 expect(firstField.name, firstFieldName);
1219 expect(firstField.initializer, isNull); 1215 expect(firstField.initializer, isNull);
1220 expect(firstField.isConst, isFalse); 1216 expect(firstField.isConst, isFalse);
1221 expect(firstField.isFinal, isFalse); 1217 expect(firstField.isFinal, isFalse);
1222 expect(firstField.isSynthetic, isFalse); 1218 expect(firstField.isSynthetic, isFalse);
1223 1219
1224 FieldElement secondField = fields[1]; 1220 FieldElement secondField = fields[1];
1225 expect(secondField, isNotNull); 1221 expect(secondField, isNotNull);
1226 _assertHasCodeRange(secondField, 50, 61); 1222 _assertHasCodeRange(secondField, 50, 61);
1227 expect(secondField.documentationComment, '/// aaa'); 1223 expect(secondField.documentationComment, '/// aaa');
1228 _assertHasDocRange(secondField, 50, 7);
1229 expect(secondField.name, secondFieldName); 1224 expect(secondField.name, secondFieldName);
1230 expect(secondField.initializer, isNull); 1225 expect(secondField.initializer, isNull);
1231 expect(secondField.isConst, isFalse); 1226 expect(secondField.isConst, isFalse);
1232 expect(secondField.isFinal, isFalse); 1227 expect(secondField.isFinal, isFalse);
1233 expect(secondField.isSynthetic, isFalse); 1228 expect(secondField.isSynthetic, isFalse);
1234 } 1229 }
1235 1230
1236 void test_visitFieldFormalParameter() { 1231 void test_visitFieldFormalParameter() {
1237 ElementHolder holder = new ElementHolder(); 1232 ElementHolder holder = new ElementHolder();
1238 ElementBuilder builder = _makeBuilder(holder); 1233 ElementBuilder builder = _makeBuilder(holder);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); 1334 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
1340 declaration.endToken.offset = 80; 1335 declaration.endToken.offset = 80;
1341 declaration.accept(builder); 1336 declaration.accept(builder);
1342 1337
1343 List<PropertyAccessorElement> accessors = holder.accessors; 1338 List<PropertyAccessorElement> accessors = holder.accessors;
1344 expect(accessors, hasLength(1)); 1339 expect(accessors, hasLength(1));
1345 PropertyAccessorElement accessor = accessors[0]; 1340 PropertyAccessorElement accessor = accessors[0];
1346 expect(accessor, isNotNull); 1341 expect(accessor, isNotNull);
1347 _assertHasCodeRange(accessor, 50, 31); 1342 _assertHasCodeRange(accessor, 50, 31);
1348 expect(accessor.documentationComment, '/// aaa'); 1343 expect(accessor.documentationComment, '/// aaa');
1349 _assertHasDocRange(accessor, 50, 7);
1350 expect(accessor.name, functionName); 1344 expect(accessor.name, functionName);
1351 expect(declaration.element, same(accessor)); 1345 expect(declaration.element, same(accessor));
1352 expect(declaration.functionExpression.element, same(accessor)); 1346 expect(declaration.functionExpression.element, same(accessor));
1353 expect(accessor.hasImplicitReturnType, isTrue); 1347 expect(accessor.hasImplicitReturnType, isTrue);
1354 expect(accessor.isGetter, isTrue); 1348 expect(accessor.isGetter, isTrue);
1355 expect(accessor.isExternal, isFalse); 1349 expect(accessor.isExternal, isFalse);
1356 expect(accessor.isSetter, isFalse); 1350 expect(accessor.isSetter, isFalse);
1357 expect(accessor.isSynthetic, isFalse); 1351 expect(accessor.isSynthetic, isFalse);
1358 expect(accessor.typeParameters, hasLength(0)); 1352 expect(accessor.typeParameters, hasLength(0));
1359 PropertyInducingElement variable = accessor.variable; 1353 PropertyInducingElement variable = accessor.variable;
(...skipping 17 matching lines...) Expand all
1377 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); 1371 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
1378 declaration.endToken.offset = 80; 1372 declaration.endToken.offset = 80;
1379 declaration.accept(builder); 1373 declaration.accept(builder);
1380 1374
1381 List<FunctionElement> functions = holder.functions; 1375 List<FunctionElement> functions = holder.functions;
1382 expect(functions, hasLength(1)); 1376 expect(functions, hasLength(1));
1383 FunctionElement function = functions[0]; 1377 FunctionElement function = functions[0];
1384 expect(function, isNotNull); 1378 expect(function, isNotNull);
1385 _assertHasCodeRange(function, 50, 31); 1379 _assertHasCodeRange(function, 50, 31);
1386 expect(function.documentationComment, '/// aaa'); 1380 expect(function.documentationComment, '/// aaa');
1387 _assertHasDocRange(function, 50, 7);
1388 expect(function.hasImplicitReturnType, isFalse); 1381 expect(function.hasImplicitReturnType, isFalse);
1389 expect(function.name, functionName); 1382 expect(function.name, functionName);
1390 expect(declaration.element, same(function)); 1383 expect(declaration.element, same(function));
1391 expect(declaration.functionExpression.element, same(function)); 1384 expect(declaration.functionExpression.element, same(function));
1392 expect(function.isExternal, isFalse); 1385 expect(function.isExternal, isFalse);
1393 expect(function.isSynthetic, isFalse); 1386 expect(function.isSynthetic, isFalse);
1394 expect(function.typeParameters, hasLength(0)); 1387 expect(function.typeParameters, hasLength(0));
1395 } 1388 }
1396 1389
1397 void test_visitFunctionDeclaration_setter() { 1390 void test_visitFunctionDeclaration_setter() {
(...skipping 11 matching lines...) Expand all
1409 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); 1402 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
1410 declaration.endToken.offset = 80; 1403 declaration.endToken.offset = 80;
1411 declaration.accept(builder); 1404 declaration.accept(builder);
1412 1405
1413 List<PropertyAccessorElement> accessors = holder.accessors; 1406 List<PropertyAccessorElement> accessors = holder.accessors;
1414 expect(accessors, hasLength(1)); 1407 expect(accessors, hasLength(1));
1415 PropertyAccessorElement accessor = accessors[0]; 1408 PropertyAccessorElement accessor = accessors[0];
1416 expect(accessor, isNotNull); 1409 expect(accessor, isNotNull);
1417 _assertHasCodeRange(accessor, 50, 31); 1410 _assertHasCodeRange(accessor, 50, 31);
1418 expect(accessor.documentationComment, '/// aaa'); 1411 expect(accessor.documentationComment, '/// aaa');
1419 _assertHasDocRange(accessor, 50, 7);
1420 expect(accessor.hasImplicitReturnType, isTrue); 1412 expect(accessor.hasImplicitReturnType, isTrue);
1421 expect(accessor.name, "$functionName="); 1413 expect(accessor.name, "$functionName=");
1422 expect(declaration.element, same(accessor)); 1414 expect(declaration.element, same(accessor));
1423 expect(declaration.functionExpression.element, same(accessor)); 1415 expect(declaration.functionExpression.element, same(accessor));
1424 expect(accessor.isGetter, isFalse); 1416 expect(accessor.isGetter, isFalse);
1425 expect(accessor.isExternal, isFalse); 1417 expect(accessor.isExternal, isFalse);
1426 expect(accessor.isSetter, isTrue); 1418 expect(accessor.isSetter, isTrue);
1427 expect(accessor.isSynthetic, isFalse); 1419 expect(accessor.isSynthetic, isFalse);
1428 expect(accessor.typeParameters, hasLength(0)); 1420 expect(accessor.typeParameters, hasLength(0));
1429 PropertyInducingElement variable = accessor.variable; 1421 PropertyInducingElement variable = accessor.variable;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); 1482 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
1491 aliasNode.endToken.offset = 80; 1483 aliasNode.endToken.offset = 80;
1492 aliasNode.accept(builder); 1484 aliasNode.accept(builder);
1493 1485
1494 List<FunctionTypeAliasElement> aliases = holder.typeAliases; 1486 List<FunctionTypeAliasElement> aliases = holder.typeAliases;
1495 expect(aliases, hasLength(1)); 1487 expect(aliases, hasLength(1));
1496 FunctionTypeAliasElement alias = aliases[0]; 1488 FunctionTypeAliasElement alias = aliases[0];
1497 expect(alias, isNotNull); 1489 expect(alias, isNotNull);
1498 _assertHasCodeRange(alias, 50, 31); 1490 _assertHasCodeRange(alias, 50, 31);
1499 expect(alias.documentationComment, '/// aaa'); 1491 expect(alias.documentationComment, '/// aaa');
1500 _assertHasDocRange(alias, 50, 7);
1501 expect(alias.name, aliasName); 1492 expect(alias.name, aliasName);
1502 expect(alias.parameters, hasLength(0)); 1493 expect(alias.parameters, hasLength(0));
1503 List<TypeParameterElement> typeParameters = alias.typeParameters; 1494 List<TypeParameterElement> typeParameters = alias.typeParameters;
1504 expect(typeParameters, hasLength(1)); 1495 expect(typeParameters, hasLength(1));
1505 TypeParameterElement typeParameter = typeParameters[0]; 1496 TypeParameterElement typeParameter = typeParameters[0];
1506 expect(typeParameter, isNotNull); 1497 expect(typeParameter, isNotNull);
1507 expect(typeParameter.name, parameterName); 1498 expect(typeParameter.name, parameterName);
1508 } 1499 }
1509 1500
1510 void test_visitFunctionTypedFormalParameter() { 1501 void test_visitFunctionTypedFormalParameter() {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1691 expect(fields, hasLength(1)); 1682 expect(fields, hasLength(1));
1692 FieldElement field = fields[0]; 1683 FieldElement field = fields[0];
1693 expect(field, isNotNull); 1684 expect(field, isNotNull);
1694 expect(field.name, methodName); 1685 expect(field.name, methodName);
1695 expect(field.isSynthetic, isTrue); 1686 expect(field.isSynthetic, isTrue);
1696 expect(field.setter, isNull); 1687 expect(field.setter, isNull);
1697 PropertyAccessorElement getter = field.getter; 1688 PropertyAccessorElement getter = field.getter;
1698 expect(getter, isNotNull); 1689 expect(getter, isNotNull);
1699 _assertHasCodeRange(getter, 50, 31); 1690 _assertHasCodeRange(getter, 50, 31);
1700 expect(getter.documentationComment, '/// aaa'); 1691 expect(getter.documentationComment, '/// aaa');
1701 _assertHasDocRange(getter, 50, 7);
1702 expect(getter.hasImplicitReturnType, isTrue); 1692 expect(getter.hasImplicitReturnType, isTrue);
1703 expect(getter.isAbstract, isFalse); 1693 expect(getter.isAbstract, isFalse);
1704 expect(getter.isExternal, isFalse); 1694 expect(getter.isExternal, isFalse);
1705 expect(getter.isGetter, isTrue); 1695 expect(getter.isGetter, isTrue);
1706 expect(getter.isSynthetic, isFalse); 1696 expect(getter.isSynthetic, isFalse);
1707 expect(getter.name, methodName); 1697 expect(getter.name, methodName);
1708 expect(getter.variable, field); 1698 expect(getter.variable, field);
1709 expect(getter.functions, hasLength(0)); 1699 expect(getter.functions, hasLength(0));
1710 expect(getter.labels, hasLength(0)); 1700 expect(getter.labels, hasLength(0));
1711 expect(getter.localVariables, hasLength(0)); 1701 expect(getter.localVariables, hasLength(0));
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); 1794 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
1805 methodDeclaration.endToken.offset = 80; 1795 methodDeclaration.endToken.offset = 80;
1806 methodDeclaration.accept(builder); 1796 methodDeclaration.accept(builder);
1807 1797
1808 List<MethodElement> methods = holder.methods; 1798 List<MethodElement> methods = holder.methods;
1809 expect(methods, hasLength(1)); 1799 expect(methods, hasLength(1));
1810 MethodElement method = methods[0]; 1800 MethodElement method = methods[0];
1811 expect(method, isNotNull); 1801 expect(method, isNotNull);
1812 _assertHasCodeRange(method, 50, 31); 1802 _assertHasCodeRange(method, 50, 31);
1813 expect(method.documentationComment, '/// aaa'); 1803 expect(method.documentationComment, '/// aaa');
1814 _assertHasDocRange(method, 50, 7);
1815 expect(method.hasImplicitReturnType, isFalse); 1804 expect(method.hasImplicitReturnType, isFalse);
1816 expect(method.name, methodName); 1805 expect(method.name, methodName);
1817 expect(method.functions, hasLength(0)); 1806 expect(method.functions, hasLength(0));
1818 expect(method.labels, hasLength(0)); 1807 expect(method.labels, hasLength(0));
1819 expect(method.localVariables, hasLength(0)); 1808 expect(method.localVariables, hasLength(0));
1820 expect(method.parameters, hasLength(0)); 1809 expect(method.parameters, hasLength(0));
1821 expect(method.typeParameters, hasLength(0)); 1810 expect(method.typeParameters, hasLength(0));
1822 expect(method.isAbstract, isFalse); 1811 expect(method.isAbstract, isFalse);
1823 expect(method.isExternal, isFalse); 1812 expect(method.isExternal, isFalse);
1824 expect(method.isStatic, isFalse); 1813 expect(method.isStatic, isFalse);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 FieldElement field = fields[0]; 1870 FieldElement field = fields[0];
1882 expect(field, isNotNull); 1871 expect(field, isNotNull);
1883 expect(field.name, methodName); 1872 expect(field.name, methodName);
1884 expect(field.isSynthetic, isTrue); 1873 expect(field.isSynthetic, isTrue);
1885 expect(field.getter, isNull); 1874 expect(field.getter, isNull);
1886 1875
1887 PropertyAccessorElement setter = field.setter; 1876 PropertyAccessorElement setter = field.setter;
1888 expect(setter, isNotNull); 1877 expect(setter, isNotNull);
1889 _assertHasCodeRange(setter, 50, 31); 1878 _assertHasCodeRange(setter, 50, 31);
1890 expect(setter.documentationComment, '/// aaa'); 1879 expect(setter.documentationComment, '/// aaa');
1891 _assertHasDocRange(setter, 50, 7);
1892 expect(setter.hasImplicitReturnType, isTrue); 1880 expect(setter.hasImplicitReturnType, isTrue);
1893 expect(setter.isAbstract, isFalse); 1881 expect(setter.isAbstract, isFalse);
1894 expect(setter.isExternal, isFalse); 1882 expect(setter.isExternal, isFalse);
1895 expect(setter.isSetter, isTrue); 1883 expect(setter.isSetter, isTrue);
1896 expect(setter.isSynthetic, isFalse); 1884 expect(setter.isSynthetic, isFalse);
1897 expect(setter.name, "$methodName="); 1885 expect(setter.name, "$methodName=");
1898 expect(setter.displayName, methodName); 1886 expect(setter.displayName, methodName);
1899 expect(setter.variable, field); 1887 expect(setter.variable, field);
1900 expect(setter.functions, hasLength(0)); 1888 expect(setter.functions, hasLength(0));
1901 expect(setter.labels, hasLength(0)); 1889 expect(setter.labels, hasLength(0));
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 expect(variable.hasImplicitType, isTrue); 2458 expect(variable.hasImplicitType, isTrue);
2471 expect(variable.initializer, isNull); 2459 expect(variable.initializer, isNull);
2472 expect(variable.name, variableName); 2460 expect(variable.name, variableName);
2473 expect(variable.isConst, isFalse); 2461 expect(variable.isConst, isFalse);
2474 expect(variable.isFinal, isFalse); 2462 expect(variable.isFinal, isFalse);
2475 expect(variable.isSynthetic, isFalse); 2463 expect(variable.isSynthetic, isFalse);
2476 expect(variable.getter, isNotNull); 2464 expect(variable.getter, isNotNull);
2477 expect(variable.setter, isNotNull); 2465 expect(variable.setter, isNotNull);
2478 } 2466 }
2479 2467
2480 void test_visitVariableDeclaration_top_const_hasInitializer() { 2468 void test_visitVariableDeclaration_top() {
2481 // const v = 42;
2482 ElementHolder holder = new ElementHolder();
2483 ElementBuilder builder = _makeBuilder(holder);
2484 String variableName = "v";
2485 VariableDeclaration variableDeclaration =
2486 AstFactory.variableDeclaration2(variableName, AstFactory.integer(42));
2487 AstFactory.variableDeclarationList2(Keyword.CONST, [variableDeclaration]);
2488 variableDeclaration.accept(builder);
2489
2490 List<TopLevelVariableElement> variables = holder.topLevelVariables;
2491 expect(variables, hasLength(1));
2492 TopLevelVariableElement variable = variables[0];
2493 expect(variable, new isInstanceOf<ConstTopLevelVariableElementImpl>());
2494 expect(variable.initializer, isNotNull);
2495 expect(variable.initializer.type, isNotNull);
2496 expect(variable.initializer.hasImplicitReturnType, isTrue);
2497 expect(variable.name, variableName);
2498 expect(variable.hasImplicitType, isTrue);
2499 expect(variable.isConst, isTrue);
2500 expect(variable.isFinal, isFalse);
2501 expect(variable.isSynthetic, isFalse);
2502 expect(variable.getter, isNotNull);
2503 expect(variable.setter, isNull);
2504 }
2505
2506 void test_visitVariableDeclaration_top_docRange() {
2507 // final a, b; 2469 // final a, b;
2508 ElementHolder holder = new ElementHolder(); 2470 ElementHolder holder = new ElementHolder();
2509 ElementBuilder builder = _makeBuilder(holder); 2471 ElementBuilder builder = _makeBuilder(holder);
2510 VariableDeclaration variableDeclaration1 = 2472 VariableDeclaration variableDeclaration1 =
2511 AstFactory.variableDeclaration('a'); 2473 AstFactory.variableDeclaration('a');
2512 VariableDeclaration variableDeclaration2 = 2474 VariableDeclaration variableDeclaration2 =
2513 AstFactory.variableDeclaration('b'); 2475 AstFactory.variableDeclaration('b');
2514 TopLevelVariableDeclaration topLevelVariableDeclaration = AstFactory 2476 TopLevelVariableDeclaration topLevelVariableDeclaration = AstFactory
2515 .topLevelVariableDeclaration( 2477 .topLevelVariableDeclaration(
2516 Keyword.FINAL, null, [variableDeclaration1, variableDeclaration2]); 2478 Keyword.FINAL, null, [variableDeclaration1, variableDeclaration2]);
2517 topLevelVariableDeclaration.documentationComment = AstFactory 2479 topLevelVariableDeclaration.documentationComment = AstFactory
2518 .documentationComment( 2480 .documentationComment(
2519 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []); 2481 [TokenFactory.tokenFromString('/// aaa')..offset = 50], []);
2520 2482
2521 topLevelVariableDeclaration.accept(builder); 2483 topLevelVariableDeclaration.accept(builder);
2522 List<TopLevelVariableElement> variables = holder.topLevelVariables; 2484 List<TopLevelVariableElement> variables = holder.topLevelVariables;
2523 expect(variables, hasLength(2)); 2485 expect(variables, hasLength(2));
2524 2486
2525 TopLevelVariableElement variable1 = variables[0]; 2487 TopLevelVariableElement variable1 = variables[0];
2526 expect(variable1, isNotNull); 2488 expect(variable1, isNotNull);
2527 expect(variable1.documentationComment, '/// aaa'); 2489 expect(variable1.documentationComment, '/// aaa');
2528 _assertHasDocRange(variable1, 50, 7);
2529 2490
2530 TopLevelVariableElement variable2 = variables[1]; 2491 TopLevelVariableElement variable2 = variables[1];
2531 expect(variable2, isNotNull); 2492 expect(variable2, isNotNull);
2532 expect(variable2.documentationComment, '/// aaa'); 2493 expect(variable2.documentationComment, '/// aaa');
2533 _assertHasDocRange(variable2, 50, 7); 2494 }
2495
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);
2534 } 2520 }
2535 2521
2536 void test_visitVariableDeclaration_top_final() { 2522 void test_visitVariableDeclaration_top_final() {
2537 // final v; 2523 // final v;
2538 ElementHolder holder = new ElementHolder(); 2524 ElementHolder holder = new ElementHolder();
2539 ElementBuilder builder = _makeBuilder(holder); 2525 ElementBuilder builder = _makeBuilder(holder);
2540 String variableName = "v"; 2526 String variableName = "v";
2541 VariableDeclaration variableDeclaration = 2527 VariableDeclaration variableDeclaration =
2542 AstFactory.variableDeclaration2(variableName, null); 2528 AstFactory.variableDeclaration2(variableName, null);
2543 AstFactory.variableDeclarationList2(Keyword.FINAL, [variableDeclaration]); 2529 AstFactory.variableDeclarationList2(Keyword.FINAL, [variableDeclaration]);
(...skipping 11 matching lines...) Expand all
2555 expect(variable.getter, isNotNull); 2541 expect(variable.getter, isNotNull);
2556 expect(variable.setter, isNull); 2542 expect(variable.setter, isNull);
2557 } 2543 }
2558 2544
2559 void _assertHasCodeRange(Element element, int offset, int length) { 2545 void _assertHasCodeRange(Element element, int offset, int length) {
2560 ElementImpl elementImpl = element; 2546 ElementImpl elementImpl = element;
2561 expect(elementImpl.codeOffset, offset); 2547 expect(elementImpl.codeOffset, offset);
2562 expect(elementImpl.codeLength, length); 2548 expect(elementImpl.codeLength, length);
2563 } 2549 }
2564 2550
2565 void _assertHasDocRange(
2566 Element element, int expectedOffset, int expectedLength) {
2567 // Cast to dynamic here to avoid a hint about @deprecated docRange.
2568 SourceRange docRange = (element as dynamic).docRange;
2569 expect(docRange, isNotNull);
2570 expect(docRange.offset, expectedOffset);
2571 expect(docRange.length, expectedLength);
2572 }
2573
2574 void _assertVisibleRange(LocalElement element, int offset, int end) { 2551 void _assertVisibleRange(LocalElement element, int offset, int end) {
2575 SourceRange visibleRange = element.visibleRange; 2552 SourceRange visibleRange = element.visibleRange;
2576 expect(visibleRange.offset, offset); 2553 expect(visibleRange.offset, offset);
2577 expect(visibleRange.end, end); 2554 expect(visibleRange.end, end);
2578 } 2555 }
2579 2556
2580 ElementBuilder _makeBuilder(ElementHolder holder) => 2557 ElementBuilder _makeBuilder(ElementHolder holder) =>
2581 new ElementBuilder(holder, new CompilationUnitElementImpl('test.dart')); 2558 new ElementBuilder(holder, new CompilationUnitElementImpl('test.dart'));
2582 2559
2583 void _setBlockBodySourceRange(BlockFunctionBody body, int offset, int end) { 2560 void _setBlockBodySourceRange(BlockFunctionBody body, int offset, int end) {
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
3117 expect(field.isSynthetic, isTrue); 3094 expect(field.isSynthetic, isTrue);
3118 expect((field as FieldElementImpl).evaluationResult, isNotNull); 3095 expect((field as FieldElementImpl).evaluationResult, isNotNull);
3119 _assertGetter(field); 3096 _assertGetter(field);
3120 3097
3121 FieldElement constant = fields[2]; 3098 FieldElement constant = fields[2];
3122 expect(constant, isNotNull); 3099 expect(constant, isNotNull);
3123 expect(constant.name, firstName); 3100 expect(constant.name, firstName);
3124 expect(constant.isStatic, isTrue); 3101 expect(constant.isStatic, isTrue);
3125 expect((constant as FieldElementImpl).evaluationResult, isNotNull); 3102 expect((constant as FieldElementImpl).evaluationResult, isNotNull);
3126 expect(constant.documentationComment, '/// aaa'); 3103 expect(constant.documentationComment, '/// aaa');
3127 expect(constant.docRange.offset, 50);
3128 expect(constant.docRange.length, 7);
3129 _assertGetter(constant); 3104 _assertGetter(constant);
3130 } 3105 }
3131 3106
3132 void _assertGetter(FieldElement field) { 3107 void _assertGetter(FieldElement field) {
3133 PropertyAccessorElement getter = field.getter; 3108 PropertyAccessorElement getter = field.getter;
3134 expect(getter, isNotNull); 3109 expect(getter, isNotNull);
3135 expect(getter.variable, same(field)); 3110 expect(getter.variable, same(field));
3136 expect(getter.type, isNotNull); 3111 expect(getter.type, isNotNull);
3137 } 3112 }
3138 3113
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
4127 if (1 < 2) { 4102 if (1 < 2) {
4128 break x; 4103 break x;
4129 } 4104 }
4130 return; 4105 return;
4131 } 4106 }
4132 } 4107 }
4133 '''); 4108 ''');
4134 _assertNthStatementDoesNotExit(source, 0); 4109 _assertNthStatementDoesNotExit(source, 0);
4135 } 4110 }
4136 4111
4137 void test_whileStatement_breakWithLabel_afterExting() { 4112 void test_whileStatement_breakWithLabel_afterExiting() {
4138 Source source = addSource(r''' 4113 Source source = addSource(r'''
4139 void f() { 4114 void f() {
4140 x: while (true) { 4115 x: while (true) {
4141 return; 4116 return;
4142 if (1 < 2) { 4117 if (1 < 2) {
4143 break x; 4118 break x;
4144 } 4119 }
4145 } 4120 }
4146 } 4121 }
4147 '''); 4122 ''');
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « pkg/analyzer/pubspec.yaml ('k') | pkg/analyzer/test/src/summary/resynthesize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698