| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library analyzer.test.generated.parser_test; | 5 library analyzer.test.generated.parser_test; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/ast/visitor.dart'; | 9 import 'package:analyzer/dart/ast/visitor.dart'; |
| 10 import 'package:analyzer/src/dart/ast/token.dart'; | 10 import 'package:analyzer/src/dart/ast/token.dart'; |
| (...skipping 3681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3692 CompilationUnitMember unitMember = declarations[0]; | 3692 CompilationUnitMember unitMember = declarations[0]; |
| 3693 EngineTestCase.assertInstanceOf( | 3693 EngineTestCase.assertInstanceOf( |
| 3694 (obj) => obj is ClassDeclaration, ClassDeclaration, unitMember); | 3694 (obj) => obj is ClassDeclaration, ClassDeclaration, unitMember); |
| 3695 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members; | 3695 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members; |
| 3696 expect(members, hasLength(1)); | 3696 expect(members, hasLength(1)); |
| 3697 ClassMember classMember = members[0]; | 3697 ClassMember classMember = members[0]; |
| 3698 EngineTestCase.assertInstanceOf( | 3698 EngineTestCase.assertInstanceOf( |
| 3699 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember); | 3699 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember); |
| 3700 VariableDeclarationList fieldList = | 3700 VariableDeclarationList fieldList = |
| 3701 (classMember as FieldDeclaration).fields; | 3701 (classMember as FieldDeclaration).fields; |
| 3702 expect((fieldList.keyword as KeywordToken).keyword, Keyword.CONST); | 3702 expect(fieldList.keyword.keyword, Keyword.CONST); |
| 3703 NodeList<VariableDeclaration> fields = fieldList.variables; | 3703 NodeList<VariableDeclaration> fields = fieldList.variables; |
| 3704 expect(fields, hasLength(1)); | 3704 expect(fields, hasLength(1)); |
| 3705 VariableDeclaration field = fields[0]; | 3705 VariableDeclaration field = fields[0]; |
| 3706 expect(field.name.isSynthetic, isTrue); | 3706 expect(field.name.isSynthetic, isTrue); |
| 3707 } | 3707 } |
| 3708 | 3708 |
| 3709 void test_incompleteField_final() { | 3709 void test_incompleteField_final() { |
| 3710 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 3710 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 3711 r''' | 3711 r''' |
| 3712 class C { | 3712 class C { |
| 3713 final | 3713 final |
| 3714 }''', | 3714 }''', |
| 3715 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); | 3715 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); |
| 3716 NodeList<CompilationUnitMember> declarations = unit.declarations; | 3716 NodeList<CompilationUnitMember> declarations = unit.declarations; |
| 3717 expect(declarations, hasLength(1)); | 3717 expect(declarations, hasLength(1)); |
| 3718 CompilationUnitMember unitMember = declarations[0]; | 3718 CompilationUnitMember unitMember = declarations[0]; |
| 3719 EngineTestCase.assertInstanceOf( | 3719 EngineTestCase.assertInstanceOf( |
| 3720 (obj) => obj is ClassDeclaration, ClassDeclaration, unitMember); | 3720 (obj) => obj is ClassDeclaration, ClassDeclaration, unitMember); |
| 3721 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members; | 3721 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members; |
| 3722 expect(members, hasLength(1)); | 3722 expect(members, hasLength(1)); |
| 3723 ClassMember classMember = members[0]; | 3723 ClassMember classMember = members[0]; |
| 3724 EngineTestCase.assertInstanceOf( | 3724 EngineTestCase.assertInstanceOf( |
| 3725 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember); | 3725 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember); |
| 3726 VariableDeclarationList fieldList = | 3726 VariableDeclarationList fieldList = |
| 3727 (classMember as FieldDeclaration).fields; | 3727 (classMember as FieldDeclaration).fields; |
| 3728 expect((fieldList.keyword as KeywordToken).keyword, Keyword.FINAL); | 3728 expect(fieldList.keyword.keyword, Keyword.FINAL); |
| 3729 NodeList<VariableDeclaration> fields = fieldList.variables; | 3729 NodeList<VariableDeclaration> fields = fieldList.variables; |
| 3730 expect(fields, hasLength(1)); | 3730 expect(fields, hasLength(1)); |
| 3731 VariableDeclaration field = fields[0]; | 3731 VariableDeclaration field = fields[0]; |
| 3732 expect(field.name.isSynthetic, isTrue); | 3732 expect(field.name.isSynthetic, isTrue); |
| 3733 } | 3733 } |
| 3734 | 3734 |
| 3735 void test_incompleteField_var() { | 3735 void test_incompleteField_var() { |
| 3736 CompilationUnit unit = ParserTestCase.parseCompilationUnit( | 3736 CompilationUnit unit = ParserTestCase.parseCompilationUnit( |
| 3737 r''' | 3737 r''' |
| 3738 class C { | 3738 class C { |
| 3739 var | 3739 var |
| 3740 }''', | 3740 }''', |
| 3741 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); | 3741 [ParserErrorCode.MISSING_IDENTIFIER, ParserErrorCode.EXPECTED_TOKEN]); |
| 3742 NodeList<CompilationUnitMember> declarations = unit.declarations; | 3742 NodeList<CompilationUnitMember> declarations = unit.declarations; |
| 3743 expect(declarations, hasLength(1)); | 3743 expect(declarations, hasLength(1)); |
| 3744 CompilationUnitMember unitMember = declarations[0]; | 3744 CompilationUnitMember unitMember = declarations[0]; |
| 3745 EngineTestCase.assertInstanceOf( | 3745 EngineTestCase.assertInstanceOf( |
| 3746 (obj) => obj is ClassDeclaration, ClassDeclaration, unitMember); | 3746 (obj) => obj is ClassDeclaration, ClassDeclaration, unitMember); |
| 3747 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members; | 3747 NodeList<ClassMember> members = (unitMember as ClassDeclaration).members; |
| 3748 expect(members, hasLength(1)); | 3748 expect(members, hasLength(1)); |
| 3749 ClassMember classMember = members[0]; | 3749 ClassMember classMember = members[0]; |
| 3750 EngineTestCase.assertInstanceOf( | 3750 EngineTestCase.assertInstanceOf( |
| 3751 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember); | 3751 (obj) => obj is FieldDeclaration, FieldDeclaration, classMember); |
| 3752 VariableDeclarationList fieldList = | 3752 VariableDeclarationList fieldList = |
| 3753 (classMember as FieldDeclaration).fields; | 3753 (classMember as FieldDeclaration).fields; |
| 3754 expect((fieldList.keyword as KeywordToken).keyword, Keyword.VAR); | 3754 expect(fieldList.keyword.keyword, Keyword.VAR); |
| 3755 NodeList<VariableDeclaration> fields = fieldList.variables; | 3755 NodeList<VariableDeclaration> fields = fieldList.variables; |
| 3756 expect(fields, hasLength(1)); | 3756 expect(fields, hasLength(1)); |
| 3757 VariableDeclaration field = fields[0]; | 3757 VariableDeclaration field = fields[0]; |
| 3758 expect(field.name.isSynthetic, isTrue); | 3758 expect(field.name.isSynthetic, isTrue); |
| 3759 } | 3759 } |
| 3760 | 3760 |
| 3761 void test_incompleteForEach() { | 3761 void test_incompleteForEach() { |
| 3762 ForStatement statement = ParserTestCase.parseStatement( | 3762 ForStatement statement = ParserTestCase.parseStatement( |
| 3763 'for (String item i) {}', | 3763 'for (String item i) {}', |
| 3764 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN]); | 3764 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.EXPECTED_TOKEN]); |
| (...skipping 3733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7498 EngineTestCase.assertInstanceOf( | 7498 EngineTestCase.assertInstanceOf( |
| 7499 (obj) => obj is TypeName, TypeName, clause.superclass); | 7499 (obj) => obj is TypeName, TypeName, clause.superclass); |
| 7500 } | 7500 } |
| 7501 | 7501 |
| 7502 void test_parseFinalConstVarOrType_const_noType() { | 7502 void test_parseFinalConstVarOrType_const_noType() { |
| 7503 FinalConstVarOrType result = | 7503 FinalConstVarOrType result = |
| 7504 parse("parseFinalConstVarOrType", <Object>[false], "const"); | 7504 parse("parseFinalConstVarOrType", <Object>[false], "const"); |
| 7505 Token keyword = result.keyword; | 7505 Token keyword = result.keyword; |
| 7506 expect(keyword, isNotNull); | 7506 expect(keyword, isNotNull); |
| 7507 expect(keyword.type, TokenType.KEYWORD); | 7507 expect(keyword.type, TokenType.KEYWORD); |
| 7508 expect((keyword as KeywordToken).keyword, Keyword.CONST); | 7508 expect(keyword.keyword, Keyword.CONST); |
| 7509 expect(result.type, isNull); | 7509 expect(result.type, isNull); |
| 7510 } | 7510 } |
| 7511 | 7511 |
| 7512 void test_parseFinalConstVarOrType_const_type() { | 7512 void test_parseFinalConstVarOrType_const_type() { |
| 7513 FinalConstVarOrType result = | 7513 FinalConstVarOrType result = |
| 7514 parse("parseFinalConstVarOrType", <Object>[false], "const A a"); | 7514 parse("parseFinalConstVarOrType", <Object>[false], "const A a"); |
| 7515 Token keyword = result.keyword; | 7515 Token keyword = result.keyword; |
| 7516 expect(keyword, isNotNull); | 7516 expect(keyword, isNotNull); |
| 7517 expect(keyword.type, TokenType.KEYWORD); | 7517 expect(keyword.type, TokenType.KEYWORD); |
| 7518 expect((keyword as KeywordToken).keyword, Keyword.CONST); | 7518 expect(keyword.keyword, Keyword.CONST); |
| 7519 expect(result.type, isNotNull); | 7519 expect(result.type, isNotNull); |
| 7520 } | 7520 } |
| 7521 | 7521 |
| 7522 void test_parseFinalConstVarOrType_final_noType() { | 7522 void test_parseFinalConstVarOrType_final_noType() { |
| 7523 FinalConstVarOrType result = | 7523 FinalConstVarOrType result = |
| 7524 parse("parseFinalConstVarOrType", <Object>[false], "final"); | 7524 parse("parseFinalConstVarOrType", <Object>[false], "final"); |
| 7525 Token keyword = result.keyword; | 7525 Token keyword = result.keyword; |
| 7526 expect(keyword, isNotNull); | 7526 expect(keyword, isNotNull); |
| 7527 expect(keyword.type, TokenType.KEYWORD); | 7527 expect(keyword.type, TokenType.KEYWORD); |
| 7528 expect((keyword as KeywordToken).keyword, Keyword.FINAL); | 7528 expect(keyword.keyword, Keyword.FINAL); |
| 7529 expect(result.type, isNull); | 7529 expect(result.type, isNull); |
| 7530 } | 7530 } |
| 7531 | 7531 |
| 7532 void test_parseFinalConstVarOrType_final_prefixedType() { | 7532 void test_parseFinalConstVarOrType_final_prefixedType() { |
| 7533 FinalConstVarOrType result = | 7533 FinalConstVarOrType result = |
| 7534 parse("parseFinalConstVarOrType", <Object>[false], "final p.A a"); | 7534 parse("parseFinalConstVarOrType", <Object>[false], "final p.A a"); |
| 7535 Token keyword = result.keyword; | 7535 Token keyword = result.keyword; |
| 7536 expect(keyword, isNotNull); | 7536 expect(keyword, isNotNull); |
| 7537 expect(keyword.type, TokenType.KEYWORD); | 7537 expect(keyword.type, TokenType.KEYWORD); |
| 7538 expect((keyword as KeywordToken).keyword, Keyword.FINAL); | 7538 expect(keyword.keyword, Keyword.FINAL); |
| 7539 expect(result.type, isNotNull); | 7539 expect(result.type, isNotNull); |
| 7540 } | 7540 } |
| 7541 | 7541 |
| 7542 void test_parseFinalConstVarOrType_final_type() { | 7542 void test_parseFinalConstVarOrType_final_type() { |
| 7543 FinalConstVarOrType result = | 7543 FinalConstVarOrType result = |
| 7544 parse("parseFinalConstVarOrType", <Object>[false], "final A a"); | 7544 parse("parseFinalConstVarOrType", <Object>[false], "final A a"); |
| 7545 Token keyword = result.keyword; | 7545 Token keyword = result.keyword; |
| 7546 expect(keyword, isNotNull); | 7546 expect(keyword, isNotNull); |
| 7547 expect(keyword.type, TokenType.KEYWORD); | 7547 expect(keyword.type, TokenType.KEYWORD); |
| 7548 expect((keyword as KeywordToken).keyword, Keyword.FINAL); | 7548 expect(keyword.keyword, Keyword.FINAL); |
| 7549 expect(result.type, isNotNull); | 7549 expect(result.type, isNotNull); |
| 7550 } | 7550 } |
| 7551 | 7551 |
| 7552 void test_parseFinalConstVarOrType_type_parameterized() { | 7552 void test_parseFinalConstVarOrType_type_parameterized() { |
| 7553 FinalConstVarOrType result = | 7553 FinalConstVarOrType result = |
| 7554 parse("parseFinalConstVarOrType", <Object>[false], "A<B> a"); | 7554 parse("parseFinalConstVarOrType", <Object>[false], "A<B> a"); |
| 7555 expect(result.keyword, isNull); | 7555 expect(result.keyword, isNull); |
| 7556 expect(result.type, isNotNull); | 7556 expect(result.type, isNotNull); |
| 7557 } | 7557 } |
| 7558 | 7558 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 7583 expect(result.keyword, isNull); | 7583 expect(result.keyword, isNull); |
| 7584 expect(result.type, isNotNull); | 7584 expect(result.type, isNotNull); |
| 7585 } | 7585 } |
| 7586 | 7586 |
| 7587 void test_parseFinalConstVarOrType_var() { | 7587 void test_parseFinalConstVarOrType_var() { |
| 7588 FinalConstVarOrType result = | 7588 FinalConstVarOrType result = |
| 7589 parse("parseFinalConstVarOrType", <Object>[false], "var"); | 7589 parse("parseFinalConstVarOrType", <Object>[false], "var"); |
| 7590 Token keyword = result.keyword; | 7590 Token keyword = result.keyword; |
| 7591 expect(keyword, isNotNull); | 7591 expect(keyword, isNotNull); |
| 7592 expect(keyword.type, TokenType.KEYWORD); | 7592 expect(keyword.type, TokenType.KEYWORD); |
| 7593 expect((keyword as KeywordToken).keyword, Keyword.VAR); | 7593 expect(keyword.keyword, Keyword.VAR); |
| 7594 expect(result.type, isNull); | 7594 expect(result.type, isNull); |
| 7595 } | 7595 } |
| 7596 | 7596 |
| 7597 void test_parseFinalConstVarOrType_void() { | 7597 void test_parseFinalConstVarOrType_void() { |
| 7598 FinalConstVarOrType result = | 7598 FinalConstVarOrType result = |
| 7599 parse("parseFinalConstVarOrType", <Object>[false], "void f()"); | 7599 parse("parseFinalConstVarOrType", <Object>[false], "void f()"); |
| 7600 expect(result.keyword, isNull); | 7600 expect(result.keyword, isNull); |
| 7601 expect(result.type, isNotNull); | 7601 expect(result.type, isNotNull); |
| 7602 } | 7602 } |
| 7603 | 7603 |
| (...skipping 3569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11173 new Scanner(null, new CharSequenceReader(source), listener); | 11173 new Scanner(null, new CharSequenceReader(source), listener); |
| 11174 Token tokenStream = scanner.tokenize(); | 11174 Token tokenStream = scanner.tokenize(); |
| 11175 // | 11175 // |
| 11176 // Parse the source. | 11176 // Parse the source. |
| 11177 // | 11177 // |
| 11178 Parser parser = new Parser(null, listener); | 11178 Parser parser = new Parser(null, listener); |
| 11179 return invokeParserMethodImpl( | 11179 return invokeParserMethodImpl( |
| 11180 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 11180 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 11181 } | 11181 } |
| 11182 } | 11182 } |
| OLD | NEW |