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