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/standard_ast_factory.dart'; |
8 import 'package:analyzer/dart/ast/token.dart'; | 9 import 'package:analyzer/dart/ast/token.dart'; |
9 import 'package:analyzer/dart/ast/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
10 import 'package:analyzer/error/error.dart'; | 11 import 'package:analyzer/error/error.dart'; |
11 import 'package:analyzer/error/listener.dart'; | 12 import 'package:analyzer/error/listener.dart'; |
12 import 'package:analyzer/src/dart/ast/token.dart'; | 13 import 'package:analyzer/src/dart/ast/token.dart'; |
13 import 'package:analyzer/src/dart/scanner/reader.dart'; | 14 import 'package:analyzer/src/dart/scanner/reader.dart'; |
14 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 15 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
15 import 'package:analyzer/src/generated/parser.dart'; | 16 import 'package:analyzer/src/generated/parser.dart'; |
16 import 'package:analyzer/src/generated/source.dart'; | 17 import 'package:analyzer/src/generated/source.dart'; |
17 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; | 18 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; |
(...skipping 5041 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5059 expect(expression, new isInstanceOf<IndexExpression>()); | 5060 expect(expression, new isInstanceOf<IndexExpression>()); |
5060 IndexExpression indexExpression = expression; | 5061 IndexExpression indexExpression = expression; |
5061 expect(indexExpression.leftBracket, isNotNull); | 5062 expect(indexExpression.leftBracket, isNotNull); |
5062 expect(indexExpression.index, isNotNull); | 5063 expect(indexExpression.index, isNotNull); |
5063 expect(indexExpression.rightBracket, isNotNull); | 5064 expect(indexExpression.rightBracket, isNotNull); |
5064 } | 5065 } |
5065 | 5066 |
5066 void test_parseAssignableSelector_none() { | 5067 void test_parseAssignableSelector_none() { |
5067 createParser(';'); | 5068 createParser(';'); |
5068 Expression expression = | 5069 Expression expression = |
5069 parser.parseAssignableSelector(new SimpleIdentifier(null), true); | 5070 parser.parseAssignableSelector(astFactory.simpleIdentifier(null), true); |
5070 expectNotNullIfNoErrors(expression); | 5071 expectNotNullIfNoErrors(expression); |
5071 listener.assertNoErrors(); | 5072 listener.assertNoErrors(); |
5072 expect(expression, new isInstanceOf<SimpleIdentifier>()); | 5073 expect(expression, new isInstanceOf<SimpleIdentifier>()); |
5073 SimpleIdentifier identifier = expression; | 5074 SimpleIdentifier identifier = expression; |
5074 expect(identifier, isNotNull); | 5075 expect(identifier, isNotNull); |
5075 } | 5076 } |
5076 | 5077 |
5077 void test_parseAssignableSelector_question_dot() { | 5078 void test_parseAssignableSelector_question_dot() { |
5078 createParser('?.x'); | 5079 createParser('?.x'); |
5079 Expression expression = parser.parseAssignableSelector(null, true); | 5080 Expression expression = parser.parseAssignableSelector(null, true); |
(...skipping 4336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9416 void test_parseFunctionBody_skip_expression() { | 9417 void test_parseFunctionBody_skip_expression() { |
9417 ParserTestCase.parseFunctionBodies = false; | 9418 ParserTestCase.parseFunctionBodies = false; |
9418 createParser('=> y;'); | 9419 createParser('=> y;'); |
9419 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); | 9420 FunctionBody functionBody = parser.parseFunctionBody(false, null, false); |
9420 expectNotNullIfNoErrors(functionBody); | 9421 expectNotNullIfNoErrors(functionBody); |
9421 listener.assertNoErrors(); | 9422 listener.assertNoErrors(); |
9422 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); | 9423 expect(functionBody, new isInstanceOf<EmptyFunctionBody>()); |
9423 } | 9424 } |
9424 | 9425 |
9425 void test_parseFunctionDeclaration_function() { | 9426 void test_parseFunctionDeclaration_function() { |
9426 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9427 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
9427 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 9428 TypeName returnType = |
| 9429 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
9428 createParser('f() {}'); | 9430 createParser('f() {}'); |
9429 FunctionDeclaration declaration = parser.parseFunctionDeclaration( | 9431 FunctionDeclaration declaration = parser.parseFunctionDeclaration( |
9430 commentAndMetadata(comment), null, returnType); | 9432 commentAndMetadata(comment), null, returnType); |
9431 expectNotNullIfNoErrors(declaration); | 9433 expectNotNullIfNoErrors(declaration); |
9432 listener.assertNoErrors(); | 9434 listener.assertNoErrors(); |
9433 expect(declaration.documentationComment, comment); | 9435 expect(declaration.documentationComment, comment); |
9434 expect(declaration.returnType, returnType); | 9436 expect(declaration.returnType, returnType); |
9435 expect(declaration.name, isNotNull); | 9437 expect(declaration.name, isNotNull); |
9436 FunctionExpression expression = declaration.functionExpression; | 9438 FunctionExpression expression = declaration.functionExpression; |
9437 expect(expression, isNotNull); | 9439 expect(expression, isNotNull); |
9438 expect(expression.body, isNotNull); | 9440 expect(expression.body, isNotNull); |
9439 expect(expression.typeParameters, isNull); | 9441 expect(expression.typeParameters, isNull); |
9440 expect(expression.parameters, isNotNull); | 9442 expect(expression.parameters, isNotNull); |
9441 expect(declaration.propertyKeyword, isNull); | 9443 expect(declaration.propertyKeyword, isNull); |
9442 } | 9444 } |
9443 | 9445 |
9444 void test_parseFunctionDeclaration_functionWithTypeParameters() { | 9446 void test_parseFunctionDeclaration_functionWithTypeParameters() { |
9445 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9447 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
9446 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 9448 TypeName returnType = |
| 9449 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
9447 createParser('f<E>() {}'); | 9450 createParser('f<E>() {}'); |
9448 FunctionDeclaration declaration = parser.parseFunctionDeclaration( | 9451 FunctionDeclaration declaration = parser.parseFunctionDeclaration( |
9449 commentAndMetadata(comment), null, returnType); | 9452 commentAndMetadata(comment), null, returnType); |
9450 expectNotNullIfNoErrors(declaration); | 9453 expectNotNullIfNoErrors(declaration); |
9451 listener.assertNoErrors(); | 9454 listener.assertNoErrors(); |
9452 expect(declaration.documentationComment, comment); | 9455 expect(declaration.documentationComment, comment); |
9453 expect(declaration.returnType, returnType); | 9456 expect(declaration.returnType, returnType); |
9454 expect(declaration.name, isNotNull); | 9457 expect(declaration.name, isNotNull); |
9455 FunctionExpression expression = declaration.functionExpression; | 9458 FunctionExpression expression = declaration.functionExpression; |
9456 expect(expression, isNotNull); | 9459 expect(expression, isNotNull); |
9457 expect(expression.body, isNotNull); | 9460 expect(expression.body, isNotNull); |
9458 expect(expression.typeParameters, isNotNull); | 9461 expect(expression.typeParameters, isNotNull); |
9459 expect(expression.parameters, isNotNull); | 9462 expect(expression.parameters, isNotNull); |
9460 expect(declaration.propertyKeyword, isNull); | 9463 expect(declaration.propertyKeyword, isNull); |
9461 } | 9464 } |
9462 | 9465 |
9463 void test_parseFunctionDeclaration_functionWithTypeParameters_comment() { | 9466 void test_parseFunctionDeclaration_functionWithTypeParameters_comment() { |
9464 enableGenericMethodComments = true; | 9467 enableGenericMethodComments = true; |
9465 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9468 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
9466 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 9469 TypeName returnType = |
| 9470 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
9467 createParser('f/*<E>*/() {}'); | 9471 createParser('f/*<E>*/() {}'); |
9468 FunctionDeclaration declaration = parser.parseFunctionDeclaration( | 9472 FunctionDeclaration declaration = parser.parseFunctionDeclaration( |
9469 commentAndMetadata(comment), null, returnType); | 9473 commentAndMetadata(comment), null, returnType); |
9470 expectNotNullIfNoErrors(declaration); | 9474 expectNotNullIfNoErrors(declaration); |
9471 listener.assertNoErrors(); | 9475 listener.assertNoErrors(); |
9472 expect(declaration.documentationComment, comment); | 9476 expect(declaration.documentationComment, comment); |
9473 expect(declaration.returnType, returnType); | 9477 expect(declaration.returnType, returnType); |
9474 expect(declaration.name, isNotNull); | 9478 expect(declaration.name, isNotNull); |
9475 FunctionExpression expression = declaration.functionExpression; | 9479 FunctionExpression expression = declaration.functionExpression; |
9476 expect(expression, isNotNull); | 9480 expect(expression, isNotNull); |
9477 expect(expression.body, isNotNull); | 9481 expect(expression.body, isNotNull); |
9478 expect(expression.typeParameters, isNotNull); | 9482 expect(expression.typeParameters, isNotNull); |
9479 expect(expression.parameters, isNotNull); | 9483 expect(expression.parameters, isNotNull); |
9480 expect(declaration.propertyKeyword, isNull); | 9484 expect(declaration.propertyKeyword, isNull); |
9481 } | 9485 } |
9482 | 9486 |
9483 void test_parseFunctionDeclaration_getter() { | 9487 void test_parseFunctionDeclaration_getter() { |
9484 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9488 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
9485 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 9489 TypeName returnType = |
| 9490 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
9486 createParser('get p => 0;'); | 9491 createParser('get p => 0;'); |
9487 FunctionDeclaration declaration = parser.parseFunctionDeclaration( | 9492 FunctionDeclaration declaration = parser.parseFunctionDeclaration( |
9488 commentAndMetadata(comment), null, returnType); | 9493 commentAndMetadata(comment), null, returnType); |
9489 expectNotNullIfNoErrors(declaration); | 9494 expectNotNullIfNoErrors(declaration); |
9490 listener.assertNoErrors(); | 9495 listener.assertNoErrors(); |
9491 expect(declaration.documentationComment, comment); | 9496 expect(declaration.documentationComment, comment); |
9492 expect(declaration.returnType, returnType); | 9497 expect(declaration.returnType, returnType); |
9493 expect(declaration.name, isNotNull); | 9498 expect(declaration.name, isNotNull); |
9494 FunctionExpression expression = declaration.functionExpression; | 9499 FunctionExpression expression = declaration.functionExpression; |
9495 expect(expression, isNotNull); | 9500 expect(expression, isNotNull); |
9496 expect(expression.body, isNotNull); | 9501 expect(expression.body, isNotNull); |
9497 expect(expression.typeParameters, isNull); | 9502 expect(expression.typeParameters, isNull); |
9498 expect(expression.parameters, isNull); | 9503 expect(expression.parameters, isNull); |
9499 expect(declaration.propertyKeyword, isNotNull); | 9504 expect(declaration.propertyKeyword, isNotNull); |
9500 } | 9505 } |
9501 | 9506 |
9502 void test_parseFunctionDeclaration_setter() { | 9507 void test_parseFunctionDeclaration_setter() { |
9503 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9508 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
9504 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 9509 TypeName returnType = |
| 9510 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
9505 createParser('set p(v) {}'); | 9511 createParser('set p(v) {}'); |
9506 FunctionDeclaration declaration = parser.parseFunctionDeclaration( | 9512 FunctionDeclaration declaration = parser.parseFunctionDeclaration( |
9507 commentAndMetadata(comment), null, returnType); | 9513 commentAndMetadata(comment), null, returnType); |
9508 expectNotNullIfNoErrors(declaration); | 9514 expectNotNullIfNoErrors(declaration); |
9509 listener.assertNoErrors(); | 9515 listener.assertNoErrors(); |
9510 expect(declaration.documentationComment, comment); | 9516 expect(declaration.documentationComment, comment); |
9511 expect(declaration.returnType, returnType); | 9517 expect(declaration.returnType, returnType); |
9512 expect(declaration.name, isNotNull); | 9518 expect(declaration.name, isNotNull); |
9513 FunctionExpression expression = declaration.functionExpression; | 9519 FunctionExpression expression = declaration.functionExpression; |
9514 expect(expression, isNotNull); | 9520 expect(expression, isNotNull); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9583 FunctionExpression expression = parser.parseFunctionExpression(); | 9589 FunctionExpression expression = parser.parseFunctionExpression(); |
9584 expectNotNullIfNoErrors(expression); | 9590 expectNotNullIfNoErrors(expression); |
9585 listener.assertNoErrors(); | 9591 listener.assertNoErrors(); |
9586 expect(expression.body, isNotNull); | 9592 expect(expression.body, isNotNull); |
9587 expect(expression.typeParameters, isNotNull); | 9593 expect(expression.typeParameters, isNotNull); |
9588 expect(expression.parameters, isNotNull); | 9594 expect(expression.parameters, isNotNull); |
9589 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); | 9595 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); |
9590 } | 9596 } |
9591 | 9597 |
9592 void test_parseGetter_nonStatic() { | 9598 void test_parseGetter_nonStatic() { |
9593 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9599 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
9594 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 9600 TypeName returnType = |
| 9601 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
9595 createParser('get a;'); | 9602 createParser('get a;'); |
9596 MethodDeclaration method = | 9603 MethodDeclaration method = |
9597 parser.parseGetter(commentAndMetadata(comment), null, null, returnType); | 9604 parser.parseGetter(commentAndMetadata(comment), null, null, returnType); |
9598 expectNotNullIfNoErrors(method); | 9605 expectNotNullIfNoErrors(method); |
9599 listener.assertNoErrors(); | 9606 listener.assertNoErrors(); |
9600 expect(method.body, isNotNull); | 9607 expect(method.body, isNotNull); |
9601 expect(method.documentationComment, comment); | 9608 expect(method.documentationComment, comment); |
9602 expect(method.externalKeyword, isNull); | 9609 expect(method.externalKeyword, isNull); |
9603 expect(method.modifierKeyword, isNull); | 9610 expect(method.modifierKeyword, isNull); |
9604 expect(method.name, isNotNull); | 9611 expect(method.name, isNotNull); |
9605 expect(method.operatorKeyword, isNull); | 9612 expect(method.operatorKeyword, isNull); |
9606 expect(method.parameters, isNull); | 9613 expect(method.parameters, isNull); |
9607 expect(method.propertyKeyword, isNotNull); | 9614 expect(method.propertyKeyword, isNotNull); |
9608 expect(method.returnType, returnType); | 9615 expect(method.returnType, returnType); |
9609 } | 9616 } |
9610 | 9617 |
9611 void test_parseGetter_static() { | 9618 void test_parseGetter_static() { |
9612 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9619 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
9613 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 9620 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
9614 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 9621 TypeName returnType = |
| 9622 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
9615 createParser('get a => 42;'); | 9623 createParser('get a => 42;'); |
9616 MethodDeclaration method = parser.parseGetter( | 9624 MethodDeclaration method = parser.parseGetter( |
9617 commentAndMetadata(comment), null, staticKeyword, returnType); | 9625 commentAndMetadata(comment), null, staticKeyword, returnType); |
9618 expectNotNullIfNoErrors(method); | 9626 expectNotNullIfNoErrors(method); |
9619 listener.assertNoErrors(); | 9627 listener.assertNoErrors(); |
9620 expect(method.body, isNotNull); | 9628 expect(method.body, isNotNull); |
9621 expect(method.documentationComment, comment); | 9629 expect(method.documentationComment, comment); |
9622 expect(method.externalKeyword, isNull); | 9630 expect(method.externalKeyword, isNull); |
9623 expect(method.modifierKeyword, staticKeyword); | 9631 expect(method.modifierKeyword, staticKeyword); |
9624 expect(method.name, isNotNull); | 9632 expect(method.name, isNotNull); |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9853 expect(directive.keyword, isNotNull); | 9861 expect(directive.keyword, isNotNull); |
9854 expect(directive.uri, isNotNull); | 9862 expect(directive.uri, isNotNull); |
9855 expect(directive.deferredKeyword, isNull); | 9863 expect(directive.deferredKeyword, isNull); |
9856 expect(directive.asKeyword, isNull); | 9864 expect(directive.asKeyword, isNull); |
9857 expect(directive.prefix, isNull); | 9865 expect(directive.prefix, isNull); |
9858 expect(directive.combinators, hasLength(1)); | 9866 expect(directive.combinators, hasLength(1)); |
9859 expect(directive.semicolon, isNotNull); | 9867 expect(directive.semicolon, isNotNull); |
9860 } | 9868 } |
9861 | 9869 |
9862 void test_parseInitializedIdentifierList_type() { | 9870 void test_parseInitializedIdentifierList_type() { |
9863 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9871 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
9864 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 9872 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
9865 TypeName type = new TypeName(new SimpleIdentifier(null), null); | 9873 TypeName type = |
| 9874 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
9866 createParser("a = 1, b, c = 3;"); | 9875 createParser("a = 1, b, c = 3;"); |
9867 FieldDeclaration declaration = parser.parseInitializedIdentifierList( | 9876 FieldDeclaration declaration = parser.parseInitializedIdentifierList( |
9868 commentAndMetadata(comment), staticKeyword, null, type); | 9877 commentAndMetadata(comment), staticKeyword, null, type); |
9869 expectNotNullIfNoErrors(declaration); | 9878 expectNotNullIfNoErrors(declaration); |
9870 listener.assertNoErrors(); | 9879 listener.assertNoErrors(); |
9871 expect(declaration.documentationComment, comment); | 9880 expect(declaration.documentationComment, comment); |
9872 VariableDeclarationList fields = declaration.fields; | 9881 VariableDeclarationList fields = declaration.fields; |
9873 expect(fields, isNotNull); | 9882 expect(fields, isNotNull); |
9874 expect(fields.keyword, isNull); | 9883 expect(fields.keyword, isNull); |
9875 expect(fields.type, type); | 9884 expect(fields.type, type); |
9876 expect(fields.variables, hasLength(3)); | 9885 expect(fields.variables, hasLength(3)); |
9877 expect(declaration.staticKeyword, staticKeyword); | 9886 expect(declaration.staticKeyword, staticKeyword); |
9878 expect(declaration.semicolon, isNotNull); | 9887 expect(declaration.semicolon, isNotNull); |
9879 } | 9888 } |
9880 | 9889 |
9881 void test_parseInitializedIdentifierList_var() { | 9890 void test_parseInitializedIdentifierList_var() { |
9882 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 9891 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
9883 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 9892 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
9884 Token varKeyword = TokenFactory.tokenFromKeyword(Keyword.VAR); | 9893 Token varKeyword = TokenFactory.tokenFromKeyword(Keyword.VAR); |
9885 createParser('a = 1, b, c = 3;'); | 9894 createParser('a = 1, b, c = 3;'); |
9886 FieldDeclaration declaration = parser.parseInitializedIdentifierList( | 9895 FieldDeclaration declaration = parser.parseInitializedIdentifierList( |
9887 commentAndMetadata(comment), staticKeyword, varKeyword, null); | 9896 commentAndMetadata(comment), staticKeyword, varKeyword, null); |
9888 expectNotNullIfNoErrors(declaration); | 9897 expectNotNullIfNoErrors(declaration); |
9889 listener.assertNoErrors(); | 9898 listener.assertNoErrors(); |
9890 expect(declaration.documentationComment, comment); | 9899 expect(declaration.documentationComment, comment); |
9891 VariableDeclarationList fields = declaration.fields; | 9900 VariableDeclarationList fields = declaration.fields; |
9892 expect(fields, isNotNull); | 9901 expect(fields, isNotNull); |
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11064 expectNotNullIfNoErrors(parameter); | 11073 expectNotNullIfNoErrors(parameter); |
11065 listener.assertNoErrors(); | 11074 listener.assertNoErrors(); |
11066 expect(parameter, new isInstanceOf<SimpleFormalParameter>()); | 11075 expect(parameter, new isInstanceOf<SimpleFormalParameter>()); |
11067 SimpleFormalParameter simpleParameter = parameter; | 11076 SimpleFormalParameter simpleParameter = parameter; |
11068 expect(simpleParameter.keyword, isNull); | 11077 expect(simpleParameter.keyword, isNull); |
11069 expect(simpleParameter.type, isNotNull); | 11078 expect(simpleParameter.type, isNotNull); |
11070 expect(simpleParameter.identifier, isNotNull); | 11079 expect(simpleParameter.identifier, isNotNull); |
11071 } | 11080 } |
11072 | 11081 |
11073 void test_parseOperator() { | 11082 void test_parseOperator() { |
11074 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 11083 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
11075 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 11084 TypeName returnType = |
| 11085 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
11076 createParser('operator +(A a);'); | 11086 createParser('operator +(A a);'); |
11077 MethodDeclaration method = | 11087 MethodDeclaration method = |
11078 parser.parseOperator(commentAndMetadata(comment), null, returnType); | 11088 parser.parseOperator(commentAndMetadata(comment), null, returnType); |
11079 expectNotNullIfNoErrors(method); | 11089 expectNotNullIfNoErrors(method); |
11080 listener.assertNoErrors(); | 11090 listener.assertNoErrors(); |
11081 expect(method.body, isNotNull); | 11091 expect(method.body, isNotNull); |
11082 expect(method.documentationComment, comment); | 11092 expect(method.documentationComment, comment); |
11083 expect(method.externalKeyword, isNull); | 11093 expect(method.externalKeyword, isNull); |
11084 expect(method.modifierKeyword, isNull); | 11094 expect(method.modifierKeyword, isNull); |
11085 expect(method.name, isNotNull); | 11095 expect(method.name, isNotNull); |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11722 void test_parseReturnType_void() { | 11732 void test_parseReturnType_void() { |
11723 createParser('void'); | 11733 createParser('void'); |
11724 TypeName typeName = parser.parseReturnType(); | 11734 TypeName typeName = parser.parseReturnType(); |
11725 expectNotNullIfNoErrors(typeName); | 11735 expectNotNullIfNoErrors(typeName); |
11726 listener.assertNoErrors(); | 11736 listener.assertNoErrors(); |
11727 expect(typeName.name, isNotNull); | 11737 expect(typeName.name, isNotNull); |
11728 expect(typeName.typeArguments, isNull); | 11738 expect(typeName.typeArguments, isNull); |
11729 } | 11739 } |
11730 | 11740 |
11731 void test_parseSetter_nonStatic() { | 11741 void test_parseSetter_nonStatic() { |
11732 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 11742 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
11733 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 11743 TypeName returnType = |
| 11744 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
11734 createParser('set a(var x);'); | 11745 createParser('set a(var x);'); |
11735 MethodDeclaration method = | 11746 MethodDeclaration method = |
11736 parser.parseSetter(commentAndMetadata(comment), null, null, returnType); | 11747 parser.parseSetter(commentAndMetadata(comment), null, null, returnType); |
11737 expectNotNullIfNoErrors(method); | 11748 expectNotNullIfNoErrors(method); |
11738 listener.assertNoErrors(); | 11749 listener.assertNoErrors(); |
11739 expect(method.body, isNotNull); | 11750 expect(method.body, isNotNull); |
11740 expect(method.documentationComment, comment); | 11751 expect(method.documentationComment, comment); |
11741 expect(method.externalKeyword, isNull); | 11752 expect(method.externalKeyword, isNull); |
11742 expect(method.modifierKeyword, isNull); | 11753 expect(method.modifierKeyword, isNull); |
11743 expect(method.name, isNotNull); | 11754 expect(method.name, isNotNull); |
11744 expect(method.operatorKeyword, isNull); | 11755 expect(method.operatorKeyword, isNull); |
11745 expect(method.typeParameters, isNull); | 11756 expect(method.typeParameters, isNull); |
11746 expect(method.parameters, isNotNull); | 11757 expect(method.parameters, isNotNull); |
11747 expect(method.propertyKeyword, isNotNull); | 11758 expect(method.propertyKeyword, isNotNull); |
11748 expect(method.returnType, returnType); | 11759 expect(method.returnType, returnType); |
11749 } | 11760 } |
11750 | 11761 |
11751 void test_parseSetter_static() { | 11762 void test_parseSetter_static() { |
11752 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); | 11763 Comment comment = astFactory.documentationComment(new List<Token>(0)); |
11753 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); | 11764 Token staticKeyword = TokenFactory.tokenFromKeyword(Keyword.STATIC); |
11754 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); | 11765 TypeName returnType = |
| 11766 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
11755 createParser('set a(var x) {}'); | 11767 createParser('set a(var x) {}'); |
11756 MethodDeclaration method = parser.parseSetter( | 11768 MethodDeclaration method = parser.parseSetter( |
11757 commentAndMetadata(comment), null, staticKeyword, returnType); | 11769 commentAndMetadata(comment), null, staticKeyword, returnType); |
11758 expectNotNullIfNoErrors(method); | 11770 expectNotNullIfNoErrors(method); |
11759 listener.assertNoErrors(); | 11771 listener.assertNoErrors(); |
11760 expect(method.body, isNotNull); | 11772 expect(method.body, isNotNull); |
11761 expect(method.documentationComment, comment); | 11773 expect(method.documentationComment, comment); |
11762 expect(method.externalKeyword, isNull); | 11774 expect(method.externalKeyword, isNull); |
11763 expect(method.modifierKeyword, staticKeyword); | 11775 expect(method.modifierKeyword, staticKeyword); |
11764 expect(method.name, isNotNull); | 11776 expect(method.name, isNotNull); |
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13111 createParser('var/*=T*/ x'); | 13123 createParser('var/*=T*/ x'); |
13112 VariableDeclarationList declarationList = parser | 13124 VariableDeclarationList declarationList = parser |
13113 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); | 13125 .parseVariableDeclarationListAfterMetadata(emptyCommentAndMetadata()); |
13114 expectNotNullIfNoErrors(declarationList); | 13126 expectNotNullIfNoErrors(declarationList); |
13115 listener.assertNoErrors(); | 13127 listener.assertNoErrors(); |
13116 expect(declarationList.type.name.name, 'T'); | 13128 expect(declarationList.type.name.name, 'T'); |
13117 expect(declarationList.keyword, isNull); | 13129 expect(declarationList.keyword, isNull); |
13118 } | 13130 } |
13119 | 13131 |
13120 void test_parseVariableDeclarationListAfterType_type() { | 13132 void test_parseVariableDeclarationListAfterType_type() { |
13121 TypeName type = new TypeName(new SimpleIdentifier(null), null); | 13133 TypeName type = |
| 13134 astFactory.typeName(astFactory.simpleIdentifier(null), null); |
13122 createParser('a'); | 13135 createParser('a'); |
13123 VariableDeclarationList declarationList = | 13136 VariableDeclarationList declarationList = |
13124 parser.parseVariableDeclarationListAfterType( | 13137 parser.parseVariableDeclarationListAfterType( |
13125 emptyCommentAndMetadata(), null, type); | 13138 emptyCommentAndMetadata(), null, type); |
13126 expectNotNullIfNoErrors(declarationList); | 13139 expectNotNullIfNoErrors(declarationList); |
13127 listener.assertNoErrors(); | 13140 listener.assertNoErrors(); |
13128 expect(declarationList.keyword, isNull); | 13141 expect(declarationList.keyword, isNull); |
13129 expect(declarationList.type, type); | 13142 expect(declarationList.type, type); |
13130 expect(declarationList.variables, hasLength(1)); | 13143 expect(declarationList.variables, hasLength(1)); |
13131 } | 13144 } |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13445 CompilationUnit _parseDirectives(String source, | 13458 CompilationUnit _parseDirectives(String source, |
13446 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 13459 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
13447 createParser(source); | 13460 createParser(source); |
13448 CompilationUnit unit = parser.parseDirectives2(); | 13461 CompilationUnit unit = parser.parseDirectives2(); |
13449 expect(unit, isNotNull); | 13462 expect(unit, isNotNull); |
13450 expect(unit.declarations, hasLength(0)); | 13463 expect(unit.declarations, hasLength(0)); |
13451 listener.assertErrorsWithCodes(errorCodes); | 13464 listener.assertErrorsWithCodes(errorCodes); |
13452 return unit; | 13465 return unit; |
13453 } | 13466 } |
13454 } | 13467 } |
OLD | NEW |