| 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 import 'package:analyzer/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
| 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
| 7 import 'package:analyzer/dart/ast/token.dart'; | 7 import 'package:analyzer/dart/ast/token.dart'; |
| 8 import 'package:analyzer/dart/ast/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
| 9 import 'package:analyzer/error/error.dart'; | 9 import 'package:analyzer/error/error.dart'; |
| 10 import 'package:analyzer/error/listener.dart'; | 10 import 'package:analyzer/error/listener.dart'; |
| 11 import 'package:analyzer/src/dart/ast/token.dart'; | 11 import 'package:analyzer/src/dart/ast/token.dart'; |
| 12 import 'package:analyzer/src/dart/error/hint_codes.dart'; |
| 12 import 'package:analyzer/src/dart/scanner/reader.dart'; | 13 import 'package:analyzer/src/dart/scanner/reader.dart'; |
| 13 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 14 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 14 import 'package:analyzer/src/generated/parser.dart'; | 15 import 'package:analyzer/src/generated/parser.dart'; |
| 15 import 'package:analyzer/src/generated/source.dart'; | 16 import 'package:analyzer/src/generated/source.dart'; |
| 16 import 'package:analyzer/src/generated/testing/token_factory.dart'; | 17 import 'package:analyzer/src/generated/testing/token_factory.dart'; |
| 17 import 'package:analyzer/src/generated/utilities_dart.dart'; | 18 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 18 import 'package:front_end/src/scanner/scanner.dart' as fe; | 19 import 'package:front_end/src/scanner/scanner.dart' as fe; |
| 19 import 'package:test/test.dart'; | 20 import 'package:test/test.dart'; |
| 20 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 21 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 21 | 22 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 MapLiteral parseMapLiteral( | 172 MapLiteral parseMapLiteral( |
| 172 Token token, String typeArgumentsCode, String code); | 173 Token token, String typeArgumentsCode, String code); |
| 173 | 174 |
| 174 MapLiteralEntry parseMapLiteralEntry(String code); | 175 MapLiteralEntry parseMapLiteralEntry(String code); |
| 175 | 176 |
| 176 Expression parseMultiplicativeExpression(String code); | 177 Expression parseMultiplicativeExpression(String code); |
| 177 | 178 |
| 178 InstanceCreationExpression parseNewExpression(String code); | 179 InstanceCreationExpression parseNewExpression(String code); |
| 179 | 180 |
| 180 NormalFormalParameter parseNormalFormalParameter(String code, | 181 NormalFormalParameter parseNormalFormalParameter(String code, |
| 181 {bool inFunctionType: false}); | 182 {bool inFunctionType: false, |
| 183 List<ErrorCode> errorCodes: const <ErrorCode>[]}); |
| 182 | 184 |
| 183 Expression parsePostfixExpression(String code); | 185 Expression parsePostfixExpression(String code); |
| 184 | 186 |
| 185 Identifier parsePrefixedIdentifier(String code); | 187 Identifier parsePrefixedIdentifier(String code); |
| 186 | 188 |
| 187 Expression parsePrimaryExpression(String code); | 189 Expression parsePrimaryExpression(String code); |
| 188 | 190 |
| 189 Expression parseRelationalExpression(String code); | 191 Expression parseRelationalExpression(String code); |
| 190 | 192 |
| 191 RethrowExpression parseRethrowExpression(String code); | 193 RethrowExpression parseRethrowExpression(String code); |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 expect(method.parameters, isNotNull); | 617 expect(method.parameters, isNotNull); |
| 616 expect(method.propertyKeyword, isNull); | 618 expect(method.propertyKeyword, isNull); |
| 617 expect(method.returnType, isNotNull); | 619 expect(method.returnType, isNotNull); |
| 618 } | 620 } |
| 619 | 621 |
| 620 void test_parseClassMember_method_generic_comment_noReturnType() { | 622 void test_parseClassMember_method_generic_comment_noReturnType() { |
| 621 enableGenericMethodComments = true; | 623 enableGenericMethodComments = true; |
| 622 createParser('m/*<T>*/() {}'); | 624 createParser('m/*<T>*/() {}'); |
| 623 ClassMember member = parser.parseClassMember('C'); | 625 ClassMember member = parser.parseClassMember('C'); |
| 624 expect(member, isNotNull); | 626 expect(member, isNotNull); |
| 625 assertNoErrors(); | 627 if (usingFastaParser) { |
| 628 assertNoErrors(); |
| 629 } else { |
| 630 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 631 } |
| 626 expect(member, new isInstanceOf<MethodDeclaration>()); | 632 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 627 MethodDeclaration method = member; | 633 MethodDeclaration method = member; |
| 628 expect(method.documentationComment, isNull); | 634 expect(method.documentationComment, isNull); |
| 629 expect(method.externalKeyword, isNull); | 635 expect(method.externalKeyword, isNull); |
| 630 expect(method.modifierKeyword, isNull); | 636 expect(method.modifierKeyword, isNull); |
| 631 expect(method.propertyKeyword, isNull); | 637 expect(method.propertyKeyword, isNull); |
| 632 expect(method.returnType, isNull); | 638 expect(method.returnType, isNull); |
| 633 expect(method.name, isNotNull); | 639 expect(method.name, isNotNull); |
| 634 expect(method.operatorKeyword, isNull); | 640 expect(method.operatorKeyword, isNull); |
| 635 expect(method.typeParameters, isNotNull); | 641 expect(method.typeParameters, isNotNull); |
| 636 expect(method.parameters, isNotNull); | 642 expect(method.parameters, isNotNull); |
| 637 expect(method.body, isNotNull); | 643 expect(method.body, isNotNull); |
| 638 } | 644 } |
| 639 | 645 |
| 640 void test_parseClassMember_method_generic_comment_parameterType() { | 646 void test_parseClassMember_method_generic_comment_parameterType() { |
| 641 enableGenericMethodComments = true; | 647 enableGenericMethodComments = true; |
| 642 createParser('m/*<T>*/(dynamic /*=T*/ p) => null;'); | 648 createParser('m/*<T>*/(dynamic /*=T*/ p) => null;'); |
| 643 ClassMember member = parser.parseClassMember('C'); | 649 ClassMember member = parser.parseClassMember('C'); |
| 644 expect(member, isNotNull); | 650 expect(member, isNotNull); |
| 645 assertNoErrors(); | 651 if (usingFastaParser) { |
| 652 assertNoErrors(); |
| 653 } else { |
| 654 assertErrorsWithCodes( |
| 655 [HintCode.GENERIC_METHOD_COMMENT, HintCode.GENERIC_METHOD_COMMENT]); |
| 656 } |
| 646 expect(member, new isInstanceOf<MethodDeclaration>()); | 657 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 647 MethodDeclaration method = member; | 658 MethodDeclaration method = member; |
| 648 expect(method.documentationComment, isNull); | 659 expect(method.documentationComment, isNull); |
| 649 expect(method.externalKeyword, isNull); | 660 expect(method.externalKeyword, isNull); |
| 650 expect(method.modifierKeyword, isNull); | 661 expect(method.modifierKeyword, isNull); |
| 651 expect(method.propertyKeyword, isNull); | 662 expect(method.propertyKeyword, isNull); |
| 652 expect(method.returnType, isNull); | 663 expect(method.returnType, isNull); |
| 653 expect(method.name, isNotNull); | 664 expect(method.name, isNotNull); |
| 654 expect(method.operatorKeyword, isNull); | 665 expect(method.operatorKeyword, isNull); |
| 655 expect(method.typeParameters, isNotNull); | 666 expect(method.typeParameters, isNotNull); |
| 656 | 667 |
| 657 FormalParameterList parameters = method.parameters; | 668 FormalParameterList parameters = method.parameters; |
| 658 expect(parameters, isNotNull); | 669 expect(parameters, isNotNull); |
| 659 expect(parameters.parameters, hasLength(1)); | 670 expect(parameters.parameters, hasLength(1)); |
| 660 var parameter = parameters.parameters[0] as SimpleFormalParameter; | 671 var parameter = parameters.parameters[0] as SimpleFormalParameter; |
| 661 var parameterType = parameter.type as TypeName; | 672 var parameterType = parameter.type as TypeName; |
| 662 expect(parameterType.name.name, 'T'); | 673 expect(parameterType.name.name, 'T'); |
| 663 | 674 |
| 664 expect(method.body, isNotNull); | 675 expect(method.body, isNotNull); |
| 665 } | 676 } |
| 666 | 677 |
| 667 void test_parseClassMember_method_generic_comment_returnType() { | 678 void test_parseClassMember_method_generic_comment_returnType() { |
| 668 enableGenericMethodComments = true; | 679 enableGenericMethodComments = true; |
| 669 createParser('/*=T*/ m/*<T>*/() {}'); | 680 createParser('/*=T*/ m/*<T>*/() {}'); |
| 670 ClassMember member = parser.parseClassMember('C'); | 681 ClassMember member = parser.parseClassMember('C'); |
| 671 expect(member, isNotNull); | 682 expect(member, isNotNull); |
| 672 assertNoErrors(); | 683 if (usingFastaParser) { |
| 684 assertNoErrors(); |
| 685 } else { |
| 686 assertErrorsWithCodes( |
| 687 [HintCode.GENERIC_METHOD_COMMENT, HintCode.GENERIC_METHOD_COMMENT]); |
| 688 } |
| 673 expect(member, new isInstanceOf<MethodDeclaration>()); | 689 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 674 MethodDeclaration method = member; | 690 MethodDeclaration method = member; |
| 675 expect(method.documentationComment, isNull); | 691 expect(method.documentationComment, isNull); |
| 676 expect(method.externalKeyword, isNull); | 692 expect(method.externalKeyword, isNull); |
| 677 expect(method.modifierKeyword, isNull); | 693 expect(method.modifierKeyword, isNull); |
| 678 expect(method.propertyKeyword, isNull); | 694 expect(method.propertyKeyword, isNull); |
| 679 expect(method.returnType, isNotNull); | 695 expect(method.returnType, isNotNull); |
| 680 expect((method.returnType as TypeName).name.name, 'T'); | 696 expect((method.returnType as TypeName).name.name, 'T'); |
| 681 expect(method.name, isNotNull); | 697 expect(method.name, isNotNull); |
| 682 expect(method.operatorKeyword, isNull); | 698 expect(method.operatorKeyword, isNull); |
| 683 expect(method.typeParameters, isNotNull); | 699 expect(method.typeParameters, isNotNull); |
| 684 expect(method.parameters, isNotNull); | 700 expect(method.parameters, isNotNull); |
| 685 expect(method.body, isNotNull); | 701 expect(method.body, isNotNull); |
| 686 } | 702 } |
| 687 | 703 |
| 688 void test_parseClassMember_method_generic_comment_returnType_bound() { | 704 void test_parseClassMember_method_generic_comment_returnType_bound() { |
| 689 enableGenericMethodComments = true; | 705 enableGenericMethodComments = true; |
| 690 createParser('num/*=T*/ m/*<T extends num>*/() {}'); | 706 createParser('num/*=T*/ m/*<T extends num>*/() {}'); |
| 691 ClassMember member = parser.parseClassMember('C'); | 707 ClassMember member = parser.parseClassMember('C'); |
| 692 expect(member, isNotNull); | 708 expect(member, isNotNull); |
| 693 assertNoErrors(); | 709 if (usingFastaParser) { |
| 710 assertNoErrors(); |
| 711 } else { |
| 712 assertErrorsWithCodes( |
| 713 [HintCode.GENERIC_METHOD_COMMENT, HintCode.GENERIC_METHOD_COMMENT]); |
| 714 } |
| 694 expect(member, new isInstanceOf<MethodDeclaration>()); | 715 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 695 MethodDeclaration method = member; | 716 MethodDeclaration method = member; |
| 696 expect(method.documentationComment, isNull); | 717 expect(method.documentationComment, isNull); |
| 697 expect(method.externalKeyword, isNull); | 718 expect(method.externalKeyword, isNull); |
| 698 expect(method.modifierKeyword, isNull); | 719 expect(method.modifierKeyword, isNull); |
| 699 expect(method.propertyKeyword, isNull); | 720 expect(method.propertyKeyword, isNull); |
| 700 expect((method.returnType as TypeName).name.name, 'T'); | 721 expect((method.returnType as TypeName).name.name, 'T'); |
| 701 expect(method.name, isNotNull); | 722 expect(method.name, isNotNull); |
| 702 expect(method.operatorKeyword, isNull); | 723 expect(method.operatorKeyword, isNull); |
| 703 expect(method.typeParameters, isNotNull); | 724 expect(method.typeParameters, isNotNull); |
| 704 TypeParameter tp = method.typeParameters.typeParameters[0]; | 725 TypeParameter tp = method.typeParameters.typeParameters[0]; |
| 705 expect(tp.name.name, 'T'); | 726 expect(tp.name.name, 'T'); |
| 706 expect(tp.extendsKeyword, isNotNull); | 727 expect(tp.extendsKeyword, isNotNull); |
| 707 expect((tp.bound as TypeName).name.name, 'num'); | 728 expect((tp.bound as TypeName).name.name, 'num'); |
| 708 expect(method.parameters, isNotNull); | 729 expect(method.parameters, isNotNull); |
| 709 expect(method.body, isNotNull); | 730 expect(method.body, isNotNull); |
| 710 } | 731 } |
| 711 | 732 |
| 712 void test_parseClassMember_method_generic_comment_returnType_complex() { | 733 void test_parseClassMember_method_generic_comment_returnType_complex() { |
| 713 enableGenericMethodComments = true; | 734 enableGenericMethodComments = true; |
| 714 createParser('dynamic /*=Map<int, T>*/ m/*<T>*/() => null;'); | 735 createParser('dynamic /*=Map<int, T>*/ m/*<T>*/() => null;'); |
| 715 ClassMember member = parser.parseClassMember('C'); | 736 ClassMember member = parser.parseClassMember('C'); |
| 716 expect(member, isNotNull); | 737 expect(member, isNotNull); |
| 717 assertNoErrors(); | 738 if (usingFastaParser) { |
| 739 assertNoErrors(); |
| 740 } else { |
| 741 assertErrorsWithCodes( |
| 742 [HintCode.GENERIC_METHOD_COMMENT, HintCode.GENERIC_METHOD_COMMENT]); |
| 743 } |
| 718 expect(member, new isInstanceOf<MethodDeclaration>()); | 744 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 719 MethodDeclaration method = member; | 745 MethodDeclaration method = member; |
| 720 expect(method.documentationComment, isNull); | 746 expect(method.documentationComment, isNull); |
| 721 expect(method.externalKeyword, isNull); | 747 expect(method.externalKeyword, isNull); |
| 722 expect(method.modifierKeyword, isNull); | 748 expect(method.modifierKeyword, isNull); |
| 723 expect(method.propertyKeyword, isNull); | 749 expect(method.propertyKeyword, isNull); |
| 724 | 750 |
| 725 { | 751 { |
| 726 var returnType = method.returnType as TypeName; | 752 var returnType = method.returnType as TypeName; |
| 727 expect(returnType, isNotNull); | 753 expect(returnType, isNotNull); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 738 expect(method.typeParameters, isNotNull); | 764 expect(method.typeParameters, isNotNull); |
| 739 expect(method.parameters, isNotNull); | 765 expect(method.parameters, isNotNull); |
| 740 expect(method.body, isNotNull); | 766 expect(method.body, isNotNull); |
| 741 } | 767 } |
| 742 | 768 |
| 743 void test_parseClassMember_method_generic_comment_void() { | 769 void test_parseClassMember_method_generic_comment_void() { |
| 744 enableGenericMethodComments = true; | 770 enableGenericMethodComments = true; |
| 745 createParser('void m/*<T>*/() {}'); | 771 createParser('void m/*<T>*/() {}'); |
| 746 ClassMember member = parser.parseClassMember('C'); | 772 ClassMember member = parser.parseClassMember('C'); |
| 747 expect(member, isNotNull); | 773 expect(member, isNotNull); |
| 748 assertNoErrors(); | 774 if (usingFastaParser) { |
| 775 assertNoErrors(); |
| 776 } else { |
| 777 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 778 } |
| 749 expect(member, new isInstanceOf<MethodDeclaration>()); | 779 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 750 MethodDeclaration method = member; | 780 MethodDeclaration method = member; |
| 751 expect(method.documentationComment, isNull); | 781 expect(method.documentationComment, isNull); |
| 752 expect(method.externalKeyword, isNull); | 782 expect(method.externalKeyword, isNull); |
| 753 expect(method.modifierKeyword, isNull); | 783 expect(method.modifierKeyword, isNull); |
| 754 expect(method.propertyKeyword, isNull); | 784 expect(method.propertyKeyword, isNull); |
| 755 expect(method.returnType, isNotNull); | 785 expect(method.returnType, isNotNull); |
| 756 expect(method.name, isNotNull); | 786 expect(method.name, isNotNull); |
| 757 expect(method.operatorKeyword, isNull); | 787 expect(method.operatorKeyword, isNull); |
| 758 expect(method.typeParameters, isNotNull); | 788 expect(method.typeParameters, isNotNull); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 expect(method.typeParameters, isNull); | 1088 expect(method.typeParameters, isNull); |
| 1059 expect(method.parameters, isNotNull); | 1089 expect(method.parameters, isNotNull); |
| 1060 expect(method.body, isNotNull); | 1090 expect(method.body, isNotNull); |
| 1061 } | 1091 } |
| 1062 | 1092 |
| 1063 void test_parseClassMember_method_static_generic_comment_returnType() { | 1093 void test_parseClassMember_method_static_generic_comment_returnType() { |
| 1064 enableGenericMethodComments = true; | 1094 enableGenericMethodComments = true; |
| 1065 createParser('static /*=T*/ m/*<T>*/() {}'); | 1095 createParser('static /*=T*/ m/*<T>*/() {}'); |
| 1066 ClassMember member = parser.parseClassMember('C'); | 1096 ClassMember member = parser.parseClassMember('C'); |
| 1067 expect(member, isNotNull); | 1097 expect(member, isNotNull); |
| 1068 assertNoErrors(); | 1098 if (usingFastaParser) { |
| 1099 assertNoErrors(); |
| 1100 } else { |
| 1101 assertErrorsWithCodes( |
| 1102 [HintCode.GENERIC_METHOD_COMMENT, HintCode.GENERIC_METHOD_COMMENT]); |
| 1103 } |
| 1069 expect(member, new isInstanceOf<MethodDeclaration>()); | 1104 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 1070 MethodDeclaration method = member; | 1105 MethodDeclaration method = member; |
| 1071 expect(method.documentationComment, isNull); | 1106 expect(method.documentationComment, isNull); |
| 1072 expect(method.externalKeyword, isNull); | 1107 expect(method.externalKeyword, isNull); |
| 1073 expect(method.modifierKeyword, isNotNull); | 1108 expect(method.modifierKeyword, isNotNull); |
| 1074 expect(method.propertyKeyword, isNull); | 1109 expect(method.propertyKeyword, isNull); |
| 1075 expect(method.returnType, isNotNull); | 1110 expect(method.returnType, isNotNull); |
| 1076 expect((method.returnType as TypeName).name.name, 'T'); | 1111 expect((method.returnType as TypeName).name.name, 'T'); |
| 1077 expect(method.name, isNotNull); | 1112 expect(method.name, isNotNull); |
| 1078 expect(method.operatorKeyword, isNull); | 1113 expect(method.operatorKeyword, isNull); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 expect(invocation4.methodName.name, "a"); | 1643 expect(invocation4.methodName.name, "a"); |
| 1609 expect(invocation4.typeArguments, isNull); | 1644 expect(invocation4.typeArguments, isNull); |
| 1610 ArgumentList argumentList4 = invocation4.argumentList; | 1645 ArgumentList argumentList4 = invocation4.argumentList; |
| 1611 expect(argumentList4, isNotNull); | 1646 expect(argumentList4, isNotNull); |
| 1612 expect(argumentList4.arguments, hasLength(1)); | 1647 expect(argumentList4.arguments, hasLength(1)); |
| 1613 } | 1648 } |
| 1614 | 1649 |
| 1615 void test_assignableExpression_arguments_normal_chain_typeArgumentComments() { | 1650 void test_assignableExpression_arguments_normal_chain_typeArgumentComments() { |
| 1616 enableGenericMethodComments = true; | 1651 enableGenericMethodComments = true; |
| 1617 _validate_assignableExpression_arguments_normal_chain_typeArguments( | 1652 _validate_assignableExpression_arguments_normal_chain_typeArguments( |
| 1618 "a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e).f"); | 1653 "a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e).f", |
| 1654 usingFastaParser |
| 1655 ? [] |
| 1656 : [ |
| 1657 HintCode.GENERIC_METHOD_COMMENT, |
| 1658 HintCode.GENERIC_METHOD_COMMENT, |
| 1659 HintCode.GENERIC_METHOD_COMMENT |
| 1660 ]); |
| 1619 } | 1661 } |
| 1620 | 1662 |
| 1621 void test_assignableExpression_arguments_normal_chain_typeArguments() { | 1663 void test_assignableExpression_arguments_normal_chain_typeArguments() { |
| 1622 _validate_assignableExpression_arguments_normal_chain_typeArguments( | 1664 _validate_assignableExpression_arguments_normal_chain_typeArguments( |
| 1623 "a<E>(b)<F>(c).d<G>(e).f"); | 1665 "a<E>(b)<F>(c).d<G>(e).f"); |
| 1624 } | 1666 } |
| 1625 | 1667 |
| 1626 void test_assignmentExpression_compound() { | 1668 void test_assignmentExpression_compound() { |
| 1627 AssignmentExpression expression = parseExpression("x = y = 0"); | 1669 AssignmentExpression expression = parseExpression("x = y = 0"); |
| 1628 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, | 1670 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 void test_topLevelFunction_nestedGenericFunction() { | 1992 void test_topLevelFunction_nestedGenericFunction() { |
| 1951 parseCompilationUnit(''' | 1993 parseCompilationUnit(''' |
| 1952 void f() { | 1994 void f() { |
| 1953 void g<T>() { | 1995 void g<T>() { |
| 1954 } | 1996 } |
| 1955 } | 1997 } |
| 1956 '''); | 1998 '''); |
| 1957 } | 1999 } |
| 1958 | 2000 |
| 1959 void _validate_assignableExpression_arguments_normal_chain_typeArguments( | 2001 void _validate_assignableExpression_arguments_normal_chain_typeArguments( |
| 1960 String code) { | 2002 String code, |
| 1961 PropertyAccess propertyAccess1 = parseExpression(code); | 2003 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 2004 PropertyAccess propertyAccess1 = parseExpression(code, errorCodes); |
| 1962 expect(propertyAccess1.propertyName.name, "f"); | 2005 expect(propertyAccess1.propertyName.name, "f"); |
| 1963 // | 2006 // |
| 1964 // a<E>(b)<F>(c).d<G>(e) | 2007 // a<E>(b)<F>(c).d<G>(e) |
| 1965 // | 2008 // |
| 1966 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( | 2009 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( |
| 1967 (obj) => obj is MethodInvocation, | 2010 (obj) => obj is MethodInvocation, |
| 1968 MethodInvocation, | 2011 MethodInvocation, |
| 1969 propertyAccess1.target); | 2012 propertyAccess1.target); |
| 1970 expect(invocation2.methodName.name, "d"); | 2013 expect(invocation2.methodName.name, "d"); |
| 1971 expect(invocation2.typeArguments, isNotNull); | 2014 expect(invocation2.typeArguments, isNotNull); |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3204 parseStatement("static f() {}"); | 3247 parseStatement("static f() {}"); |
| 3205 assertErrorsWithCodes( | 3248 assertErrorsWithCodes( |
| 3206 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); | 3249 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); |
| 3207 } | 3250 } |
| 3208 | 3251 |
| 3209 void test_method_invalidTypeParameterComments() { | 3252 void test_method_invalidTypeParameterComments() { |
| 3210 enableGenericMethodComments = true; | 3253 enableGenericMethodComments = true; |
| 3211 createParser('void m/*<E, hello!>*/() {}'); | 3254 createParser('void m/*<E, hello!>*/() {}'); |
| 3212 ClassMember member = parser.parseClassMember('C'); | 3255 ClassMember member = parser.parseClassMember('C'); |
| 3213 expectNotNullIfNoErrors(member); | 3256 expectNotNullIfNoErrors(member); |
| 3214 listener.assertErrorsWithCodes([ | 3257 if (usingFastaParser) { |
| 3215 ParserErrorCode.EXPECTED_TOKEN /*>*/, | 3258 listener.assertErrorsWithCodes([ |
| 3216 ParserErrorCode.MISSING_IDENTIFIER, | 3259 ParserErrorCode.EXPECTED_TOKEN /*>*/, |
| 3217 ParserErrorCode.EXPECTED_TOKEN /*(*/, | 3260 ParserErrorCode.MISSING_IDENTIFIER, |
| 3218 ParserErrorCode.EXPECTED_TOKEN /*)*/, | 3261 ParserErrorCode.EXPECTED_TOKEN /*(*/, |
| 3219 ParserErrorCode.MISSING_FUNCTION_BODY | 3262 ParserErrorCode.EXPECTED_TOKEN /*)*/, |
| 3220 ]); | 3263 ParserErrorCode.MISSING_FUNCTION_BODY |
| 3264 ]); |
| 3265 } else { |
| 3266 listener.assertErrorsWithCodes([ |
| 3267 ParserErrorCode.EXPECTED_TOKEN /*>*/, |
| 3268 ParserErrorCode.MISSING_IDENTIFIER, |
| 3269 ParserErrorCode.EXPECTED_TOKEN /*(*/, |
| 3270 ParserErrorCode.EXPECTED_TOKEN /*)*/, |
| 3271 ParserErrorCode.MISSING_FUNCTION_BODY, |
| 3272 HintCode.GENERIC_METHOD_COMMENT |
| 3273 ]); |
| 3274 } |
| 3221 expect(member, new isInstanceOf<MethodDeclaration>()); | 3275 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 3222 MethodDeclaration method = member; | 3276 MethodDeclaration method = member; |
| 3223 expect(method.typeParameters.toString(), '<E, hello>', | 3277 expect(method.typeParameters.toString(), '<E, hello>', |
| 3224 reason: 'parser recovers what it can'); | 3278 reason: 'parser recovers what it can'); |
| 3225 } | 3279 } |
| 3226 | 3280 |
| 3227 void test_method_invalidTypeParameterExtends() { | 3281 void test_method_invalidTypeParameterExtends() { |
| 3228 // Regression test for https://github.com/dart-lang/sdk/issues/25739. | 3282 // Regression test for https://github.com/dart-lang/sdk/issues/25739. |
| 3229 | 3283 |
| 3230 // TODO(jmesserly): ideally we'd be better at parser recovery here. | 3284 // TODO(jmesserly): ideally we'd be better at parser recovery here. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3248 | 3302 |
| 3249 // TODO(jmesserly): ideally we'd be better at parser recovery here. | 3303 // TODO(jmesserly): ideally we'd be better at parser recovery here. |
| 3250 // Also, this behavior is slightly different from how we would parse a | 3304 // Also, this behavior is slightly different from how we would parse a |
| 3251 // normal generic method, because we "discover" the comment at a different | 3305 // normal generic method, because we "discover" the comment at a different |
| 3252 // point in the parser. This has a slight effect on the AST that results | 3306 // point in the parser. This has a slight effect on the AST that results |
| 3253 // from error recovery. | 3307 // from error recovery. |
| 3254 enableGenericMethodComments = true; | 3308 enableGenericMethodComments = true; |
| 3255 createParser('f/*<E>*/(dynamic/*=E extends num*/p);'); | 3309 createParser('f/*<E>*/(dynamic/*=E extends num*/p);'); |
| 3256 ClassMember member = parser.parseClassMember('C'); | 3310 ClassMember member = parser.parseClassMember('C'); |
| 3257 expectNotNullIfNoErrors(member); | 3311 expectNotNullIfNoErrors(member); |
| 3258 listener.assertErrorsWithCodes([ | 3312 if (usingFastaParser) { |
| 3259 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword | 3313 listener.assertErrorsWithCodes([ |
| 3260 ParserErrorCode.EXPECTED_TOKEN, // comma | 3314 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| 3261 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword | 3315 ParserErrorCode.EXPECTED_TOKEN, // comma |
| 3262 ParserErrorCode.EXPECTED_TOKEN, // close paren | 3316 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| 3263 ParserErrorCode.MISSING_FUNCTION_BODY | 3317 ParserErrorCode.EXPECTED_TOKEN, // close paren |
| 3264 ]); | 3318 ParserErrorCode.MISSING_FUNCTION_BODY |
| 3319 ]); |
| 3320 } else { |
| 3321 listener.assertErrorsWithCodes([ |
| 3322 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| 3323 ParserErrorCode.EXPECTED_TOKEN, // comma |
| 3324 ParserErrorCode.MISSING_IDENTIFIER, // `extends` is a keyword |
| 3325 ParserErrorCode.EXPECTED_TOKEN, // close paren |
| 3326 ParserErrorCode.MISSING_FUNCTION_BODY, |
| 3327 HintCode.GENERIC_METHOD_COMMENT, |
| 3328 HintCode.GENERIC_METHOD_COMMENT |
| 3329 ]); |
| 3330 } |
| 3265 expect(member, new isInstanceOf<MethodDeclaration>()); | 3331 expect(member, new isInstanceOf<MethodDeclaration>()); |
| 3266 MethodDeclaration method = member; | 3332 MethodDeclaration method = member; |
| 3267 expect(method.parameters.toString(), '(E extends, extends)', | 3333 expect(method.parameters.toString(), '(E extends, extends)', |
| 3268 reason: 'parser recovers what it can'); | 3334 reason: 'parser recovers what it can'); |
| 3269 } | 3335 } |
| 3270 | 3336 |
| 3271 void test_method_invalidTypeParameters() { | 3337 void test_method_invalidTypeParameters() { |
| 3272 // TODO(jmesserly): ideally we'd be better at parser recovery here. | 3338 // TODO(jmesserly): ideally we'd be better at parser recovery here. |
| 3273 // It doesn't try to advance past the invalid token `!` to find the | 3339 // It doesn't try to advance past the invalid token `!` to find the |
| 3274 // valid `>`. If it did we'd get less cascading errors, at least for this | 3340 // valid `>`. If it did we'd get less cascading errors, at least for this |
| (...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4465 expect(argumentList.arguments, hasLength(1)); | 4531 expect(argumentList.arguments, hasLength(1)); |
| 4466 expect(propertyAccess.operator, isNotNull); | 4532 expect(propertyAccess.operator, isNotNull); |
| 4467 expect(propertyAccess.propertyName, isNotNull); | 4533 expect(propertyAccess.propertyName, isNotNull); |
| 4468 } | 4534 } |
| 4469 | 4535 |
| 4470 void | 4536 void |
| 4471 test_parseAssignableExpression_expression_args_dot_typeArgumentComments()
{ | 4537 test_parseAssignableExpression_expression_args_dot_typeArgumentComments()
{ |
| 4472 enableGenericMethodComments = true; | 4538 enableGenericMethodComments = true; |
| 4473 Expression expression = parseAssignableExpression('(x)/*<F>*/(y).z', false); | 4539 Expression expression = parseAssignableExpression('(x)/*<F>*/(y).z', false); |
| 4474 expect(expression, isNotNull); | 4540 expect(expression, isNotNull); |
| 4475 assertNoErrors(); | 4541 if (usingFastaParser) { |
| 4542 assertNoErrors(); |
| 4543 } else { |
| 4544 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 4545 } |
| 4476 var propertyAccess = expression as PropertyAccess; | 4546 var propertyAccess = expression as PropertyAccess; |
| 4477 FunctionExpressionInvocation invocation = | 4547 FunctionExpressionInvocation invocation = |
| 4478 propertyAccess.target as FunctionExpressionInvocation; | 4548 propertyAccess.target as FunctionExpressionInvocation; |
| 4479 expect(invocation.function, isNotNull); | 4549 expect(invocation.function, isNotNull); |
| 4480 expect(invocation.typeArguments, isNotNull); | 4550 expect(invocation.typeArguments, isNotNull); |
| 4481 ArgumentList argumentList = invocation.argumentList; | 4551 ArgumentList argumentList = invocation.argumentList; |
| 4482 expect(argumentList, isNotNull); | 4552 expect(argumentList, isNotNull); |
| 4483 expect(argumentList.arguments, hasLength(1)); | 4553 expect(argumentList.arguments, hasLength(1)); |
| 4484 expect(propertyAccess.operator, isNotNull); | 4554 expect(propertyAccess.operator, isNotNull); |
| 4485 expect(propertyAccess.propertyName, isNotNull); | 4555 expect(propertyAccess.propertyName, isNotNull); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4553 expect(argumentList.arguments, hasLength(1)); | 4623 expect(argumentList.arguments, hasLength(1)); |
| 4554 expect(propertyAccess.operator, isNotNull); | 4624 expect(propertyAccess.operator, isNotNull); |
| 4555 expect(propertyAccess.propertyName, isNotNull); | 4625 expect(propertyAccess.propertyName, isNotNull); |
| 4556 } | 4626 } |
| 4557 | 4627 |
| 4558 void | 4628 void |
| 4559 test_parseAssignableExpression_identifier_args_dot_typeArgumentComments()
{ | 4629 test_parseAssignableExpression_identifier_args_dot_typeArgumentComments()
{ |
| 4560 enableGenericMethodComments = true; | 4630 enableGenericMethodComments = true; |
| 4561 Expression expression = parseAssignableExpression('x/*<E>*/(y).z', false); | 4631 Expression expression = parseAssignableExpression('x/*<E>*/(y).z', false); |
| 4562 expect(expression, isNotNull); | 4632 expect(expression, isNotNull); |
| 4563 assertNoErrors(); | 4633 if (usingFastaParser) { |
| 4634 assertNoErrors(); |
| 4635 } else { |
| 4636 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 4637 } |
| 4564 var propertyAccess = expression as PropertyAccess; | 4638 var propertyAccess = expression as PropertyAccess; |
| 4565 MethodInvocation invocation = propertyAccess.target as MethodInvocation; | 4639 MethodInvocation invocation = propertyAccess.target as MethodInvocation; |
| 4566 expect(invocation.methodName.name, "x"); | 4640 expect(invocation.methodName.name, "x"); |
| 4567 expect(invocation.typeArguments, isNotNull); | 4641 expect(invocation.typeArguments, isNotNull); |
| 4568 ArgumentList argumentList = invocation.argumentList; | 4642 ArgumentList argumentList = invocation.argumentList; |
| 4569 expect(argumentList, isNotNull); | 4643 expect(argumentList, isNotNull); |
| 4570 expect(argumentList.arguments, hasLength(1)); | 4644 expect(argumentList.arguments, hasLength(1)); |
| 4571 expect(propertyAccess.operator, isNotNull); | 4645 expect(propertyAccess.operator, isNotNull); |
| 4572 expect(propertyAccess.propertyName, isNotNull); | 4646 expect(propertyAccess.propertyName, isNotNull); |
| 4573 } | 4647 } |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4769 var section = expression as FunctionExpressionInvocation; | 4843 var section = expression as FunctionExpressionInvocation; |
| 4770 expect(section.function, new isInstanceOf<IndexExpression>()); | 4844 expect(section.function, new isInstanceOf<IndexExpression>()); |
| 4771 expect(section.typeArguments, isNull); | 4845 expect(section.typeArguments, isNull); |
| 4772 expect(section.argumentList, isNotNull); | 4846 expect(section.argumentList, isNotNull); |
| 4773 } | 4847 } |
| 4774 | 4848 |
| 4775 void test_parseCascadeSection_ia_typeArgumentComments() { | 4849 void test_parseCascadeSection_ia_typeArgumentComments() { |
| 4776 enableGenericMethodComments = true; | 4850 enableGenericMethodComments = true; |
| 4777 Expression expression = parseCascadeSection('..[i]/*<E>*/(b)'); | 4851 Expression expression = parseCascadeSection('..[i]/*<E>*/(b)'); |
| 4778 expect(expression, isNotNull); | 4852 expect(expression, isNotNull); |
| 4779 assertNoErrors(); | 4853 if (usingFastaParser) { |
| 4854 assertNoErrors(); |
| 4855 } else { |
| 4856 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 4857 } |
| 4780 var section = expression as FunctionExpressionInvocation; | 4858 var section = expression as FunctionExpressionInvocation; |
| 4781 expect(section.function, new isInstanceOf<IndexExpression>()); | 4859 expect(section.function, new isInstanceOf<IndexExpression>()); |
| 4782 expect(section.typeArguments, isNotNull); | 4860 expect(section.typeArguments, isNotNull); |
| 4783 expect(section.argumentList, isNotNull); | 4861 expect(section.argumentList, isNotNull); |
| 4784 } | 4862 } |
| 4785 | 4863 |
| 4786 void test_parseCascadeSection_ia_typeArguments() { | 4864 void test_parseCascadeSection_ia_typeArguments() { |
| 4787 Expression expression = parseCascadeSection('..[i]<E>(b)'); | 4865 Expression expression = parseCascadeSection('..[i]<E>(b)'); |
| 4788 expect(expression, isNotNull); | 4866 expect(expression, isNotNull); |
| 4789 assertNoErrors(); | 4867 assertNoErrors(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 4803 expect(section.methodName, isNotNull); | 4881 expect(section.methodName, isNotNull); |
| 4804 expect(section.typeArguments, isNull); | 4882 expect(section.typeArguments, isNull); |
| 4805 expect(section.argumentList, isNotNull); | 4883 expect(section.argumentList, isNotNull); |
| 4806 expect(section.argumentList.arguments, hasLength(1)); | 4884 expect(section.argumentList.arguments, hasLength(1)); |
| 4807 } | 4885 } |
| 4808 | 4886 |
| 4809 void test_parseCascadeSection_ii_typeArgumentComments() { | 4887 void test_parseCascadeSection_ii_typeArgumentComments() { |
| 4810 enableGenericMethodComments = true; | 4888 enableGenericMethodComments = true; |
| 4811 Expression expression = parseCascadeSection('..a/*<E>*/(b).c/*<F>*/(d)'); | 4889 Expression expression = parseCascadeSection('..a/*<E>*/(b).c/*<F>*/(d)'); |
| 4812 expect(expression, isNotNull); | 4890 expect(expression, isNotNull); |
| 4813 assertNoErrors(); | 4891 if (usingFastaParser) { |
| 4892 assertNoErrors(); |
| 4893 } else { |
| 4894 assertErrorsWithCodes( |
| 4895 [HintCode.GENERIC_METHOD_COMMENT, HintCode.GENERIC_METHOD_COMMENT]); |
| 4896 } |
| 4814 var section = expression as MethodInvocation; | 4897 var section = expression as MethodInvocation; |
| 4815 expect(section.target, new isInstanceOf<MethodInvocation>()); | 4898 expect(section.target, new isInstanceOf<MethodInvocation>()); |
| 4816 expect(section.operator, isNotNull); | 4899 expect(section.operator, isNotNull); |
| 4817 expect(section.methodName, isNotNull); | 4900 expect(section.methodName, isNotNull); |
| 4818 expect(section.typeArguments, isNotNull); | 4901 expect(section.typeArguments, isNotNull); |
| 4819 expect(section.argumentList, isNotNull); | 4902 expect(section.argumentList, isNotNull); |
| 4820 expect(section.argumentList.arguments, hasLength(1)); | 4903 expect(section.argumentList.arguments, hasLength(1)); |
| 4821 } | 4904 } |
| 4822 | 4905 |
| 4823 void test_parseCascadeSection_ii_typeArguments() { | 4906 void test_parseCascadeSection_ii_typeArguments() { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4911 expect(section.methodName, isNotNull); | 4994 expect(section.methodName, isNotNull); |
| 4912 expect(section.typeArguments, isNull); | 4995 expect(section.typeArguments, isNull); |
| 4913 expect(section.argumentList, isNotNull); | 4996 expect(section.argumentList, isNotNull); |
| 4914 expect(section.argumentList.arguments, hasLength(1)); | 4997 expect(section.argumentList.arguments, hasLength(1)); |
| 4915 } | 4998 } |
| 4916 | 4999 |
| 4917 void test_parseCascadeSection_pa_typeArgumentComments() { | 5000 void test_parseCascadeSection_pa_typeArgumentComments() { |
| 4918 enableGenericMethodComments = true; | 5001 enableGenericMethodComments = true; |
| 4919 Expression expression = parseCascadeSection('..a/*<E>*/(b)'); | 5002 Expression expression = parseCascadeSection('..a/*<E>*/(b)'); |
| 4920 expect(expression, isNotNull); | 5003 expect(expression, isNotNull); |
| 4921 assertNoErrors(); | 5004 if (usingFastaParser) { |
| 5005 assertNoErrors(); |
| 5006 } else { |
| 5007 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 5008 } |
| 4922 var section = expression as MethodInvocation; | 5009 var section = expression as MethodInvocation; |
| 4923 expect(section.target, isNull); | 5010 expect(section.target, isNull); |
| 4924 expect(section.operator, isNotNull); | 5011 expect(section.operator, isNotNull); |
| 4925 expect(section.methodName, isNotNull); | 5012 expect(section.methodName, isNotNull); |
| 4926 expect(section.typeArguments, isNotNull); | 5013 expect(section.typeArguments, isNotNull); |
| 4927 expect(section.argumentList, isNotNull); | 5014 expect(section.argumentList, isNotNull); |
| 4928 expect(section.argumentList.arguments, hasLength(1)); | 5015 expect(section.argumentList.arguments, hasLength(1)); |
| 4929 } | 5016 } |
| 4930 | 5017 |
| 4931 void test_parseCascadeSection_pa_typeArguments() { | 5018 void test_parseCascadeSection_pa_typeArguments() { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4949 expect(section.function, new isInstanceOf<MethodInvocation>()); | 5036 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4950 expect(section.typeArguments, isNull); | 5037 expect(section.typeArguments, isNull); |
| 4951 expect(section.argumentList, isNotNull); | 5038 expect(section.argumentList, isNotNull); |
| 4952 expect(section.argumentList.arguments, hasLength(1)); | 5039 expect(section.argumentList.arguments, hasLength(1)); |
| 4953 } | 5040 } |
| 4954 | 5041 |
| 4955 void test_parseCascadeSection_paa_typeArgumentComments() { | 5042 void test_parseCascadeSection_paa_typeArgumentComments() { |
| 4956 enableGenericMethodComments = true; | 5043 enableGenericMethodComments = true; |
| 4957 Expression expression = parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c)'); | 5044 Expression expression = parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c)'); |
| 4958 expect(expression, isNotNull); | 5045 expect(expression, isNotNull); |
| 4959 assertNoErrors(); | 5046 if (usingFastaParser) { |
| 5047 assertNoErrors(); |
| 5048 } else { |
| 5049 assertErrorsWithCodes( |
| 5050 [HintCode.GENERIC_METHOD_COMMENT, HintCode.GENERIC_METHOD_COMMENT]); |
| 5051 } |
| 4960 var section = expression as FunctionExpressionInvocation; | 5052 var section = expression as FunctionExpressionInvocation; |
| 4961 expect(section.function, new isInstanceOf<MethodInvocation>()); | 5053 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4962 expect(section.typeArguments, isNotNull); | 5054 expect(section.typeArguments, isNotNull); |
| 4963 expect(section.argumentList, isNotNull); | 5055 expect(section.argumentList, isNotNull); |
| 4964 expect(section.argumentList.arguments, hasLength(1)); | 5056 expect(section.argumentList.arguments, hasLength(1)); |
| 4965 } | 5057 } |
| 4966 | 5058 |
| 4967 void test_parseCascadeSection_paa_typeArguments() { | 5059 void test_parseCascadeSection_paa_typeArguments() { |
| 4968 Expression expression = parseCascadeSection('..a<E>(b)<F>(c)'); | 5060 Expression expression = parseCascadeSection('..a<E>(b)<F>(c)'); |
| 4969 expect(expression, isNotNull); | 5061 expect(expression, isNotNull); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 4984 expect(section.typeArguments, isNull); | 5076 expect(section.typeArguments, isNull); |
| 4985 expect(section.argumentList, isNotNull); | 5077 expect(section.argumentList, isNotNull); |
| 4986 expect(section.argumentList.arguments, hasLength(1)); | 5078 expect(section.argumentList.arguments, hasLength(1)); |
| 4987 } | 5079 } |
| 4988 | 5080 |
| 4989 void test_parseCascadeSection_paapaa_typeArgumentComments() { | 5081 void test_parseCascadeSection_paapaa_typeArgumentComments() { |
| 4990 enableGenericMethodComments = true; | 5082 enableGenericMethodComments = true; |
| 4991 Expression expression = | 5083 Expression expression = |
| 4992 parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)'); | 5084 parseCascadeSection('..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)'); |
| 4993 expect(expression, isNotNull); | 5085 expect(expression, isNotNull); |
| 4994 assertNoErrors(); | 5086 if (usingFastaParser) { |
| 5087 assertNoErrors(); |
| 5088 } else { |
| 5089 assertErrorsWithCodes([ |
| 5090 HintCode.GENERIC_METHOD_COMMENT, |
| 5091 HintCode.GENERIC_METHOD_COMMENT, |
| 5092 HintCode.GENERIC_METHOD_COMMENT, |
| 5093 HintCode.GENERIC_METHOD_COMMENT |
| 5094 ]); |
| 5095 } |
| 4995 var section = expression as FunctionExpressionInvocation; | 5096 var section = expression as FunctionExpressionInvocation; |
| 4996 expect(section.function, new isInstanceOf<MethodInvocation>()); | 5097 expect(section.function, new isInstanceOf<MethodInvocation>()); |
| 4997 expect(section.typeArguments, isNotNull); | 5098 expect(section.typeArguments, isNotNull); |
| 4998 expect(section.argumentList, isNotNull); | 5099 expect(section.argumentList, isNotNull); |
| 4999 expect(section.argumentList.arguments, hasLength(1)); | 5100 expect(section.argumentList.arguments, hasLength(1)); |
| 5000 } | 5101 } |
| 5001 | 5102 |
| 5002 void test_parseCascadeSection_paapaa_typeArguments() { | 5103 void test_parseCascadeSection_paapaa_typeArguments() { |
| 5003 Expression expression = | 5104 Expression expression = |
| 5004 parseCascadeSection('..a<E>(b)<F>(c).d<G>(e)<H>(f)'); | 5105 parseCascadeSection('..a<E>(b)<F>(c).d<G>(e)<H>(f)'); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5018 var section = expression as PropertyAccess; | 5119 var section = expression as PropertyAccess; |
| 5019 expect(section.target, isNotNull); | 5120 expect(section.target, isNotNull); |
| 5020 expect(section.operator, isNotNull); | 5121 expect(section.operator, isNotNull); |
| 5021 expect(section.propertyName, isNotNull); | 5122 expect(section.propertyName, isNotNull); |
| 5022 } | 5123 } |
| 5023 | 5124 |
| 5024 void test_parseCascadeSection_pap_typeArgumentComments() { | 5125 void test_parseCascadeSection_pap_typeArgumentComments() { |
| 5025 enableGenericMethodComments = true; | 5126 enableGenericMethodComments = true; |
| 5026 Expression expression = parseCascadeSection('..a/*<E>*/(b).c'); | 5127 Expression expression = parseCascadeSection('..a/*<E>*/(b).c'); |
| 5027 expect(expression, isNotNull); | 5128 expect(expression, isNotNull); |
| 5028 assertNoErrors(); | 5129 if (usingFastaParser) { |
| 5130 assertNoErrors(); |
| 5131 } else { |
| 5132 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 5133 } |
| 5029 var section = expression as PropertyAccess; | 5134 var section = expression as PropertyAccess; |
| 5030 expect(section.target, isNotNull); | 5135 expect(section.target, isNotNull); |
| 5031 expect(section.operator, isNotNull); | 5136 expect(section.operator, isNotNull); |
| 5032 expect(section.propertyName, isNotNull); | 5137 expect(section.propertyName, isNotNull); |
| 5033 } | 5138 } |
| 5034 | 5139 |
| 5035 void test_parseCascadeSection_pap_typeArguments() { | 5140 void test_parseCascadeSection_pap_typeArguments() { |
| 5036 Expression expression = parseCascadeSection('..a<E>(b).c'); | 5141 Expression expression = parseCascadeSection('..a<E>(b).c'); |
| 5037 expect(expression, isNotNull); | 5142 expect(expression, isNotNull); |
| 5038 assertNoErrors(); | 5143 assertNoErrors(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5077 expect(literal.typeArguments, isNotNull); | 5182 expect(literal.typeArguments, isNotNull); |
| 5078 expect(literal.leftBracket, isNotNull); | 5183 expect(literal.leftBracket, isNotNull); |
| 5079 expect(literal.elements, hasLength(0)); | 5184 expect(literal.elements, hasLength(0)); |
| 5080 expect(literal.rightBracket, isNotNull); | 5185 expect(literal.rightBracket, isNotNull); |
| 5081 } | 5186 } |
| 5082 | 5187 |
| 5083 void test_parseConstExpression_listLiteral_typed_genericComment() { | 5188 void test_parseConstExpression_listLiteral_typed_genericComment() { |
| 5084 enableGenericMethodComments = true; | 5189 enableGenericMethodComments = true; |
| 5085 Expression expression = parseConstExpression('const /*<A>*/ []'); | 5190 Expression expression = parseConstExpression('const /*<A>*/ []'); |
| 5086 expect(expression, isNotNull); | 5191 expect(expression, isNotNull); |
| 5087 assertNoErrors(); | 5192 if (usingFastaParser) { |
| 5193 assertNoErrors(); |
| 5194 } else { |
| 5195 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 5196 } |
| 5088 var literal = expression as ListLiteral; | 5197 var literal = expression as ListLiteral; |
| 5089 expect(literal.constKeyword, isNotNull); | 5198 expect(literal.constKeyword, isNotNull); |
| 5090 expect(literal.typeArguments, isNotNull); | 5199 expect(literal.typeArguments, isNotNull); |
| 5091 expect(literal.leftBracket, isNotNull); | 5200 expect(literal.leftBracket, isNotNull); |
| 5092 expect(literal.elements, hasLength(0)); | 5201 expect(literal.elements, hasLength(0)); |
| 5093 expect(literal.rightBracket, isNotNull); | 5202 expect(literal.rightBracket, isNotNull); |
| 5094 } | 5203 } |
| 5095 | 5204 |
| 5096 void test_parseConstExpression_listLiteral_untyped() { | 5205 void test_parseConstExpression_listLiteral_untyped() { |
| 5097 Expression expression = parseConstExpression('const []'); | 5206 Expression expression = parseConstExpression('const []'); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 5113 expect(literal.leftBracket, isNotNull); | 5222 expect(literal.leftBracket, isNotNull); |
| 5114 expect(literal.entries, hasLength(0)); | 5223 expect(literal.entries, hasLength(0)); |
| 5115 expect(literal.rightBracket, isNotNull); | 5224 expect(literal.rightBracket, isNotNull); |
| 5116 expect(literal.typeArguments, isNotNull); | 5225 expect(literal.typeArguments, isNotNull); |
| 5117 } | 5226 } |
| 5118 | 5227 |
| 5119 void test_parseConstExpression_mapLiteral_typed_genericComment() { | 5228 void test_parseConstExpression_mapLiteral_typed_genericComment() { |
| 5120 enableGenericMethodComments = true; | 5229 enableGenericMethodComments = true; |
| 5121 Expression expression = parseConstExpression('const /*<A, B>*/ {}'); | 5230 Expression expression = parseConstExpression('const /*<A, B>*/ {}'); |
| 5122 expect(expression, isNotNull); | 5231 expect(expression, isNotNull); |
| 5123 assertNoErrors(); | 5232 if (usingFastaParser) { |
| 5233 assertNoErrors(); |
| 5234 } else { |
| 5235 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 5236 } |
| 5124 var literal = expression as MapLiteral; | 5237 var literal = expression as MapLiteral; |
| 5125 expect(literal.leftBracket, isNotNull); | 5238 expect(literal.leftBracket, isNotNull); |
| 5126 expect(literal.entries, hasLength(0)); | 5239 expect(literal.entries, hasLength(0)); |
| 5127 expect(literal.rightBracket, isNotNull); | 5240 expect(literal.rightBracket, isNotNull); |
| 5128 expect(literal.typeArguments, isNotNull); | 5241 expect(literal.typeArguments, isNotNull); |
| 5129 } | 5242 } |
| 5130 | 5243 |
| 5131 void test_parseConstExpression_mapLiteral_untyped() { | 5244 void test_parseConstExpression_mapLiteral_untyped() { |
| 5132 Expression expression = parseConstExpression('const {}'); | 5245 Expression expression = parseConstExpression('const {}'); |
| 5133 expect(expression, isNotNull); | 5246 expect(expression, isNotNull); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5250 Expression expression = parseExpression('super.m()'); | 5363 Expression expression = parseExpression('super.m()'); |
| 5251 var invocation = expression as MethodInvocation; | 5364 var invocation = expression as MethodInvocation; |
| 5252 expect(invocation.target, isNotNull); | 5365 expect(invocation.target, isNotNull); |
| 5253 expect(invocation.methodName, isNotNull); | 5366 expect(invocation.methodName, isNotNull); |
| 5254 expect(invocation.typeArguments, isNull); | 5367 expect(invocation.typeArguments, isNull); |
| 5255 expect(invocation.argumentList, isNotNull); | 5368 expect(invocation.argumentList, isNotNull); |
| 5256 } | 5369 } |
| 5257 | 5370 |
| 5258 void test_parseExpression_superMethodInvocation_typeArgumentComments() { | 5371 void test_parseExpression_superMethodInvocation_typeArgumentComments() { |
| 5259 enableGenericMethodComments = true; | 5372 enableGenericMethodComments = true; |
| 5260 Expression expression = parseExpression('super.m/*<E>*/()'); | 5373 Expression expression; |
| 5374 expression = parseExpression('super.m/*<E>*/()', |
| 5375 usingFastaParser ? [] : [HintCode.GENERIC_METHOD_COMMENT]); |
| 5261 var invocation = expression as MethodInvocation; | 5376 var invocation = expression as MethodInvocation; |
| 5262 expect(invocation.target, isNotNull); | 5377 expect(invocation.target, isNotNull); |
| 5263 expect(invocation.methodName, isNotNull); | 5378 expect(invocation.methodName, isNotNull); |
| 5264 expect(invocation.typeArguments, isNotNull); | 5379 expect(invocation.typeArguments, isNotNull); |
| 5265 expect(invocation.argumentList, isNotNull); | 5380 expect(invocation.argumentList, isNotNull); |
| 5266 } | 5381 } |
| 5267 | 5382 |
| 5268 void test_parseExpression_superMethodInvocation_typeArguments() { | 5383 void test_parseExpression_superMethodInvocation_typeArguments() { |
| 5269 Expression expression = parseExpression('super.m<E>()'); | 5384 Expression expression = parseExpression('super.m<E>()'); |
| 5270 var invocation = expression as MethodInvocation; | 5385 var invocation = expression as MethodInvocation; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5320 expect(invocation.methodName, isNotNull); | 5435 expect(invocation.methodName, isNotNull); |
| 5321 expect(invocation.typeArguments, isNull); | 5436 expect(invocation.typeArguments, isNull); |
| 5322 expect(invocation.argumentList, isNotNull); | 5437 expect(invocation.argumentList, isNotNull); |
| 5323 } | 5438 } |
| 5324 | 5439 |
| 5325 void | 5440 void |
| 5326 test_parseExpressionWithoutCascade_superMethodInvocation_typeArgumentComme
nts() { | 5441 test_parseExpressionWithoutCascade_superMethodInvocation_typeArgumentComme
nts() { |
| 5327 enableGenericMethodComments = true; | 5442 enableGenericMethodComments = true; |
| 5328 Expression expression = parseExpressionWithoutCascade('super.m/*<E>*/()'); | 5443 Expression expression = parseExpressionWithoutCascade('super.m/*<E>*/()'); |
| 5329 expect(expression, isNotNull); | 5444 expect(expression, isNotNull); |
| 5330 assertNoErrors(); | 5445 if (usingFastaParser) { |
| 5446 assertNoErrors(); |
| 5447 } else { |
| 5448 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 5449 } |
| 5331 var invocation = expression as MethodInvocation; | 5450 var invocation = expression as MethodInvocation; |
| 5332 expect(invocation.target, isNotNull); | 5451 expect(invocation.target, isNotNull); |
| 5333 expect(invocation.methodName, isNotNull); | 5452 expect(invocation.methodName, isNotNull); |
| 5334 expect(invocation.typeArguments, isNotNull); | 5453 expect(invocation.typeArguments, isNotNull); |
| 5335 expect(invocation.argumentList, isNotNull); | 5454 expect(invocation.argumentList, isNotNull); |
| 5336 } | 5455 } |
| 5337 | 5456 |
| 5338 void | 5457 void |
| 5339 test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { | 5458 test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { |
| 5340 Expression expression = parseExpressionWithoutCascade('super.m<E>()'); | 5459 Expression expression = parseExpressionWithoutCascade('super.m<E>()'); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5355 expect(expression.typeParameters, isNull); | 5474 expect(expression.typeParameters, isNull); |
| 5356 expect(expression.parameters, isNotNull); | 5475 expect(expression.parameters, isNotNull); |
| 5357 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 5476 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
| 5358 } | 5477 } |
| 5359 | 5478 |
| 5360 void test_parseFunctionExpression_typeParameterComments() { | 5479 void test_parseFunctionExpression_typeParameterComments() { |
| 5361 enableGenericMethodComments = true; | 5480 enableGenericMethodComments = true; |
| 5362 FunctionExpression expression = | 5481 FunctionExpression expression = |
| 5363 parseFunctionExpression('/*<E>*/(/*=E*/ i) => i++'); | 5482 parseFunctionExpression('/*<E>*/(/*=E*/ i) => i++'); |
| 5364 expect(expression, isNotNull); | 5483 expect(expression, isNotNull); |
| 5365 assertNoErrors(); | 5484 if (usingFastaParser) { |
| 5485 assertNoErrors(); |
| 5486 } else { |
| 5487 assertErrorsWithCodes( |
| 5488 [HintCode.GENERIC_METHOD_COMMENT, HintCode.GENERIC_METHOD_COMMENT]); |
| 5489 } |
| 5366 expect(expression.body, isNotNull); | 5490 expect(expression.body, isNotNull); |
| 5367 expect(expression.typeParameters, isNotNull); | 5491 expect(expression.typeParameters, isNotNull); |
| 5368 expect(expression.parameters, isNotNull); | 5492 expect(expression.parameters, isNotNull); |
| 5369 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 5493 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
| 5370 SimpleFormalParameter p = expression.parameters.parameters[0]; | 5494 SimpleFormalParameter p = expression.parameters.parameters[0]; |
| 5371 expect(p.type, isNotNull); | 5495 expect(p.type, isNotNull); |
| 5372 } | 5496 } |
| 5373 | 5497 |
| 5374 void test_parseFunctionExpression_typeParameters() { | 5498 void test_parseFunctionExpression_typeParameters() { |
| 5375 FunctionExpression expression = parseFunctionExpression('<E>(E i) => i++'); | 5499 FunctionExpression expression = parseFunctionExpression('<E>(E i) => i++'); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5415 expect(expression.argumentList, isNotNull); | 5539 expect(expression.argumentList, isNotNull); |
| 5416 } | 5540 } |
| 5417 | 5541 |
| 5418 void | 5542 void |
| 5419 test_parseInstanceCreationExpression_qualifiedType_named_typeArgumentComme
nts() { | 5543 test_parseInstanceCreationExpression_qualifiedType_named_typeArgumentComme
nts() { |
| 5420 enableGenericMethodComments = true; | 5544 enableGenericMethodComments = true; |
| 5421 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5545 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5422 InstanceCreationExpression expression = | 5546 InstanceCreationExpression expression = |
| 5423 parseInstanceCreationExpression('A.B/*<E>*/.c()', token); | 5547 parseInstanceCreationExpression('A.B/*<E>*/.c()', token); |
| 5424 expect(expression, isNotNull); | 5548 expect(expression, isNotNull); |
| 5425 assertNoErrors(); | 5549 if (usingFastaParser) { |
| 5550 assertNoErrors(); |
| 5551 } else { |
| 5552 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 5553 } |
| 5426 expect(expression.keyword.keyword, Keyword.NEW); | 5554 expect(expression.keyword.keyword, Keyword.NEW); |
| 5427 ConstructorName name = expression.constructorName; | 5555 ConstructorName name = expression.constructorName; |
| 5428 expect(name, isNotNull); | 5556 expect(name, isNotNull); |
| 5429 TypeName type = name.type; | 5557 TypeName type = name.type; |
| 5430 expect(type, isNotNull); | 5558 expect(type, isNotNull); |
| 5431 expect(type.typeArguments.arguments, hasLength(1)); | 5559 expect(type.typeArguments.arguments, hasLength(1)); |
| 5432 expect(name.period, isNotNull); | 5560 expect(name.period, isNotNull); |
| 5433 expect(name.name, isNotNull); | 5561 expect(name.name, isNotNull); |
| 5434 expect(expression.argumentList, isNotNull); | 5562 expect(expression.argumentList, isNotNull); |
| 5435 } | 5563 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 5452 expect(expression.argumentList, isNotNull); | 5580 expect(expression.argumentList, isNotNull); |
| 5453 } | 5581 } |
| 5454 | 5582 |
| 5455 void | 5583 void |
| 5456 test_parseInstanceCreationExpression_qualifiedType_typeArgumentComments()
{ | 5584 test_parseInstanceCreationExpression_qualifiedType_typeArgumentComments()
{ |
| 5457 enableGenericMethodComments = true; | 5585 enableGenericMethodComments = true; |
| 5458 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5586 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5459 InstanceCreationExpression expression = | 5587 InstanceCreationExpression expression = |
| 5460 parseInstanceCreationExpression('A.B/*<E>*/()', token); | 5588 parseInstanceCreationExpression('A.B/*<E>*/()', token); |
| 5461 expect(expression, isNotNull); | 5589 expect(expression, isNotNull); |
| 5462 assertNoErrors(); | 5590 if (usingFastaParser) { |
| 5591 assertNoErrors(); |
| 5592 } else { |
| 5593 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 5594 } |
| 5463 expect(expression.keyword.keyword, Keyword.NEW); | 5595 expect(expression.keyword.keyword, Keyword.NEW); |
| 5464 ConstructorName name = expression.constructorName; | 5596 ConstructorName name = expression.constructorName; |
| 5465 expect(name, isNotNull); | 5597 expect(name, isNotNull); |
| 5466 TypeName type = name.type; | 5598 TypeName type = name.type; |
| 5467 expect(type, isNotNull); | 5599 expect(type, isNotNull); |
| 5468 expect(type.typeArguments.arguments, hasLength(1)); | 5600 expect(type.typeArguments.arguments, hasLength(1)); |
| 5469 expect(name.period, isNull); | 5601 expect(name.period, isNull); |
| 5470 expect(name.name, isNull); | 5602 expect(name.name, isNull); |
| 5471 expect(expression.argumentList, isNotNull); | 5603 expect(expression.argumentList, isNotNull); |
| 5472 } | 5604 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5521 expect(name.name, isNull); | 5653 expect(name.name, isNull); |
| 5522 expect(expression.argumentList, isNotNull); | 5654 expect(expression.argumentList, isNotNull); |
| 5523 } | 5655 } |
| 5524 | 5656 |
| 5525 void test_parseInstanceCreationExpression_type_named_typeArgumentComments() { | 5657 void test_parseInstanceCreationExpression_type_named_typeArgumentComments() { |
| 5526 enableGenericMethodComments = true; | 5658 enableGenericMethodComments = true; |
| 5527 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5659 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5528 InstanceCreationExpression expression = | 5660 InstanceCreationExpression expression = |
| 5529 parseInstanceCreationExpression('A/*<B>*/.c()', token); | 5661 parseInstanceCreationExpression('A/*<B>*/.c()', token); |
| 5530 expect(expression, isNotNull); | 5662 expect(expression, isNotNull); |
| 5531 assertNoErrors(); | 5663 if (usingFastaParser) { |
| 5664 assertNoErrors(); |
| 5665 } else { |
| 5666 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 5667 } |
| 5532 expect(expression.keyword.keyword, Keyword.NEW); | 5668 expect(expression.keyword.keyword, Keyword.NEW); |
| 5533 ConstructorName name = expression.constructorName; | 5669 ConstructorName name = expression.constructorName; |
| 5534 expect(name, isNotNull); | 5670 expect(name, isNotNull); |
| 5535 TypeName type = name.type; | 5671 TypeName type = name.type; |
| 5536 expect(type, isNotNull); | 5672 expect(type, isNotNull); |
| 5537 expect(type.typeArguments.arguments, hasLength(1)); | 5673 expect(type.typeArguments.arguments, hasLength(1)); |
| 5538 expect(name.period, isNotNull); | 5674 expect(name.period, isNotNull); |
| 5539 expect(name.name, isNotNull); | 5675 expect(name.name, isNotNull); |
| 5540 expect(expression.argumentList, isNotNull); | 5676 expect(expression.argumentList, isNotNull); |
| 5541 } | 5677 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5556 expect(name.name, isNotNull); | 5692 expect(name.name, isNotNull); |
| 5557 expect(expression.argumentList, isNotNull); | 5693 expect(expression.argumentList, isNotNull); |
| 5558 } | 5694 } |
| 5559 | 5695 |
| 5560 void test_parseInstanceCreationExpression_type_typeArgumentComments() { | 5696 void test_parseInstanceCreationExpression_type_typeArgumentComments() { |
| 5561 enableGenericMethodComments = true; | 5697 enableGenericMethodComments = true; |
| 5562 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); | 5698 Token token = TokenFactory.tokenFromKeyword(Keyword.NEW); |
| 5563 InstanceCreationExpression expression = | 5699 InstanceCreationExpression expression = |
| 5564 parseInstanceCreationExpression('A/*<B>*/()', token); | 5700 parseInstanceCreationExpression('A/*<B>*/()', token); |
| 5565 expect(expression, isNotNull); | 5701 expect(expression, isNotNull); |
| 5566 assertNoErrors(); | 5702 |
| 5703 if (usingFastaParser) { |
| 5704 assertNoErrors(); |
| 5705 } else { |
| 5706 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 5707 } |
| 5567 expect(expression.keyword.keyword, Keyword.NEW); | 5708 expect(expression.keyword.keyword, Keyword.NEW); |
| 5568 ConstructorName name = expression.constructorName; | 5709 ConstructorName name = expression.constructorName; |
| 5569 expect(name, isNotNull); | 5710 expect(name, isNotNull); |
| 5570 TypeName type = name.type; | 5711 TypeName type = name.type; |
| 5571 expect(type, isNotNull); | 5712 expect(type, isNotNull); |
| 5572 expect(type.typeArguments.arguments, hasLength(1)); | 5713 expect(type.typeArguments.arguments, hasLength(1)); |
| 5573 expect(name.period, isNull); | 5714 expect(name.period, isNull); |
| 5574 expect(name.name, isNull); | 5715 expect(name.name, isNull); |
| 5575 expect(expression.argumentList, isNotNull); | 5716 expect(expression.argumentList, isNotNull); |
| 5576 } | 5717 } |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5896 expect(methodInvocation.methodName, isNotNull); | 6037 expect(methodInvocation.methodName, isNotNull); |
| 5897 expect(methodInvocation.typeArguments, isNull); | 6038 expect(methodInvocation.typeArguments, isNull); |
| 5898 expect(methodInvocation.argumentList, isNotNull); | 6039 expect(methodInvocation.argumentList, isNotNull); |
| 5899 } | 6040 } |
| 5900 | 6041 |
| 5901 void | 6042 void |
| 5902 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
tComments() { | 6043 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
tComments() { |
| 5903 enableGenericMethodComments = true; | 6044 enableGenericMethodComments = true; |
| 5904 Expression expression = parsePostfixExpression('a?.m/*<E>*/()'); | 6045 Expression expression = parsePostfixExpression('a?.m/*<E>*/()'); |
| 5905 expect(expression, isNotNull); | 6046 expect(expression, isNotNull); |
| 5906 assertNoErrors(); | 6047 if (usingFastaParser) { |
| 6048 assertNoErrors(); |
| 6049 } else { |
| 6050 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 6051 } |
| 5907 var methodInvocation = expression as MethodInvocation; | 6052 var methodInvocation = expression as MethodInvocation; |
| 5908 expect(methodInvocation.target, isNotNull); | 6053 expect(methodInvocation.target, isNotNull); |
| 5909 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 6054 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
| 5910 expect(methodInvocation.methodName, isNotNull); | 6055 expect(methodInvocation.methodName, isNotNull); |
| 5911 expect(methodInvocation.typeArguments, isNotNull); | 6056 expect(methodInvocation.typeArguments, isNotNull); |
| 5912 expect(methodInvocation.argumentList, isNotNull); | 6057 expect(methodInvocation.argumentList, isNotNull); |
| 5913 } | 6058 } |
| 5914 | 6059 |
| 5915 void | 6060 void |
| 5916 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
ts() { | 6061 test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgumen
ts() { |
| 5917 Expression expression = parsePostfixExpression('a?.m<E>()'); | 6062 Expression expression = parsePostfixExpression('a?.m<E>()'); |
| 5918 expect(expression, isNotNull); | 6063 expect(expression, isNotNull); |
| 5919 assertNoErrors(); | 6064 assertNoErrors(); |
| 5920 var methodInvocation = expression as MethodInvocation; | 6065 var methodInvocation = expression as MethodInvocation; |
| 5921 expect(methodInvocation.target, isNotNull); | 6066 expect(methodInvocation.target, isNotNull); |
| 5922 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); | 6067 expect(methodInvocation.operator.type, TokenType.QUESTION_PERIOD); |
| 5923 expect(methodInvocation.methodName, isNotNull); | 6068 expect(methodInvocation.methodName, isNotNull); |
| 5924 expect(methodInvocation.typeArguments, isNotNull); | 6069 expect(methodInvocation.typeArguments, isNotNull); |
| 5925 expect(methodInvocation.argumentList, isNotNull); | 6070 expect(methodInvocation.argumentList, isNotNull); |
| 5926 } | 6071 } |
| 5927 | 6072 |
| 5928 void | 6073 void |
| 5929 test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() { | 6074 test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() { |
| 5930 enableGenericMethodComments = true; | 6075 enableGenericMethodComments = true; |
| 5931 Expression expression = parsePostfixExpression('a.m/*<E>*/()'); | 6076 Expression expression = parsePostfixExpression('a.m/*<E>*/()'); |
| 5932 expect(expression, isNotNull); | 6077 expect(expression, isNotNull); |
| 5933 assertNoErrors(); | 6078 if (usingFastaParser) { |
| 6079 assertNoErrors(); |
| 6080 } else { |
| 6081 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 6082 } |
| 5934 var methodInvocation = expression as MethodInvocation; | 6083 var methodInvocation = expression as MethodInvocation; |
| 5935 expect(methodInvocation.target, isNotNull); | 6084 expect(methodInvocation.target, isNotNull); |
| 5936 expect(methodInvocation.operator.type, TokenType.PERIOD); | 6085 expect(methodInvocation.operator.type, TokenType.PERIOD); |
| 5937 expect(methodInvocation.methodName, isNotNull); | 6086 expect(methodInvocation.methodName, isNotNull); |
| 5938 expect(methodInvocation.typeArguments, isNotNull); | 6087 expect(methodInvocation.typeArguments, isNotNull); |
| 5939 expect(methodInvocation.argumentList, isNotNull); | 6088 expect(methodInvocation.argumentList, isNotNull); |
| 5940 } | 6089 } |
| 5941 | 6090 |
| 5942 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { | 6091 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { |
| 5943 Expression expression = parsePostfixExpression('a.m<E>()'); | 6092 Expression expression = parsePostfixExpression('a.m<E>()'); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6084 assertNoErrors(); | 6233 assertNoErrors(); |
| 6085 var literal = expression as ListLiteral; | 6234 var literal = expression as ListLiteral; |
| 6086 expect(literal.typeArguments, isNotNull); | 6235 expect(literal.typeArguments, isNotNull); |
| 6087 expect(literal.typeArguments.arguments, hasLength(1)); | 6236 expect(literal.typeArguments.arguments, hasLength(1)); |
| 6088 } | 6237 } |
| 6089 | 6238 |
| 6090 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { | 6239 void test_parsePrimaryExpression_listLiteral_typed_genericComment() { |
| 6091 enableGenericMethodComments = true; | 6240 enableGenericMethodComments = true; |
| 6092 Expression expression = parsePrimaryExpression('/*<A>*/[ ]'); | 6241 Expression expression = parsePrimaryExpression('/*<A>*/[ ]'); |
| 6093 expect(expression, isNotNull); | 6242 expect(expression, isNotNull); |
| 6094 assertNoErrors(); | 6243 if (usingFastaParser) { |
| 6244 assertNoErrors(); |
| 6245 } else { |
| 6246 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 6247 } |
| 6095 var literal = expression as ListLiteral; | 6248 var literal = expression as ListLiteral; |
| 6096 expect(literal.typeArguments, isNotNull); | 6249 expect(literal.typeArguments, isNotNull); |
| 6097 expect(literal.typeArguments.arguments, hasLength(1)); | 6250 expect(literal.typeArguments.arguments, hasLength(1)); |
| 6098 } | 6251 } |
| 6099 | 6252 |
| 6100 void test_parsePrimaryExpression_mapLiteral() { | 6253 void test_parsePrimaryExpression_mapLiteral() { |
| 6101 Expression expression = parsePrimaryExpression('{}'); | 6254 Expression expression = parsePrimaryExpression('{}'); |
| 6102 expect(expression, isNotNull); | 6255 expect(expression, isNotNull); |
| 6103 assertNoErrors(); | 6256 assertNoErrors(); |
| 6104 var literal = expression as MapLiteral; | 6257 var literal = expression as MapLiteral; |
| 6105 expect(literal.typeArguments, isNull); | 6258 expect(literal.typeArguments, isNull); |
| 6106 expect(literal, isNotNull); | 6259 expect(literal, isNotNull); |
| 6107 } | 6260 } |
| 6108 | 6261 |
| 6109 void test_parsePrimaryExpression_mapLiteral_typed() { | 6262 void test_parsePrimaryExpression_mapLiteral_typed() { |
| 6110 Expression expression = parsePrimaryExpression('<A, B>{}'); | 6263 Expression expression = parsePrimaryExpression('<A, B>{}'); |
| 6111 expect(expression, isNotNull); | 6264 expect(expression, isNotNull); |
| 6112 assertNoErrors(); | 6265 assertNoErrors(); |
| 6113 var literal = expression as MapLiteral; | 6266 var literal = expression as MapLiteral; |
| 6114 expect(literal.typeArguments, isNotNull); | 6267 expect(literal.typeArguments, isNotNull); |
| 6115 expect(literal.typeArguments.arguments, hasLength(2)); | 6268 expect(literal.typeArguments.arguments, hasLength(2)); |
| 6116 } | 6269 } |
| 6117 | 6270 |
| 6118 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { | 6271 void test_parsePrimaryExpression_mapLiteral_typed_genericComment() { |
| 6119 enableGenericMethodComments = true; | 6272 enableGenericMethodComments = true; |
| 6120 Expression expression = parsePrimaryExpression('/*<A, B>*/{}'); | 6273 Expression expression = parsePrimaryExpression('/*<A, B>*/{}'); |
| 6121 expect(expression, isNotNull); | 6274 expect(expression, isNotNull); |
| 6122 assertNoErrors(); | 6275 if (usingFastaParser) { |
| 6276 assertNoErrors(); |
| 6277 } else { |
| 6278 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 6279 } |
| 6123 var literal = expression as MapLiteral; | 6280 var literal = expression as MapLiteral; |
| 6124 expect(literal.typeArguments, isNotNull); | 6281 expect(literal.typeArguments, isNotNull); |
| 6125 expect(literal.typeArguments.arguments, hasLength(2)); | 6282 expect(literal.typeArguments.arguments, hasLength(2)); |
| 6126 } | 6283 } |
| 6127 | 6284 |
| 6128 void test_parsePrimaryExpression_new() { | 6285 void test_parsePrimaryExpression_new() { |
| 6129 Expression expression = parsePrimaryExpression('new A()'); | 6286 Expression expression = parsePrimaryExpression('new A()'); |
| 6130 expect(expression, isNotNull); | 6287 expect(expression, isNotNull); |
| 6131 assertNoErrors(); | 6288 assertNoErrors(); |
| 6132 var creation = expression as InstanceCreationExpression; | 6289 var creation = expression as InstanceCreationExpression; |
| (...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7789 FunctionTypedFormalParameter functionParameter = parameter; | 7946 FunctionTypedFormalParameter functionParameter = parameter; |
| 7790 expect(functionParameter.returnType, isNull); | 7947 expect(functionParameter.returnType, isNull); |
| 7791 expect(functionParameter.identifier, isNotNull); | 7948 expect(functionParameter.identifier, isNotNull); |
| 7792 expect(functionParameter.typeParameters, isNull); | 7949 expect(functionParameter.typeParameters, isNull); |
| 7793 expect(functionParameter.parameters, isNotNull); | 7950 expect(functionParameter.parameters, isNotNull); |
| 7794 expect(functionParameter.question, isNotNull); | 7951 expect(functionParameter.question, isNotNull); |
| 7795 } | 7952 } |
| 7796 | 7953 |
| 7797 void test_parseNormalFormalParameter_function_noType_typeParameterComments() { | 7954 void test_parseNormalFormalParameter_function_noType_typeParameterComments() { |
| 7798 enableGenericMethodComments = true; | 7955 enableGenericMethodComments = true; |
| 7799 NormalFormalParameter parameter = parseNormalFormalParameter('a/*<E>*/()'); | 7956 NormalFormalParameter parameter = parseNormalFormalParameter('a/*<E>*/()', |
| 7957 errorCodes: usingFastaParser ? [] : [HintCode.GENERIC_METHOD_COMMENT]); |
| 7800 expect(parameter, isNotNull); | 7958 expect(parameter, isNotNull); |
| 7801 assertNoErrors(); | |
| 7802 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 7959 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
| 7803 FunctionTypedFormalParameter functionParameter = parameter; | 7960 FunctionTypedFormalParameter functionParameter = parameter; |
| 7804 expect(functionParameter.returnType, isNull); | 7961 expect(functionParameter.returnType, isNull); |
| 7805 expect(functionParameter.identifier, isNotNull); | 7962 expect(functionParameter.identifier, isNotNull); |
| 7806 expect(functionParameter.typeParameters, isNotNull); | 7963 expect(functionParameter.typeParameters, isNotNull); |
| 7807 expect(functionParameter.parameters, isNotNull); | 7964 expect(functionParameter.parameters, isNotNull); |
| 7808 } | 7965 } |
| 7809 | 7966 |
| 7810 void test_parseNormalFormalParameter_function_noType_typeParameters() { | 7967 void test_parseNormalFormalParameter_function_noType_typeParameters() { |
| 7811 NormalFormalParameter parameter = parseNormalFormalParameter('a<E>()'); | 7968 NormalFormalParameter parameter = parseNormalFormalParameter('a<E>()'); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7858 FunctionTypedFormalParameter functionParameter = parameter; | 8015 FunctionTypedFormalParameter functionParameter = parameter; |
| 7859 expect(functionParameter.returnType, isNotNull); | 8016 expect(functionParameter.returnType, isNotNull); |
| 7860 expect(functionParameter.identifier, isNotNull); | 8017 expect(functionParameter.identifier, isNotNull); |
| 7861 expect(functionParameter.typeParameters, isNull); | 8018 expect(functionParameter.typeParameters, isNull); |
| 7862 expect(functionParameter.parameters, isNotNull); | 8019 expect(functionParameter.parameters, isNotNull); |
| 7863 expect(functionParameter.question, isNotNull); | 8020 expect(functionParameter.question, isNotNull); |
| 7864 } | 8021 } |
| 7865 | 8022 |
| 7866 void test_parseNormalFormalParameter_function_type_typeParameterComments() { | 8023 void test_parseNormalFormalParameter_function_type_typeParameterComments() { |
| 7867 enableGenericMethodComments = true; | 8024 enableGenericMethodComments = true; |
| 7868 NormalFormalParameter parameter = | 8025 NormalFormalParameter parameter = parseNormalFormalParameter('A a/*<E>*/()', |
| 7869 parseNormalFormalParameter('A a/*<E>*/()'); | 8026 errorCodes: usingFastaParser ? [] : [HintCode.GENERIC_METHOD_COMMENT]); |
| 7870 expect(parameter, isNotNull); | 8027 expect(parameter, isNotNull); |
| 7871 assertNoErrors(); | |
| 7872 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 8028 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
| 7873 FunctionTypedFormalParameter functionParameter = parameter; | 8029 FunctionTypedFormalParameter functionParameter = parameter; |
| 7874 expect(functionParameter.returnType, isNotNull); | 8030 expect(functionParameter.returnType, isNotNull); |
| 7875 expect(functionParameter.identifier, isNotNull); | 8031 expect(functionParameter.identifier, isNotNull); |
| 7876 expect(functionParameter.typeParameters, isNotNull); | 8032 expect(functionParameter.typeParameters, isNotNull); |
| 7877 expect(functionParameter.parameters, isNotNull); | 8033 expect(functionParameter.parameters, isNotNull); |
| 7878 expect(functionParameter.question, isNull); | 8034 expect(functionParameter.question, isNull); |
| 7879 } | 8035 } |
| 7880 | 8036 |
| 7881 void test_parseNormalFormalParameter_function_type_typeParameters() { | 8037 void test_parseNormalFormalParameter_function_type_typeParameters() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7927 FunctionTypedFormalParameter functionParameter = parameter; | 8083 FunctionTypedFormalParameter functionParameter = parameter; |
| 7928 expect(functionParameter.returnType, isNotNull); | 8084 expect(functionParameter.returnType, isNotNull); |
| 7929 expect(functionParameter.identifier, isNotNull); | 8085 expect(functionParameter.identifier, isNotNull); |
| 7930 expect(functionParameter.typeParameters, isNull); | 8086 expect(functionParameter.typeParameters, isNull); |
| 7931 expect(functionParameter.parameters, isNotNull); | 8087 expect(functionParameter.parameters, isNotNull); |
| 7932 expect(functionParameter.question, isNotNull); | 8088 expect(functionParameter.question, isNotNull); |
| 7933 } | 8089 } |
| 7934 | 8090 |
| 7935 void test_parseNormalFormalParameter_function_void_typeParameterComments() { | 8091 void test_parseNormalFormalParameter_function_void_typeParameterComments() { |
| 7936 enableGenericMethodComments = true; | 8092 enableGenericMethodComments = true; |
| 7937 NormalFormalParameter parameter = | 8093 NormalFormalParameter parameter = parseNormalFormalParameter( |
| 7938 parseNormalFormalParameter('void a/*<E>*/()'); | 8094 'void a/*<E>*/()', |
| 8095 errorCodes: usingFastaParser ? [] : [HintCode.GENERIC_METHOD_COMMENT]); |
| 7939 expect(parameter, isNotNull); | 8096 expect(parameter, isNotNull); |
| 7940 assertNoErrors(); | |
| 7941 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); | 8097 expect(parameter, new isInstanceOf<FunctionTypedFormalParameter>()); |
| 7942 FunctionTypedFormalParameter functionParameter = parameter; | 8098 FunctionTypedFormalParameter functionParameter = parameter; |
| 7943 expect(functionParameter.returnType, isNotNull); | 8099 expect(functionParameter.returnType, isNotNull); |
| 7944 expect(functionParameter.identifier, isNotNull); | 8100 expect(functionParameter.identifier, isNotNull); |
| 7945 expect(functionParameter.typeParameters, isNotNull); | 8101 expect(functionParameter.typeParameters, isNotNull); |
| 7946 expect(functionParameter.parameters, isNotNull); | 8102 expect(functionParameter.parameters, isNotNull); |
| 7947 expect(functionParameter.question, isNull); | 8103 expect(functionParameter.question, isNull); |
| 7948 } | 8104 } |
| 7949 | 8105 |
| 7950 void test_parseNormalFormalParameter_function_void_typeParameters() { | 8106 void test_parseNormalFormalParameter_function_void_typeParameters() { |
| (...skipping 3252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11203 | 11359 |
| 11204 void test_parseFinalConstVarOrType_void() { | 11360 void test_parseFinalConstVarOrType_void() { |
| 11205 createParser('void f()'); | 11361 createParser('void f()'); |
| 11206 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); | 11362 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); |
| 11207 expectNotNullIfNoErrors(result); | 11363 expectNotNullIfNoErrors(result); |
| 11208 listener.assertNoErrors(); | 11364 listener.assertNoErrors(); |
| 11209 expect(result.keyword, isNull); | 11365 expect(result.keyword, isNull); |
| 11210 expect(result.type, isNotNull); | 11366 expect(result.type, isNotNull); |
| 11211 } | 11367 } |
| 11212 | 11368 |
| 11213 void test_parseFinalConstVarOrType_void_noIdentifier() { | |
| 11214 createParser('void,'); | |
| 11215 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); | |
| 11216 expectNotNullIfNoErrors(result); | |
| 11217 listener.assertErrorsWithCodes( | |
| 11218 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); | |
| 11219 } | |
| 11220 | |
| 11221 void test_parseFinalConstVarOrType_void_identifier() { | 11369 void test_parseFinalConstVarOrType_void_identifier() { |
| 11222 createParser('void x'); | 11370 createParser('void x'); |
| 11223 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); | 11371 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); |
| 11224 expectNotNullIfNoErrors(result); | 11372 expectNotNullIfNoErrors(result); |
| 11225 listener.assertNoErrors(); | 11373 listener.assertNoErrors(); |
| 11226 expect(result.keyword, isNull); | 11374 expect(result.keyword, isNull); |
| 11227 expect(result.type, isNotNull); | 11375 expect(result.type, isNotNull); |
| 11228 } | 11376 } |
| 11229 | 11377 |
| 11378 void test_parseFinalConstVarOrType_void_noIdentifier() { |
| 11379 createParser('void,'); |
| 11380 FinalConstVarOrType result = parser.parseFinalConstVarOrType(false); |
| 11381 expectNotNullIfNoErrors(result); |
| 11382 listener.assertErrorsWithCodes( |
| 11383 [ParserErrorCode.MISSING_CONST_FINAL_VAR_OR_TYPE]); |
| 11384 } |
| 11385 |
| 11230 void test_parseFunctionBody_block() { | 11386 void test_parseFunctionBody_block() { |
| 11231 createParser('{}'); | 11387 createParser('{}'); |
| 11232 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | 11388 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
| 11233 expectNotNullIfNoErrors(functionBody); | 11389 expectNotNullIfNoErrors(functionBody); |
| 11234 listener.assertNoErrors(); | 11390 listener.assertNoErrors(); |
| 11235 expect(functionBody, new isInstanceOf<BlockFunctionBody>()); | 11391 expect(functionBody, new isInstanceOf<BlockFunctionBody>()); |
| 11236 BlockFunctionBody body = functionBody; | 11392 BlockFunctionBody body = functionBody; |
| 11237 expect(body.keyword, isNull); | 11393 expect(body.keyword, isNull); |
| 11238 expect(body.star, isNull); | 11394 expect(body.star, isNull); |
| 11239 expect(body.block, isNotNull); | 11395 expect(body.block, isNotNull); |
| (...skipping 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12627 var statement = parseStatement('void f(int p) => p * 2;') | 12783 var statement = parseStatement('void f(int p) => p * 2;') |
| 12628 as FunctionDeclarationStatement; | 12784 as FunctionDeclarationStatement; |
| 12629 assertNoErrors(); | 12785 assertNoErrors(); |
| 12630 expect(statement.functionDeclaration, isNotNull); | 12786 expect(statement.functionDeclaration, isNotNull); |
| 12631 } | 12787 } |
| 12632 | 12788 |
| 12633 void test_parseFunctionDeclarationStatement_typeParameterComments() { | 12789 void test_parseFunctionDeclarationStatement_typeParameterComments() { |
| 12634 enableGenericMethodComments = true; | 12790 enableGenericMethodComments = true; |
| 12635 var statement = parseStatement('/*=E*/ f/*<E>*/(/*=E*/ p) => p * 2;') | 12791 var statement = parseStatement('/*=E*/ f/*<E>*/(/*=E*/ p) => p * 2;') |
| 12636 as FunctionDeclarationStatement; | 12792 as FunctionDeclarationStatement; |
| 12637 assertNoErrors(); | 12793 if (usingFastaParser) { |
| 12794 assertNoErrors(); |
| 12795 } else { |
| 12796 assertErrorsWithCodes([ |
| 12797 HintCode.GENERIC_METHOD_COMMENT, |
| 12798 HintCode.GENERIC_METHOD_COMMENT, |
| 12799 HintCode.GENERIC_METHOD_COMMENT |
| 12800 ]); |
| 12801 } |
| 12638 FunctionDeclaration f = statement.functionDeclaration; | 12802 FunctionDeclaration f = statement.functionDeclaration; |
| 12639 expect(f, isNotNull); | 12803 expect(f, isNotNull); |
| 12640 expect(f.functionExpression.typeParameters, isNotNull); | 12804 expect(f.functionExpression.typeParameters, isNotNull); |
| 12641 expect(f.returnType, isNotNull); | 12805 expect(f.returnType, isNotNull); |
| 12642 SimpleFormalParameter p = f.functionExpression.parameters.parameters[0]; | 12806 SimpleFormalParameter p = f.functionExpression.parameters.parameters[0]; |
| 12643 expect(p.type, isNotNull); | 12807 expect(p.type, isNotNull); |
| 12644 } | 12808 } |
| 12645 | 12809 |
| 12646 void test_parseFunctionDeclarationStatement_typeParameters() { | 12810 void test_parseFunctionDeclarationStatement_typeParameters() { |
| 12647 var statement = | 12811 var statement = |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12948 var statement = parseStatement('true;') as ExpressionStatement; | 13112 var statement = parseStatement('true;') as ExpressionStatement; |
| 12949 assertNoErrors(); | 13113 assertNoErrors(); |
| 12950 expect(statement.expression, isNotNull); | 13114 expect(statement.expression, isNotNull); |
| 12951 } | 13115 } |
| 12952 | 13116 |
| 12953 void | 13117 void |
| 12954 test_parseStatement_functionDeclaration_noReturnType_typeParameterComments
() { | 13118 test_parseStatement_functionDeclaration_noReturnType_typeParameterComments
() { |
| 12955 enableGenericMethodComments = true; | 13119 enableGenericMethodComments = true; |
| 12956 var statement = | 13120 var statement = |
| 12957 parseStatement('f/*<E>*/(a, b) {}') as FunctionDeclarationStatement; | 13121 parseStatement('f/*<E>*/(a, b) {}') as FunctionDeclarationStatement; |
| 12958 assertNoErrors(); | 13122 if (usingFastaParser) { |
| 13123 assertNoErrors(); |
| 13124 } else { |
| 13125 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 13126 } |
| 12959 expect(statement.functionDeclaration, isNotNull); | 13127 expect(statement.functionDeclaration, isNotNull); |
| 12960 expect(statement.functionDeclaration.functionExpression.typeParameters, | 13128 expect(statement.functionDeclaration.functionExpression.typeParameters, |
| 12961 isNotNull); | 13129 isNotNull); |
| 12962 } | 13130 } |
| 12963 | 13131 |
| 12964 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() { | 13132 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() { |
| 12965 var statement = | 13133 var statement = |
| 12966 parseStatement('f<E>(a, b) {}') as FunctionDeclarationStatement; | 13134 parseStatement('f<E>(a, b) {}') as FunctionDeclarationStatement; |
| 12967 assertNoErrors(); | 13135 assertNoErrors(); |
| 12968 expect(statement.functionDeclaration, isNotNull); | 13136 expect(statement.functionDeclaration, isNotNull); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13214 var declarationList = parseVariableDeclarationList('const A a'); | 13382 var declarationList = parseVariableDeclarationList('const A a'); |
| 13215 assertNoErrors(); | 13383 assertNoErrors(); |
| 13216 expect(declarationList.keyword.lexeme, 'const'); | 13384 expect(declarationList.keyword.lexeme, 'const'); |
| 13217 expect(declarationList.type, isNotNull); | 13385 expect(declarationList.type, isNotNull); |
| 13218 expect(declarationList.variables, hasLength(1)); | 13386 expect(declarationList.variables, hasLength(1)); |
| 13219 } | 13387 } |
| 13220 | 13388 |
| 13221 void test_parseVariableDeclarationListAfterMetadata_const_typeComment() { | 13389 void test_parseVariableDeclarationListAfterMetadata_const_typeComment() { |
| 13222 enableGenericMethodComments = true; | 13390 enableGenericMethodComments = true; |
| 13223 var declarationList = parseVariableDeclarationList('const/*=T*/ a'); | 13391 var declarationList = parseVariableDeclarationList('const/*=T*/ a'); |
| 13224 assertNoErrors(); | 13392 if (usingFastaParser) { |
| 13393 assertNoErrors(); |
| 13394 } else { |
| 13395 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 13396 } |
| 13225 expect((declarationList.type as TypeName).name.name, 'T'); | 13397 expect((declarationList.type as TypeName).name.name, 'T'); |
| 13226 expect(declarationList.isConst, true); | 13398 expect(declarationList.isConst, true); |
| 13227 } | 13399 } |
| 13228 | 13400 |
| 13229 void test_parseVariableDeclarationListAfterMetadata_dynamic_typeComment() { | 13401 void test_parseVariableDeclarationListAfterMetadata_dynamic_typeComment() { |
| 13230 enableGenericMethodComments = true; | 13402 enableGenericMethodComments = true; |
| 13231 var declarationList = parseVariableDeclarationList('dynamic/*=T*/ a'); | 13403 var declarationList = parseVariableDeclarationList('dynamic/*=T*/ a'); |
| 13232 assertNoErrors(); | 13404 if (usingFastaParser) { |
| 13405 assertNoErrors(); |
| 13406 } else { |
| 13407 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 13408 } |
| 13233 expect((declarationList.type as TypeName).name.name, 'T'); | 13409 expect((declarationList.type as TypeName).name.name, 'T'); |
| 13234 expect(declarationList.keyword, isNull); | 13410 expect(declarationList.keyword, isNull); |
| 13235 } | 13411 } |
| 13236 | 13412 |
| 13237 void test_parseVariableDeclarationListAfterMetadata_final_noType() { | 13413 void test_parseVariableDeclarationListAfterMetadata_final_noType() { |
| 13238 var declarationList = parseVariableDeclarationList('final a'); | 13414 var declarationList = parseVariableDeclarationList('final a'); |
| 13239 assertNoErrors(); | 13415 assertNoErrors(); |
| 13240 expect(declarationList.keyword, isNotNull); | 13416 expect(declarationList.keyword, isNotNull); |
| 13241 expect(declarationList.type, isNull); | 13417 expect(declarationList.type, isNull); |
| 13242 expect(declarationList.variables, hasLength(1)); | 13418 expect(declarationList.variables, hasLength(1)); |
| 13243 } | 13419 } |
| 13244 | 13420 |
| 13245 void test_parseVariableDeclarationListAfterMetadata_final_type() { | 13421 void test_parseVariableDeclarationListAfterMetadata_final_type() { |
| 13246 var declarationList = parseVariableDeclarationList('final A a'); | 13422 var declarationList = parseVariableDeclarationList('final A a'); |
| 13247 assertNoErrors(); | 13423 assertNoErrors(); |
| 13248 expect(declarationList.keyword.lexeme, 'final'); | 13424 expect(declarationList.keyword.lexeme, 'final'); |
| 13249 expect(declarationList.type, isNotNull); | 13425 expect(declarationList.type, isNotNull); |
| 13250 expect(declarationList.variables, hasLength(1)); | 13426 expect(declarationList.variables, hasLength(1)); |
| 13251 } | 13427 } |
| 13252 | 13428 |
| 13253 void test_parseVariableDeclarationListAfterMetadata_final_typeComment() { | 13429 void test_parseVariableDeclarationListAfterMetadata_final_typeComment() { |
| 13254 enableGenericMethodComments = true; | 13430 enableGenericMethodComments = true; |
| 13255 var declarationList = parseVariableDeclarationList('final/*=T*/ a'); | 13431 var declarationList = parseVariableDeclarationList('final/*=T*/ a'); |
| 13256 assertNoErrors(); | 13432 if (usingFastaParser) { |
| 13433 assertNoErrors(); |
| 13434 } else { |
| 13435 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 13436 } |
| 13257 expect((declarationList.type as TypeName).name.name, 'T'); | 13437 expect((declarationList.type as TypeName).name.name, 'T'); |
| 13258 expect(declarationList.isFinal, true); | 13438 expect(declarationList.isFinal, true); |
| 13259 } | 13439 } |
| 13260 | 13440 |
| 13261 void test_parseVariableDeclarationListAfterMetadata_type_multiple() { | 13441 void test_parseVariableDeclarationListAfterMetadata_type_multiple() { |
| 13262 var declarationList = parseVariableDeclarationList('A a, b, c'); | 13442 var declarationList = parseVariableDeclarationList('A a, b, c'); |
| 13263 assertNoErrors(); | 13443 assertNoErrors(); |
| 13264 expect(declarationList.keyword, isNull); | 13444 expect(declarationList.keyword, isNull); |
| 13265 expect(declarationList.type, isNotNull); | 13445 expect(declarationList.type, isNotNull); |
| 13266 expect(declarationList.variables, hasLength(3)); | 13446 expect(declarationList.variables, hasLength(3)); |
| 13267 } | 13447 } |
| 13268 | 13448 |
| 13269 void test_parseVariableDeclarationListAfterMetadata_type_single() { | 13449 void test_parseVariableDeclarationListAfterMetadata_type_single() { |
| 13270 var declarationList = parseVariableDeclarationList('A a'); | 13450 var declarationList = parseVariableDeclarationList('A a'); |
| 13271 assertNoErrors(); | 13451 assertNoErrors(); |
| 13272 expect(declarationList.keyword, isNull); | 13452 expect(declarationList.keyword, isNull); |
| 13273 expect(declarationList.type, isNotNull); | 13453 expect(declarationList.type, isNotNull); |
| 13274 expect(declarationList.variables, hasLength(1)); | 13454 expect(declarationList.variables, hasLength(1)); |
| 13275 } | 13455 } |
| 13276 | 13456 |
| 13277 void test_parseVariableDeclarationListAfterMetadata_type_typeComment() { | 13457 void test_parseVariableDeclarationListAfterMetadata_type_typeComment() { |
| 13278 enableGenericMethodComments = true; | 13458 enableGenericMethodComments = true; |
| 13279 var declarationList = parseVariableDeclarationList('int/*=T*/ a'); | 13459 var declarationList = parseVariableDeclarationList('int/*=T*/ a'); |
| 13280 assertNoErrors(); | 13460 if (usingFastaParser) { |
| 13461 assertNoErrors(); |
| 13462 } else { |
| 13463 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 13464 } |
| 13281 expect((declarationList.type as TypeName).name.name, 'T'); | 13465 expect((declarationList.type as TypeName).name.name, 'T'); |
| 13282 expect(declarationList.keyword, isNull); | 13466 expect(declarationList.keyword, isNull); |
| 13283 } | 13467 } |
| 13284 | 13468 |
| 13285 void test_parseVariableDeclarationListAfterMetadata_var_multiple() { | 13469 void test_parseVariableDeclarationListAfterMetadata_var_multiple() { |
| 13286 var declarationList = parseVariableDeclarationList('var a, b, c'); | 13470 var declarationList = parseVariableDeclarationList('var a, b, c'); |
| 13287 assertNoErrors(); | 13471 assertNoErrors(); |
| 13288 expect(declarationList.keyword.lexeme, 'var'); | 13472 expect(declarationList.keyword.lexeme, 'var'); |
| 13289 expect(declarationList.type, isNull); | 13473 expect(declarationList.type, isNull); |
| 13290 expect(declarationList.variables, hasLength(3)); | 13474 expect(declarationList.variables, hasLength(3)); |
| 13291 } | 13475 } |
| 13292 | 13476 |
| 13293 void test_parseVariableDeclarationListAfterMetadata_var_single() { | 13477 void test_parseVariableDeclarationListAfterMetadata_var_single() { |
| 13294 var declarationList = parseVariableDeclarationList('var a'); | 13478 var declarationList = parseVariableDeclarationList('var a'); |
| 13295 assertNoErrors(); | 13479 assertNoErrors(); |
| 13296 expect(declarationList.keyword.lexeme, 'var'); | 13480 expect(declarationList.keyword.lexeme, 'var'); |
| 13297 expect(declarationList.type, isNull); | 13481 expect(declarationList.type, isNull); |
| 13298 expect(declarationList.variables, hasLength(1)); | 13482 expect(declarationList.variables, hasLength(1)); |
| 13299 } | 13483 } |
| 13300 | 13484 |
| 13301 void test_parseVariableDeclarationListAfterMetadata_var_typeComment() { | 13485 void test_parseVariableDeclarationListAfterMetadata_var_typeComment() { |
| 13302 enableGenericMethodComments = true; | 13486 enableGenericMethodComments = true; |
| 13303 var declarationList = parseVariableDeclarationList('var/*=T*/ a'); | 13487 var declarationList = parseVariableDeclarationList('var/*=T*/ a'); |
| 13304 assertNoErrors(); | 13488 if (usingFastaParser) { |
| 13489 assertNoErrors(); |
| 13490 } else { |
| 13491 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 13492 } |
| 13305 expect((declarationList.type as TypeName).name.name, 'T'); | 13493 expect((declarationList.type as TypeName).name.name, 'T'); |
| 13306 expect(declarationList.keyword, isNull); | 13494 expect(declarationList.keyword, isNull); |
| 13307 } | 13495 } |
| 13308 | 13496 |
| 13309 void test_parseVariableDeclarationStatementAfterMetadata_multiple() { | 13497 void test_parseVariableDeclarationStatementAfterMetadata_multiple() { |
| 13310 var statement = | 13498 var statement = |
| 13311 parseStatement('var x, y, z;') as VariableDeclarationStatement; | 13499 parseStatement('var x, y, z;') as VariableDeclarationStatement; |
| 13312 assertNoErrors(); | 13500 assertNoErrors(); |
| 13313 expect(statement.semicolon, isNotNull); | 13501 expect(statement.semicolon, isNotNull); |
| 13314 VariableDeclarationList variableList = statement.variables; | 13502 VariableDeclarationList variableList = statement.variables; |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 14665 expect(expression.typeParameters, isNotNull); | 14853 expect(expression.typeParameters, isNotNull); |
| 14666 expect(expression.parameters, isNotNull); | 14854 expect(expression.parameters, isNotNull); |
| 14667 expect(declaration.propertyKeyword, isNull); | 14855 expect(declaration.propertyKeyword, isNull); |
| 14668 } | 14856 } |
| 14669 | 14857 |
| 14670 void test_parseFunctionDeclaration_functionWithTypeParameters_comment() { | 14858 void test_parseFunctionDeclaration_functionWithTypeParameters_comment() { |
| 14671 enableGenericMethodComments = true; | 14859 enableGenericMethodComments = true; |
| 14672 createParser('/// Doc\nT f/*<E>*/() {}'); | 14860 createParser('/// Doc\nT f/*<E>*/() {}'); |
| 14673 FunctionDeclaration declaration = parseFullCompilationUnitMember(); | 14861 FunctionDeclaration declaration = parseFullCompilationUnitMember(); |
| 14674 expect(declaration, isNotNull); | 14862 expect(declaration, isNotNull); |
| 14675 assertNoErrors(); | 14863 if (usingFastaParser) { |
| 14864 assertNoErrors(); |
| 14865 } else { |
| 14866 assertErrorsWithCodes([HintCode.GENERIC_METHOD_COMMENT]); |
| 14867 } |
| 14676 expectCommentText(declaration.documentationComment, '/// Doc'); | 14868 expectCommentText(declaration.documentationComment, '/// Doc'); |
| 14677 expect((declaration.returnType as TypeName).name.name, 'T'); | 14869 expect((declaration.returnType as TypeName).name.name, 'T'); |
| 14678 expect(declaration.name, isNotNull); | 14870 expect(declaration.name, isNotNull); |
| 14679 FunctionExpression expression = declaration.functionExpression; | 14871 FunctionExpression expression = declaration.functionExpression; |
| 14680 expect(expression, isNotNull); | 14872 expect(expression, isNotNull); |
| 14681 expect(expression.body, isNotNull); | 14873 expect(expression.body, isNotNull); |
| 14682 expect(expression.typeParameters, isNotNull); | 14874 expect(expression.typeParameters, isNotNull); |
| 14683 expect(expression.parameters, isNotNull); | 14875 expect(expression.parameters, isNotNull); |
| 14684 expect(declaration.propertyKeyword, isNull); | 14876 expect(declaration.propertyKeyword, isNull); |
| 14685 } | 14877 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 14698 expect(expression.typeParameters, isNull); | 14890 expect(expression.typeParameters, isNull); |
| 14699 expect(expression.parameters, isNull); | 14891 expect(expression.parameters, isNull); |
| 14700 expect(declaration.propertyKeyword, isNotNull); | 14892 expect(declaration.propertyKeyword, isNotNull); |
| 14701 } | 14893 } |
| 14702 | 14894 |
| 14703 void test_parseFunctionDeclaration_getter_generic_comment_returnType() { | 14895 void test_parseFunctionDeclaration_getter_generic_comment_returnType() { |
| 14704 enableGenericMethodComments = true; | 14896 enableGenericMethodComments = true; |
| 14705 createParser('/*=T*/ f/*<S, T>*/(/*=S*/ s) => null;'); | 14897 createParser('/*=T*/ f/*<S, T>*/(/*=S*/ s) => null;'); |
| 14706 var member = parseFullCompilationUnitMember(); | 14898 var member = parseFullCompilationUnitMember(); |
| 14707 expect(member, isNotNull); | 14899 expect(member, isNotNull); |
| 14708 assertNoErrors(); | 14900 |
| 14901 if (usingFastaParser) { |
| 14902 assertNoErrors(); |
| 14903 } else { |
| 14904 assertErrorsWithCodes([ |
| 14905 HintCode.GENERIC_METHOD_COMMENT, |
| 14906 HintCode.GENERIC_METHOD_COMMENT, |
| 14907 HintCode.GENERIC_METHOD_COMMENT |
| 14908 ]); |
| 14909 } |
| 14709 var functionDeclaration = member as FunctionDeclaration; | 14910 var functionDeclaration = member as FunctionDeclaration; |
| 14710 var functionExpression = functionDeclaration.functionExpression; | 14911 var functionExpression = functionDeclaration.functionExpression; |
| 14711 expect(functionDeclaration.documentationComment, isNull); | 14912 expect(functionDeclaration.documentationComment, isNull); |
| 14712 expect(functionDeclaration.externalKeyword, isNull); | 14913 expect(functionDeclaration.externalKeyword, isNull); |
| 14713 expect(functionDeclaration.propertyKeyword, isNull); | 14914 expect(functionDeclaration.propertyKeyword, isNull); |
| 14714 expect((functionDeclaration.returnType as TypeName).name.name, 'T'); | 14915 expect((functionDeclaration.returnType as TypeName).name.name, 'T'); |
| 14715 expect(functionDeclaration.name, isNotNull); | 14916 expect(functionDeclaration.name, isNotNull); |
| 14716 expect(functionExpression.typeParameters, isNotNull); | 14917 expect(functionExpression.typeParameters, isNotNull); |
| 14717 expect(functionExpression.parameters, isNotNull); | 14918 expect(functionExpression.parameters, isNotNull); |
| 14718 expect(functionExpression.body, isNotNull); | 14919 expect(functionExpression.body, isNotNull); |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15223 expectCommentText(typeVariable.documentationComment, '/// Doc'); | 15424 expectCommentText(typeVariable.documentationComment, '/// Doc'); |
| 15224 } | 15425 } |
| 15225 | 15426 |
| 15226 /** | 15427 /** |
| 15227 * Assert that the given [name] is in declaration context. | 15428 * Assert that the given [name] is in declaration context. |
| 15228 */ | 15429 */ |
| 15229 void _assertIsDeclarationName(SimpleIdentifier name) { | 15430 void _assertIsDeclarationName(SimpleIdentifier name) { |
| 15230 expect(name.inDeclarationContext(), isTrue); | 15431 expect(name.inDeclarationContext(), isTrue); |
| 15231 } | 15432 } |
| 15232 } | 15433 } |
| OLD | NEW |