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

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

Issue 1434863003: initial generic method comment parsing (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: re-sort members Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.parser_test; 5 library engine.parser_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 (obj) => obj is MethodInvocation, 197 (obj) => obj is MethodInvocation,
198 MethodInvocation, 198 MethodInvocation,
199 invocation3.function); 199 invocation3.function);
200 expect(invocation4.methodName.name, "a"); 200 expect(invocation4.methodName.name, "a");
201 expect(invocation4.typeArguments, isNull); 201 expect(invocation4.typeArguments, isNull);
202 ArgumentList argumentList4 = invocation4.argumentList; 202 ArgumentList argumentList4 = invocation4.argumentList;
203 expect(argumentList4, isNotNull); 203 expect(argumentList4, isNotNull);
204 expect(argumentList4.arguments, hasLength(1)); 204 expect(argumentList4.arguments, hasLength(1));
205 } 205 }
206 206
207 void test_assignableExpression_arguments_normal_chain_typeArgumentComments() {
208 enableGenericMethodComments = true;
209 _validate_assignableExpression_arguments_normal_chain_typeArguments(
210 "a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e).f");
211 }
212
207 void test_assignableExpression_arguments_normal_chain_typeArguments() { 213 void test_assignableExpression_arguments_normal_chain_typeArguments() {
208 enableGenericMethods = true; 214 enableGenericMethods = true;
209 PropertyAccess propertyAccess1 = parseExpression("a<E>(b)<F>(c).d<G>(e).f"); 215 _validate_assignableExpression_arguments_normal_chain_typeArguments(
210 expect(propertyAccess1.propertyName.name, "f"); 216 "a<E>(b)<F>(c).d<G>(e).f");
211 //
212 // a<E>(b)<F>(c).d>G?(e)
213 //
214 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf(
215 (obj) => obj is MethodInvocation,
216 MethodInvocation,
217 propertyAccess1.target);
218 expect(invocation2.methodName.name, "d");
219 expect(invocation2.typeArguments, isNotNull);
220 ArgumentList argumentList2 = invocation2.argumentList;
221 expect(argumentList2, isNotNull);
222 expect(argumentList2.arguments, hasLength(1));
223 //
224 // a<E>(b)<F>(c)
225 //
226 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf(
227 (obj) => obj is FunctionExpressionInvocation,
228 FunctionExpressionInvocation,
229 invocation2.target);
230 expect(invocation3.typeArguments, isNotNull);
231 ArgumentList argumentList3 = invocation3.argumentList;
232 expect(argumentList3, isNotNull);
233 expect(argumentList3.arguments, hasLength(1));
234 //
235 // a(b)
236 //
237 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf(
238 (obj) => obj is MethodInvocation,
239 MethodInvocation,
240 invocation3.function);
241 expect(invocation4.methodName.name, "a");
242 expect(invocation4.typeArguments, isNotNull);
243 ArgumentList argumentList4 = invocation4.argumentList;
244 expect(argumentList4, isNotNull);
245 expect(argumentList4.arguments, hasLength(1));
246 } 217 }
247 218
248 void test_assignmentExpression_compound() { 219 void test_assignmentExpression_compound() {
249 AssignmentExpression expression = parseExpression("x = y = 0"); 220 AssignmentExpression expression = parseExpression("x = y = 0");
250 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier, 221 EngineTestCase.assertInstanceOf((obj) => obj is SimpleIdentifier,
251 SimpleIdentifier, expression.leftHandSide); 222 SimpleIdentifier, expression.leftHandSide);
252 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression, 223 EngineTestCase.assertInstanceOf((obj) => obj is AssignmentExpression,
253 AssignmentExpression, expression.rightHandSide); 224 AssignmentExpression, expression.rightHandSide);
254 } 225 }
255 226
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 BinaryExpression expression = parseExpression("x << y + z"); 493 BinaryExpression expression = parseExpression("x << y + z");
523 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, 494 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
524 BinaryExpression, expression.rightOperand); 495 BinaryExpression, expression.rightOperand);
525 } 496 }
526 497
527 void test_shiftExpression_super() { 498 void test_shiftExpression_super() {
528 BinaryExpression expression = parseExpression("super >> 4 << 3"); 499 BinaryExpression expression = parseExpression("super >> 4 << 3");
529 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, 500 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression,
530 BinaryExpression, expression.leftOperand); 501 BinaryExpression, expression.leftOperand);
531 } 502 }
503
504 void _validate_assignableExpression_arguments_normal_chain_typeArguments(
505 String code) {
506 PropertyAccess propertyAccess1 = parseExpression(code);
507 expect(propertyAccess1.propertyName.name, "f");
508 //
509 // a<E>(b)<F>(c).d<G>(e)
510 //
511 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf(
512 (obj) => obj is MethodInvocation,
513 MethodInvocation,
514 propertyAccess1.target);
515 expect(invocation2.methodName.name, "d");
516 expect(invocation2.typeArguments, isNotNull);
517 ArgumentList argumentList2 = invocation2.argumentList;
518 expect(argumentList2, isNotNull);
519 expect(argumentList2.arguments, hasLength(1));
520 //
521 // a<E>(b)<F>(c)
522 //
523 FunctionExpressionInvocation invocation3 = EngineTestCase.assertInstanceOf(
524 (obj) => obj is FunctionExpressionInvocation,
525 FunctionExpressionInvocation,
526 invocation2.target);
527 expect(invocation3.typeArguments, isNotNull);
528 ArgumentList argumentList3 = invocation3.argumentList;
529 expect(argumentList3, isNotNull);
530 expect(argumentList3.arguments, hasLength(1));
531 //
532 // a(b)
533 //
534 MethodInvocation invocation4 = EngineTestCase.assertInstanceOf(
535 (obj) => obj is MethodInvocation,
536 MethodInvocation,
537 invocation3.function);
538 expect(invocation4.methodName.name, "a");
539 expect(invocation4.typeArguments, isNotNull);
540 ArgumentList argumentList4 = invocation4.argumentList;
541 expect(argumentList4, isNotNull);
542 expect(argumentList4.arguments, hasLength(1));
543 }
532 } 544 }
533 545
534 /** 546 /**
535 * The class `ErrorParserTest` defines parser tests that test the parsing of cod e to ensure 547 * The class `ErrorParserTest` defines parser tests that test the parsing of cod e to ensure
536 * that errors are correctly reported, and in some cases, not reported. 548 * that errors are correctly reported, and in some cases, not reported.
537 */ 549 */
538 @reflectiveTest 550 @reflectiveTest
539 class ErrorParserTest extends ParserTestCase { 551 class ErrorParserTest extends ParserTestCase {
540 void fail_expectedListOrMapLiteral() { 552 void fail_expectedListOrMapLiteral() {
541 // It isn't clear that this test can ever pass. The parser is currently 553 // It isn't clear that this test can ever pass. The parser is currently
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 void test_localFunctionDeclarationModifier_factory() { 1431 void test_localFunctionDeclarationModifier_factory() {
1420 ParserTestCase.parseStatement("factory f() {}", 1432 ParserTestCase.parseStatement("factory f() {}",
1421 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); 1433 [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]);
1422 } 1434 }
1423 1435
1424 void test_localFunctionDeclarationModifier_static() { 1436 void test_localFunctionDeclarationModifier_static() {
1425 ParserTestCase.parseStatement( 1437 ParserTestCase.parseStatement(
1426 "static f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]); 1438 "static f() {}", [ParserErrorCode.LOCAL_FUNCTION_DECLARATION_MODIFIER]);
1427 } 1439 }
1428 1440
1441 void test_method_invalidTypeParameterComments() {
1442 enableGenericMethodComments = true;
1443 MethodDeclaration method = parse3(
1444 "parseClassMember",
1445 <Object>["C"],
1446 "void m/*<E, hello!>*/() {}",
1447 [
1448 ParserErrorCode.EXPECTED_TOKEN /*>*/,
1449 ParserErrorCode.MISSING_IDENTIFIER,
1450 ParserErrorCode.EXPECTED_TOKEN /*(*/,
1451 ParserErrorCode.EXPECTED_TOKEN /*)*/,
1452 ParserErrorCode.MISSING_FUNCTION_BODY
1453 ]);
1454 expect(method.typeParameters.toString(), '<E, hello>',
1455 reason: 'parser recovers what it can');
1456 }
1457
1458 void test_method_invalidTypeParameters() {
1459 // TODO(jmesserly): ideally we'd be better at parser recovery here.
1460 // It doesn't try to advance past the invalid token `!` to find the
1461 // valid `>`. If it did we'd get less cascading errors, at least for this
1462 // particular example.
1463 enableGenericMethods = true;
1464 MethodDeclaration method = parse3(
1465 "parseClassMember",
1466 <Object>["C"],
1467 "void m<E, hello!>() {}",
1468 [
1469 ParserErrorCode.EXPECTED_TOKEN /*>*/,
1470 ParserErrorCode.MISSING_IDENTIFIER,
1471 ParserErrorCode.EXPECTED_TOKEN /*(*/,
1472 ParserErrorCode.EXPECTED_TOKEN /*)*/,
1473 ParserErrorCode.MISSING_FUNCTION_BODY
1474 ]);
1475 expect(method.typeParameters.toString(), '<E, hello>',
1476 reason: 'parser recovers what it can');
1477 }
1478
1429 void test_missingAssignableSelector_identifiersAssigned() { 1479 void test_missingAssignableSelector_identifiersAssigned() {
1430 parseExpression("x.y = y;"); 1480 parseExpression("x.y = y;");
1431 } 1481 }
1432 1482
1433 void test_missingAssignableSelector_prefix_minusMinus_literal() { 1483 void test_missingAssignableSelector_prefix_minusMinus_literal() {
1434 parseExpression("--0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); 1484 parseExpression("--0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
1435 } 1485 }
1436 1486
1437 void test_missingAssignableSelector_prefix_plusPlus_literal() { 1487 void test_missingAssignableSelector_prefix_plusPlus_literal() {
1438 parseExpression("++0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]); 1488 parseExpression("++0", [ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR]);
(...skipping 1150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2589 */ 2639 */
2590 static bool parseFunctionBodies = true; 2640 static bool parseFunctionBodies = true;
2591 2641
2592 /** 2642 /**
2593 * A flag indicating whether generic method support should be enabled for a 2643 * A flag indicating whether generic method support should be enabled for a
2594 * specific test. 2644 * specific test.
2595 */ 2645 */
2596 bool enableGenericMethods = false; 2646 bool enableGenericMethods = false;
2597 2647
2598 /** 2648 /**
2649 * Whether generic method comments should be enabled for the test.
2650 */
2651 bool enableGenericMethodComments = false;
2652
2653 /**
2599 * Return a CommentAndMetadata object with the given values that can be used f or testing. 2654 * Return a CommentAndMetadata object with the given values that can be used f or testing.
2600 * 2655 *
2601 * @param comment the comment to be wrapped in the object 2656 * @param comment the comment to be wrapped in the object
2602 * @param annotations the annotations to be wrapped in the object 2657 * @param annotations the annotations to be wrapped in the object
2603 * @return a CommentAndMetadata object that can be used for testing 2658 * @return a CommentAndMetadata object that can be used for testing
2604 */ 2659 */
2605 CommentAndMetadata commentAndMetadata(Comment comment, 2660 CommentAndMetadata commentAndMetadata(Comment comment,
2606 [List<Annotation> annotations]) { 2661 [List<Annotation> annotations]) {
2607 return new CommentAndMetadata(comment, annotations); 2662 return new CommentAndMetadata(comment, annotations);
2608 } 2663 }
(...skipping 22 matching lines...) Expand all
2631 * @throws AssertionFailedError if the result is `null` or the errors produced while 2686 * @throws AssertionFailedError if the result is `null` or the errors produced while
2632 * scanning and parsing the source do not match the expected errors 2687 * scanning and parsing the source do not match the expected errors
2633 */ 2688 */
2634 Object invokeParserMethod(String methodName, List<Object> objects, 2689 Object invokeParserMethod(String methodName, List<Object> objects,
2635 String source, GatheringErrorListener listener) { 2690 String source, GatheringErrorListener listener) {
2636 // 2691 //
2637 // Scan the source. 2692 // Scan the source.
2638 // 2693 //
2639 Scanner scanner = 2694 Scanner scanner =
2640 new Scanner(null, new CharSequenceReader(source), listener); 2695 new Scanner(null, new CharSequenceReader(source), listener);
2696 scanner.scanGenericMethodComments = enableGenericMethodComments;
2641 Token tokenStream = scanner.tokenize(); 2697 Token tokenStream = scanner.tokenize();
2642 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2698 listener.setLineInfo(new TestSource(), scanner.lineStarts);
2643 // 2699 //
2644 // Parse the source. 2700 // Parse the source.
2645 // 2701 //
2646 Parser parser = createParser(listener); 2702 Parser parser = createParser(listener);
2647 parser.parseGenericMethods = enableGenericMethods; 2703 parser.parseGenericMethods = enableGenericMethods;
2704 parser.parseGenericMethodComments = enableGenericMethodComments;
2648 parser.parseFunctionBodies = parseFunctionBodies; 2705 parser.parseFunctionBodies = parseFunctionBodies;
2649 Object result = 2706 Object result =
2650 invokeParserMethodImpl(parser, methodName, objects, tokenStream); 2707 invokeParserMethodImpl(parser, methodName, objects, tokenStream);
2651 // 2708 //
2652 // Partially test the results. 2709 // Partially test the results.
2653 // 2710 //
2654 if (!listener.hasErrors) { 2711 if (!listener.hasErrors) {
2655 expect(result, isNotNull); 2712 expect(result, isNotNull);
2656 } 2713 }
2657 return result; 2714 return result;
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 * @param errorCodes the error codes of the errors that are expected to be fou nd 2822 * @param errorCodes the error codes of the errors that are expected to be fou nd
2766 * @return the expression that was parsed 2823 * @return the expression that was parsed
2767 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do 2824 * @throws Exception if the source could not be parsed, if the compilation err ors in the source do
2768 * not match those that are expected, or if the result would have be en `null` 2825 * not match those that are expected, or if the result would have be en `null`
2769 */ 2826 */
2770 Expression parseExpression(String source, 2827 Expression parseExpression(String source,
2771 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { 2828 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) {
2772 GatheringErrorListener listener = new GatheringErrorListener(); 2829 GatheringErrorListener listener = new GatheringErrorListener();
2773 Scanner scanner = 2830 Scanner scanner =
2774 new Scanner(null, new CharSequenceReader(source), listener); 2831 new Scanner(null, new CharSequenceReader(source), listener);
2832 scanner.scanGenericMethodComments = enableGenericMethodComments;
2775 listener.setLineInfo(new TestSource(), scanner.lineStarts); 2833 listener.setLineInfo(new TestSource(), scanner.lineStarts);
2776 Token token = scanner.tokenize(); 2834 Token token = scanner.tokenize();
2777 Parser parser = createParser(listener); 2835 Parser parser = createParser(listener);
2778 parser.parseGenericMethods = enableGenericMethods; 2836 parser.parseGenericMethods = enableGenericMethods;
2837 parser.parseGenericMethodComments = enableGenericMethodComments;
2779 Expression expression = parser.parseExpression(token); 2838 Expression expression = parser.parseExpression(token);
2780 expect(expression, isNotNull); 2839 expect(expression, isNotNull);
2781 listener.assertErrorsWithCodes(errorCodes); 2840 listener.assertErrorsWithCodes(errorCodes);
2782 return expression; 2841 return expression;
2783 } 2842 }
2784 2843
2785 @override 2844 @override
2786 void setUp() { 2845 void setUp() {
2787 super.setUp(); 2846 super.setUp();
2788 parseFunctionBodies = true; 2847 parseFunctionBodies = true;
(...skipping 1845 matching lines...) Expand 10 before | Expand all | Expand 10 after
4634 parse("parseCommentReference", <Object>["this", 5], ""); 4693 parse("parseCommentReference", <Object>["this", 5], "");
4635 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf( 4694 SimpleIdentifier identifier = EngineTestCase.assertInstanceOf(
4636 (obj) => obj is SimpleIdentifier, 4695 (obj) => obj is SimpleIdentifier,
4637 SimpleIdentifier, 4696 SimpleIdentifier,
4638 reference.identifier); 4697 reference.identifier);
4639 expect(identifier.token, isNotNull); 4698 expect(identifier.token, isNotNull);
4640 expect(identifier.name, "a"); 4699 expect(identifier.name, "a");
4641 expect(identifier.offset, 5); 4700 expect(identifier.offset, 5);
4642 } 4701 }
4643 4702
4703 void fail_parseStatement_functionDeclaration_noReturnType_typeParameters() {
4704 enableGenericMethods = true;
4705 FunctionDeclarationStatement statement =
4706 parse4("parseStatement", "f<E>(a, b) {};");
4707 expect(statement.functionDeclaration, isNotNull);
4708 }
4709
4644 void test_computeStringValue_emptyInterpolationPrefix() { 4710 void test_computeStringValue_emptyInterpolationPrefix() {
4645 expect(_computeStringValue("'''", true, false), ""); 4711 expect(_computeStringValue("'''", true, false), "");
4646 } 4712 }
4647 4713
4648 void test_computeStringValue_escape_b() { 4714 void test_computeStringValue_escape_b() {
4649 expect(_computeStringValue("'\\b'", true, true), "\b"); 4715 expect(_computeStringValue("'\\b'", true, true), "\b");
4650 } 4716 }
4651 4717
4652 void test_computeStringValue_escape_f() { 4718 void test_computeStringValue_escape_f() {
4653 expect(_computeStringValue("'\\f'", true, true), "\f"); 4719 expect(_computeStringValue("'\\f'", true, true), "\f");
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
5103 propertyAccess.target as FunctionExpressionInvocation; 5169 propertyAccess.target as FunctionExpressionInvocation;
5104 expect(invocation.function, isNotNull); 5170 expect(invocation.function, isNotNull);
5105 expect(invocation.typeArguments, isNull); 5171 expect(invocation.typeArguments, isNull);
5106 ArgumentList argumentList = invocation.argumentList; 5172 ArgumentList argumentList = invocation.argumentList;
5107 expect(argumentList, isNotNull); 5173 expect(argumentList, isNotNull);
5108 expect(argumentList.arguments, hasLength(1)); 5174 expect(argumentList.arguments, hasLength(1));
5109 expect(propertyAccess.operator, isNotNull); 5175 expect(propertyAccess.operator, isNotNull);
5110 expect(propertyAccess.propertyName, isNotNull); 5176 expect(propertyAccess.propertyName, isNotNull);
5111 } 5177 }
5112 5178
5179 void test_parseAssignableExpression_expression_args_dot_typeParameterComments( ) {
5180 enableGenericMethodComments = true;
5181 PropertyAccess propertyAccess =
5182 parse("parseAssignableExpression", <Object>[false], "(x)/*<F>*/(y).z");
5183 FunctionExpressionInvocation invocation =
5184 propertyAccess.target as FunctionExpressionInvocation;
5185 expect(invocation.function, isNotNull);
5186 expect(invocation.typeArguments, isNotNull);
5187 ArgumentList argumentList = invocation.argumentList;
5188 expect(argumentList, isNotNull);
5189 expect(argumentList.arguments, hasLength(1));
5190 expect(propertyAccess.operator, isNotNull);
5191 expect(propertyAccess.propertyName, isNotNull);
5192 }
5193
5113 void test_parseAssignableExpression_expression_args_dot_typeParameters() { 5194 void test_parseAssignableExpression_expression_args_dot_typeParameters() {
5114 enableGenericMethods = true; 5195 enableGenericMethods = true;
5115 PropertyAccess propertyAccess = 5196 PropertyAccess propertyAccess =
5116 parse("parseAssignableExpression", <Object>[false], "(x)<F>(y).z"); 5197 parse("parseAssignableExpression", <Object>[false], "(x)<F>(y).z");
5117 FunctionExpressionInvocation invocation = 5198 FunctionExpressionInvocation invocation =
5118 propertyAccess.target as FunctionExpressionInvocation; 5199 propertyAccess.target as FunctionExpressionInvocation;
5119 expect(invocation.function, isNotNull); 5200 expect(invocation.function, isNotNull);
5120 expect(invocation.typeArguments, isNotNull); 5201 expect(invocation.typeArguments, isNotNull);
5121 ArgumentList argumentList = invocation.argumentList; 5202 ArgumentList argumentList = invocation.argumentList;
5122 expect(argumentList, isNotNull); 5203 expect(argumentList, isNotNull);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
5162 MethodInvocation invocation = propertyAccess.target as MethodInvocation; 5243 MethodInvocation invocation = propertyAccess.target as MethodInvocation;
5163 expect(invocation.methodName.name, "x"); 5244 expect(invocation.methodName.name, "x");
5164 expect(invocation.typeArguments, isNull); 5245 expect(invocation.typeArguments, isNull);
5165 ArgumentList argumentList = invocation.argumentList; 5246 ArgumentList argumentList = invocation.argumentList;
5166 expect(argumentList, isNotNull); 5247 expect(argumentList, isNotNull);
5167 expect(argumentList.arguments, hasLength(1)); 5248 expect(argumentList.arguments, hasLength(1));
5168 expect(propertyAccess.operator, isNotNull); 5249 expect(propertyAccess.operator, isNotNull);
5169 expect(propertyAccess.propertyName, isNotNull); 5250 expect(propertyAccess.propertyName, isNotNull);
5170 } 5251 }
5171 5252
5253 void test_parseAssignableExpression_identifier_args_dot_typeParameterComments( ) {
5254 enableGenericMethodComments = true;
5255 PropertyAccess propertyAccess =
5256 parse("parseAssignableExpression", <Object>[false], "x/*<E>*/(y).z");
5257 MethodInvocation invocation = propertyAccess.target as MethodInvocation;
5258 expect(invocation.methodName.name, "x");
5259 expect(invocation.typeArguments, isNotNull);
5260 ArgumentList argumentList = invocation.argumentList;
5261 expect(argumentList, isNotNull);
5262 expect(argumentList.arguments, hasLength(1));
5263 expect(propertyAccess.operator, isNotNull);
5264 expect(propertyAccess.propertyName, isNotNull);
5265 }
5266
5172 void test_parseAssignableExpression_identifier_args_dot_typeParameters() { 5267 void test_parseAssignableExpression_identifier_args_dot_typeParameters() {
5173 enableGenericMethods = true; 5268 enableGenericMethods = true;
5174 PropertyAccess propertyAccess = 5269 PropertyAccess propertyAccess =
5175 parse("parseAssignableExpression", <Object>[false], "x<E>(y).z"); 5270 parse("parseAssignableExpression", <Object>[false], "x<E>(y).z");
5176 MethodInvocation invocation = propertyAccess.target as MethodInvocation; 5271 MethodInvocation invocation = propertyAccess.target as MethodInvocation;
5177 expect(invocation.methodName.name, "x"); 5272 expect(invocation.methodName.name, "x");
5178 expect(invocation.typeArguments, isNotNull); 5273 expect(invocation.typeArguments, isNotNull);
5179 ArgumentList argumentList = invocation.argumentList; 5274 ArgumentList argumentList = invocation.argumentList;
5180 expect(argumentList, isNotNull); 5275 expect(argumentList, isNotNull);
5181 expect(argumentList.arguments, hasLength(1)); 5276 expect(argumentList.arguments, hasLength(1));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
5384 5479
5385 void test_parseCascadeSection_ia() { 5480 void test_parseCascadeSection_ia() {
5386 FunctionExpressionInvocation section = 5481 FunctionExpressionInvocation section =
5387 parse4("parseCascadeSection", "..[i](b)"); 5482 parse4("parseCascadeSection", "..[i](b)");
5388 EngineTestCase.assertInstanceOf( 5483 EngineTestCase.assertInstanceOf(
5389 (obj) => obj is IndexExpression, IndexExpression, section.function); 5484 (obj) => obj is IndexExpression, IndexExpression, section.function);
5390 expect(section.typeArguments, isNull); 5485 expect(section.typeArguments, isNull);
5391 expect(section.argumentList, isNotNull); 5486 expect(section.argumentList, isNotNull);
5392 } 5487 }
5393 5488
5489 void test_parseCascadeSection_ia_typeArgumentComments() {
5490 enableGenericMethodComments = true;
5491 FunctionExpressionInvocation section =
5492 parse4("parseCascadeSection", "..[i]/*<E>*/(b)");
5493 EngineTestCase.assertInstanceOf(
5494 (obj) => obj is IndexExpression, IndexExpression, section.function);
5495 expect(section.typeArguments, isNotNull);
5496 expect(section.argumentList, isNotNull);
5497 }
5498
5394 void test_parseCascadeSection_ia_typeArguments() { 5499 void test_parseCascadeSection_ia_typeArguments() {
5395 enableGenericMethods = true; 5500 enableGenericMethods = true;
5396 FunctionExpressionInvocation section = 5501 FunctionExpressionInvocation section =
5397 parse4("parseCascadeSection", "..[i]<E>(b)"); 5502 parse4("parseCascadeSection", "..[i]<E>(b)");
5398 EngineTestCase.assertInstanceOf( 5503 EngineTestCase.assertInstanceOf(
5399 (obj) => obj is IndexExpression, IndexExpression, section.function); 5504 (obj) => obj is IndexExpression, IndexExpression, section.function);
5400 expect(section.typeArguments, isNotNull); 5505 expect(section.typeArguments, isNotNull);
5401 expect(section.argumentList, isNotNull); 5506 expect(section.argumentList, isNotNull);
5402 } 5507 }
5403 5508
5404 void test_parseCascadeSection_ii() { 5509 void test_parseCascadeSection_ii() {
5405 MethodInvocation section = parse4("parseCascadeSection", "..a(b).c(d)"); 5510 MethodInvocation section = parse4("parseCascadeSection", "..a(b).c(d)");
5406 EngineTestCase.assertInstanceOf( 5511 EngineTestCase.assertInstanceOf(
5407 (obj) => obj is MethodInvocation, MethodInvocation, section.target); 5512 (obj) => obj is MethodInvocation, MethodInvocation, section.target);
5408 expect(section.operator, isNotNull); 5513 expect(section.operator, isNotNull);
5409 expect(section.methodName, isNotNull); 5514 expect(section.methodName, isNotNull);
5410 expect(section.typeArguments, isNull); 5515 expect(section.typeArguments, isNull);
5411 expect(section.argumentList, isNotNull); 5516 expect(section.argumentList, isNotNull);
5412 expect(section.argumentList.arguments, hasLength(1)); 5517 expect(section.argumentList.arguments, hasLength(1));
5413 } 5518 }
5414 5519
5520 void test_parseCascadeSection_ii_typeArgumentComments() {
5521 enableGenericMethodComments = true;
5522 MethodInvocation section =
5523 parse4("parseCascadeSection", "..a/*<E>*/(b).c/*<F>*/(d)");
5524 EngineTestCase.assertInstanceOf(
5525 (obj) => obj is MethodInvocation, MethodInvocation, section.target);
5526 expect(section.operator, isNotNull);
5527 expect(section.methodName, isNotNull);
5528 expect(section.typeArguments, isNotNull);
5529 expect(section.argumentList, isNotNull);
5530 expect(section.argumentList.arguments, hasLength(1));
5531 }
5532
5415 void test_parseCascadeSection_ii_typeArguments() { 5533 void test_parseCascadeSection_ii_typeArguments() {
5416 enableGenericMethods = true; 5534 enableGenericMethods = true;
5417 MethodInvocation section = 5535 MethodInvocation section =
5418 parse4("parseCascadeSection", "..a<E>(b).c<F>(d)"); 5536 parse4("parseCascadeSection", "..a<E>(b).c<F>(d)");
5419 EngineTestCase.assertInstanceOf( 5537 EngineTestCase.assertInstanceOf(
5420 (obj) => obj is MethodInvocation, MethodInvocation, section.target); 5538 (obj) => obj is MethodInvocation, MethodInvocation, section.target);
5421 expect(section.operator, isNotNull); 5539 expect(section.operator, isNotNull);
5422 expect(section.methodName, isNotNull); 5540 expect(section.methodName, isNotNull);
5423 expect(section.typeArguments, isNotNull); 5541 expect(section.typeArguments, isNotNull);
5424 expect(section.argumentList, isNotNull); 5542 expect(section.argumentList, isNotNull);
(...skipping 18 matching lines...) Expand all
5443 void test_parseCascadeSection_p_assign_withCascade() { 5561 void test_parseCascadeSection_p_assign_withCascade() {
5444 AssignmentExpression section = 5562 AssignmentExpression section =
5445 parse4("parseCascadeSection", "..a = 3..m()"); 5563 parse4("parseCascadeSection", "..a = 3..m()");
5446 expect(section.leftHandSide, isNotNull); 5564 expect(section.leftHandSide, isNotNull);
5447 expect(section.operator, isNotNull); 5565 expect(section.operator, isNotNull);
5448 Expression rhs = section.rightHandSide; 5566 Expression rhs = section.rightHandSide;
5449 EngineTestCase.assertInstanceOf( 5567 EngineTestCase.assertInstanceOf(
5450 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); 5568 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs);
5451 } 5569 }
5452 5570
5571 void test_parseCascadeSection_p_assign_withCascade_typeArgumentComments() {
5572 enableGenericMethodComments = true;
5573 AssignmentExpression section =
5574 parse4("parseCascadeSection", "..a = 3..m/*<E>*/()");
5575 expect(section.leftHandSide, isNotNull);
5576 expect(section.operator, isNotNull);
5577 Expression rhs = section.rightHandSide;
5578 EngineTestCase.assertInstanceOf(
5579 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs);
5580 }
5581
5453 void test_parseCascadeSection_p_assign_withCascade_typeArguments() { 5582 void test_parseCascadeSection_p_assign_withCascade_typeArguments() {
5454 enableGenericMethods = true; 5583 enableGenericMethods = true;
5455 AssignmentExpression section = 5584 AssignmentExpression section =
5456 parse4("parseCascadeSection", "..a = 3..m<E>()"); 5585 parse4("parseCascadeSection", "..a = 3..m<E>()");
5457 expect(section.leftHandSide, isNotNull); 5586 expect(section.leftHandSide, isNotNull);
5458 expect(section.operator, isNotNull); 5587 expect(section.operator, isNotNull);
5459 Expression rhs = section.rightHandSide; 5588 Expression rhs = section.rightHandSide;
5460 EngineTestCase.assertInstanceOf( 5589 EngineTestCase.assertInstanceOf(
5461 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs); 5590 (obj) => obj is IntegerLiteral, IntegerLiteral, rhs);
5462 } 5591 }
5463 5592
5464 void test_parseCascadeSection_p_builtIn() { 5593 void test_parseCascadeSection_p_builtIn() {
5465 PropertyAccess section = parse4("parseCascadeSection", "..as"); 5594 PropertyAccess section = parse4("parseCascadeSection", "..as");
5466 expect(section.target, isNull); 5595 expect(section.target, isNull);
5467 expect(section.operator, isNotNull); 5596 expect(section.operator, isNotNull);
5468 expect(section.propertyName, isNotNull); 5597 expect(section.propertyName, isNotNull);
5469 } 5598 }
5470 5599
5471 void test_parseCascadeSection_pa() { 5600 void test_parseCascadeSection_pa() {
5472 MethodInvocation section = parse4("parseCascadeSection", "..a(b)"); 5601 MethodInvocation section = parse4("parseCascadeSection", "..a(b)");
5473 expect(section.target, isNull); 5602 expect(section.target, isNull);
5474 expect(section.operator, isNotNull); 5603 expect(section.operator, isNotNull);
5475 expect(section.methodName, isNotNull); 5604 expect(section.methodName, isNotNull);
5476 expect(section.typeArguments, isNull); 5605 expect(section.typeArguments, isNull);
5477 expect(section.argumentList, isNotNull); 5606 expect(section.argumentList, isNotNull);
5478 expect(section.argumentList.arguments, hasLength(1)); 5607 expect(section.argumentList.arguments, hasLength(1));
5479 } 5608 }
5480 5609
5610 void test_parseCascadeSection_pa_typeArgumentComments() {
5611 enableGenericMethodComments = true;
5612 MethodInvocation section = parse4("parseCascadeSection", "..a/*<E>*/(b)");
5613 expect(section.target, isNull);
5614 expect(section.operator, isNotNull);
5615 expect(section.methodName, isNotNull);
5616 expect(section.typeArguments, isNotNull);
5617 expect(section.argumentList, isNotNull);
5618 expect(section.argumentList.arguments, hasLength(1));
5619 }
5620
5481 void test_parseCascadeSection_pa_typeArguments() { 5621 void test_parseCascadeSection_pa_typeArguments() {
5482 enableGenericMethods = true; 5622 enableGenericMethods = true;
5483 MethodInvocation section = parse4("parseCascadeSection", "..a<E>(b)"); 5623 MethodInvocation section = parse4("parseCascadeSection", "..a<E>(b)");
5484 expect(section.target, isNull); 5624 expect(section.target, isNull);
5485 expect(section.operator, isNotNull); 5625 expect(section.operator, isNotNull);
5486 expect(section.methodName, isNotNull); 5626 expect(section.methodName, isNotNull);
5487 expect(section.typeArguments, isNotNull); 5627 expect(section.typeArguments, isNotNull);
5488 expect(section.argumentList, isNotNull); 5628 expect(section.argumentList, isNotNull);
5489 expect(section.argumentList.arguments, hasLength(1)); 5629 expect(section.argumentList.arguments, hasLength(1));
5490 } 5630 }
5491 5631
5492 void test_parseCascadeSection_paa() { 5632 void test_parseCascadeSection_paa() {
5493 FunctionExpressionInvocation section = 5633 FunctionExpressionInvocation section =
5494 parse4("parseCascadeSection", "..a(b)(c)"); 5634 parse4("parseCascadeSection", "..a(b)(c)");
5495 EngineTestCase.assertInstanceOf( 5635 EngineTestCase.assertInstanceOf(
5496 (obj) => obj is MethodInvocation, MethodInvocation, section.function); 5636 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5497 expect(section.typeArguments, isNull); 5637 expect(section.typeArguments, isNull);
5498 expect(section.argumentList, isNotNull); 5638 expect(section.argumentList, isNotNull);
5499 expect(section.argumentList.arguments, hasLength(1)); 5639 expect(section.argumentList.arguments, hasLength(1));
5500 } 5640 }
5501 5641
5642 void test_parseCascadeSection_paa_typeArgumentComments() {
5643 enableGenericMethodComments = true;
5644 FunctionExpressionInvocation section =
5645 parse4("parseCascadeSection", "..a/*<E>*/(b)/*<F>*/(c)");
5646 EngineTestCase.assertInstanceOf(
5647 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5648 expect(section.typeArguments, isNotNull);
5649 expect(section.argumentList, isNotNull);
5650 expect(section.argumentList.arguments, hasLength(1));
5651 }
5652
5502 void test_parseCascadeSection_paa_typeArguments() { 5653 void test_parseCascadeSection_paa_typeArguments() {
5503 enableGenericMethods = true; 5654 enableGenericMethods = true;
5504 FunctionExpressionInvocation section = 5655 FunctionExpressionInvocation section =
5505 parse4("parseCascadeSection", "..a<E>(b)<F>(c)"); 5656 parse4("parseCascadeSection", "..a<E>(b)<F>(c)");
5506 EngineTestCase.assertInstanceOf( 5657 EngineTestCase.assertInstanceOf(
5507 (obj) => obj is MethodInvocation, MethodInvocation, section.function); 5658 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5508 expect(section.typeArguments, isNotNull); 5659 expect(section.typeArguments, isNotNull);
5509 expect(section.argumentList, isNotNull); 5660 expect(section.argumentList, isNotNull);
5510 expect(section.argumentList.arguments, hasLength(1)); 5661 expect(section.argumentList.arguments, hasLength(1));
5511 } 5662 }
5512 5663
5513 void test_parseCascadeSection_paapaa() { 5664 void test_parseCascadeSection_paapaa() {
5514 FunctionExpressionInvocation section = 5665 FunctionExpressionInvocation section =
5515 parse4("parseCascadeSection", "..a(b)(c).d(e)(f)"); 5666 parse4("parseCascadeSection", "..a(b)(c).d(e)(f)");
5516 EngineTestCase.assertInstanceOf( 5667 EngineTestCase.assertInstanceOf(
5517 (obj) => obj is MethodInvocation, MethodInvocation, section.function); 5668 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5518 expect(section.typeArguments, isNull); 5669 expect(section.typeArguments, isNull);
5519 expect(section.argumentList, isNotNull); 5670 expect(section.argumentList, isNotNull);
5520 expect(section.argumentList.arguments, hasLength(1)); 5671 expect(section.argumentList.arguments, hasLength(1));
5521 } 5672 }
5522 5673
5674 void test_parseCascadeSection_paapaa_typeArgumentComments() {
5675 enableGenericMethodComments = true;
5676 FunctionExpressionInvocation section = parse4(
5677 "parseCascadeSection", "..a/*<E>*/(b)/*<F>*/(c).d/*<G>*/(e)/*<H>*/(f)");
5678 EngineTestCase.assertInstanceOf(
5679 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5680 expect(section.typeArguments, isNotNull);
5681 expect(section.argumentList, isNotNull);
5682 expect(section.argumentList.arguments, hasLength(1));
5683 }
5684
5523 void test_parseCascadeSection_paapaa_typeArguments() { 5685 void test_parseCascadeSection_paapaa_typeArguments() {
5524 enableGenericMethods = true; 5686 enableGenericMethods = true;
5525 FunctionExpressionInvocation section = 5687 FunctionExpressionInvocation section =
5526 parse4("parseCascadeSection", "..a<E>(b)<F>(c).d<G>(e)<H>(f)"); 5688 parse4("parseCascadeSection", "..a<E>(b)<F>(c).d<G>(e)<H>(f)");
5527 EngineTestCase.assertInstanceOf( 5689 EngineTestCase.assertInstanceOf(
5528 (obj) => obj is MethodInvocation, MethodInvocation, section.function); 5690 (obj) => obj is MethodInvocation, MethodInvocation, section.function);
5529 expect(section.typeArguments, isNotNull); 5691 expect(section.typeArguments, isNotNull);
5530 expect(section.argumentList, isNotNull); 5692 expect(section.argumentList, isNotNull);
5531 expect(section.argumentList.arguments, hasLength(1)); 5693 expect(section.argumentList.arguments, hasLength(1));
5532 } 5694 }
5533 5695
5534 void test_parseCascadeSection_pap() { 5696 void test_parseCascadeSection_pap() {
5535 PropertyAccess section = parse4("parseCascadeSection", "..a(b).c"); 5697 PropertyAccess section = parse4("parseCascadeSection", "..a(b).c");
5536 expect(section.target, isNotNull); 5698 expect(section.target, isNotNull);
5537 expect(section.operator, isNotNull); 5699 expect(section.operator, isNotNull);
5538 expect(section.propertyName, isNotNull); 5700 expect(section.propertyName, isNotNull);
5539 } 5701 }
5540 5702
5703 void test_parseCascadeSection_pap_typeArgumentComments() {
5704 enableGenericMethodComments = true;
5705 PropertyAccess section = parse4("parseCascadeSection", "..a/*<E>*/(b).c");
5706 expect(section.target, isNotNull);
5707 expect(section.operator, isNotNull);
5708 expect(section.propertyName, isNotNull);
5709 }
5710
5541 void test_parseCascadeSection_pap_typeArguments() { 5711 void test_parseCascadeSection_pap_typeArguments() {
5542 enableGenericMethods = true; 5712 enableGenericMethods = true;
5543 PropertyAccess section = parse4("parseCascadeSection", "..a<E>(b).c"); 5713 PropertyAccess section = parse4("parseCascadeSection", "..a<E>(b).c");
5544 expect(section.target, isNotNull); 5714 expect(section.target, isNotNull);
5545 expect(section.operator, isNotNull); 5715 expect(section.operator, isNotNull);
5546 expect(section.propertyName, isNotNull); 5716 expect(section.propertyName, isNotNull);
5547 } 5717 }
5548 5718
5549 void test_parseClassDeclaration_abstract() { 5719 void test_parseClassDeclaration_abstract() {
5550 ClassDeclaration declaration = parse( 5720 ClassDeclaration declaration = parse(
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
5860 expect(method.externalKeyword, isNotNull); 6030 expect(method.externalKeyword, isNotNull);
5861 expect(method.modifierKeyword, isNull); 6031 expect(method.modifierKeyword, isNull);
5862 expect(method.name, isNotNull); 6032 expect(method.name, isNotNull);
5863 expect(method.operatorKeyword, isNull); 6033 expect(method.operatorKeyword, isNull);
5864 expect(method.typeParameters, isNull); 6034 expect(method.typeParameters, isNull);
5865 expect(method.parameters, isNotNull); 6035 expect(method.parameters, isNotNull);
5866 expect(method.propertyKeyword, isNull); 6036 expect(method.propertyKeyword, isNull);
5867 expect(method.returnType, isNotNull); 6037 expect(method.returnType, isNotNull);
5868 } 6038 }
5869 6039
6040 void test_parseClassMember_method_generic_comment_noReturnType() {
6041 enableGenericMethodComments = true;
6042 MethodDeclaration method =
6043 parse("parseClassMember", <Object>["C"], "m/*<T>*/() {}");
6044 expect(method.documentationComment, isNull);
6045 expect(method.externalKeyword, isNull);
6046 expect(method.modifierKeyword, isNull);
6047 expect(method.propertyKeyword, isNull);
6048 expect(method.returnType, isNull);
6049 expect(method.name, isNotNull);
6050 expect(method.operatorKeyword, isNull);
6051 expect(method.typeParameters, isNotNull);
6052 expect(method.parameters, isNotNull);
6053 expect(method.body, isNotNull);
6054 }
6055
6056 void test_parseClassMember_method_generic_comment_returnType() {
6057 enableGenericMethodComments = true;
6058 MethodDeclaration method =
6059 parse("parseClassMember", <Object>["C"], "/*=T*/ m/*<T>*/() {}");
6060 expect(method.documentationComment, isNull);
6061 expect(method.externalKeyword, isNull);
6062 expect(method.modifierKeyword, isNull);
6063 expect(method.propertyKeyword, isNull);
6064 expect(method.returnType.name.name, 'T');
6065 expect(method.name, isNotNull);
6066 expect(method.operatorKeyword, isNull);
6067 expect(method.typeParameters, isNotNull);
6068 expect(method.parameters, isNotNull);
6069 expect(method.body, isNotNull);
6070 }
6071
6072 void test_parseClassMember_method_generic_comment_returnType_bound() {
6073 enableGenericMethodComments = true;
6074 MethodDeclaration method = parse("parseClassMember", <Object>["C"],
6075 "num/*=T*/ m/*<T extends num>*/() {}");
6076 expect(method.documentationComment, isNull);
6077 expect(method.externalKeyword, isNull);
6078 expect(method.modifierKeyword, isNull);
6079 expect(method.propertyKeyword, isNull);
6080 expect(method.returnType.name.name, 'T');
6081 expect(method.name, isNotNull);
6082 expect(method.operatorKeyword, isNull);
6083 expect(method.typeParameters, isNotNull);
6084 TypeParameter tp = method.typeParameters.typeParameters[0];
6085 expect(tp.name.name, 'T');
6086 expect(tp.extendsKeyword, isNotNull);
6087 expect(tp.bound.name.name, 'num');
6088 expect(method.parameters, isNotNull);
6089 expect(method.body, isNotNull);
6090 }
6091
6092 void test_parseClassMember_method_generic_comment_void() {
6093 enableGenericMethodComments = true;
6094 MethodDeclaration method =
6095 parse("parseClassMember", <Object>["C"], "void m/*<T>*/() {}");
6096 expect(method.documentationComment, isNull);
6097 expect(method.externalKeyword, isNull);
6098 expect(method.modifierKeyword, isNull);
6099 expect(method.propertyKeyword, isNull);
6100 expect(method.returnType, isNotNull);
6101 expect(method.name, isNotNull);
6102 expect(method.operatorKeyword, isNull);
6103 expect(method.typeParameters, isNotNull);
6104 expect(method.parameters, isNotNull);
6105 expect(method.body, isNotNull);
6106 }
6107
5870 void test_parseClassMember_method_generic_noReturnType() { 6108 void test_parseClassMember_method_generic_noReturnType() {
5871 enableGenericMethods = true; 6109 enableGenericMethods = true;
5872 MethodDeclaration method = 6110 MethodDeclaration method =
5873 parse("parseClassMember", <Object>["C"], "m<T>() {}"); 6111 parse("parseClassMember", <Object>["C"], "m<T>() {}");
5874 expect(method.documentationComment, isNull); 6112 expect(method.documentationComment, isNull);
5875 expect(method.externalKeyword, isNull); 6113 expect(method.externalKeyword, isNull);
5876 expect(method.modifierKeyword, isNull); 6114 expect(method.modifierKeyword, isNull);
5877 expect(method.propertyKeyword, isNull); 6115 expect(method.propertyKeyword, isNull);
5878 expect(method.returnType, isNull); 6116 expect(method.returnType, isNull);
5879 expect(method.name, isNotNull); 6117 expect(method.name, isNotNull);
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
7332 } 7570 }
7333 7571
7334 void test_parseExpression_superMethodInvocation() { 7572 void test_parseExpression_superMethodInvocation() {
7335 MethodInvocation invocation = parse4("parseExpression", "super.m()"); 7573 MethodInvocation invocation = parse4("parseExpression", "super.m()");
7336 expect(invocation.target, isNotNull); 7574 expect(invocation.target, isNotNull);
7337 expect(invocation.methodName, isNotNull); 7575 expect(invocation.methodName, isNotNull);
7338 expect(invocation.typeArguments, isNull); 7576 expect(invocation.typeArguments, isNull);
7339 expect(invocation.argumentList, isNotNull); 7577 expect(invocation.argumentList, isNotNull);
7340 } 7578 }
7341 7579
7580 void test_parseExpression_superMethodInvocation_typeArgumentComments() {
7581 enableGenericMethodComments = true;
7582 MethodInvocation invocation = parse4("parseExpression", "super.m/*<E>*/()");
7583 expect(invocation.target, isNotNull);
7584 expect(invocation.methodName, isNotNull);
7585 expect(invocation.typeArguments, isNotNull);
7586 expect(invocation.argumentList, isNotNull);
7587 }
7588
7342 void test_parseExpression_superMethodInvocation_typeArguments() { 7589 void test_parseExpression_superMethodInvocation_typeArguments() {
7343 enableGenericMethods = true; 7590 enableGenericMethods = true;
7344 MethodInvocation invocation = parse4("parseExpression", "super.m<E>()"); 7591 MethodInvocation invocation = parse4("parseExpression", "super.m<E>()");
7345 expect(invocation.target, isNotNull); 7592 expect(invocation.target, isNotNull);
7346 expect(invocation.methodName, isNotNull); 7593 expect(invocation.methodName, isNotNull);
7347 expect(invocation.typeArguments, isNotNull); 7594 expect(invocation.typeArguments, isNotNull);
7348 expect(invocation.argumentList, isNotNull); 7595 expect(invocation.argumentList, isNotNull);
7349 } 7596 }
7350 7597
7351 void test_parseExpressionList_multiple() { 7598 void test_parseExpressionList_multiple() {
(...skipping 27 matching lines...) Expand all
7379 7626
7380 void test_parseExpressionWithoutCascade_superMethodInvocation() { 7627 void test_parseExpressionWithoutCascade_superMethodInvocation() {
7381 MethodInvocation invocation = 7628 MethodInvocation invocation =
7382 parse4("parseExpressionWithoutCascade", "super.m()"); 7629 parse4("parseExpressionWithoutCascade", "super.m()");
7383 expect(invocation.target, isNotNull); 7630 expect(invocation.target, isNotNull);
7384 expect(invocation.methodName, isNotNull); 7631 expect(invocation.methodName, isNotNull);
7385 expect(invocation.typeArguments, isNull); 7632 expect(invocation.typeArguments, isNull);
7386 expect(invocation.argumentList, isNotNull); 7633 expect(invocation.argumentList, isNotNull);
7387 } 7634 }
7388 7635
7636 void test_parseExpressionWithoutCascade_superMethodInvocation_typeArgumentComm ents() {
7637 enableGenericMethodComments = true;
7638 MethodInvocation invocation =
7639 parse4("parseExpressionWithoutCascade", "super.m/*<E>*/()");
7640 expect(invocation.target, isNotNull);
7641 expect(invocation.methodName, isNotNull);
7642 expect(invocation.typeArguments, isNotNull);
7643 expect(invocation.argumentList, isNotNull);
7644 }
7645
7389 void test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() { 7646 void test_parseExpressionWithoutCascade_superMethodInvocation_typeArguments() {
7390 enableGenericMethods = true; 7647 enableGenericMethods = true;
7391 MethodInvocation invocation = 7648 MethodInvocation invocation =
7392 parse4("parseExpressionWithoutCascade", "super.m<E>()"); 7649 parse4("parseExpressionWithoutCascade", "super.m<E>()");
7393 expect(invocation.target, isNotNull); 7650 expect(invocation.target, isNotNull);
7394 expect(invocation.methodName, isNotNull); 7651 expect(invocation.methodName, isNotNull);
7395 expect(invocation.typeArguments, isNotNull); 7652 expect(invocation.typeArguments, isNotNull);
7396 expect(invocation.argumentList, isNotNull); 7653 expect(invocation.argumentList, isNotNull);
7397 } 7654 }
7398 7655
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
8141 expect(declaration.returnType, returnType); 8398 expect(declaration.returnType, returnType);
8142 expect(declaration.name, isNotNull); 8399 expect(declaration.name, isNotNull);
8143 FunctionExpression expression = declaration.functionExpression; 8400 FunctionExpression expression = declaration.functionExpression;
8144 expect(expression, isNotNull); 8401 expect(expression, isNotNull);
8145 expect(expression.body, isNotNull); 8402 expect(expression.body, isNotNull);
8146 expect(expression.typeParameters, isNotNull); 8403 expect(expression.typeParameters, isNotNull);
8147 expect(expression.parameters, isNotNull); 8404 expect(expression.parameters, isNotNull);
8148 expect(declaration.propertyKeyword, isNull); 8405 expect(declaration.propertyKeyword, isNull);
8149 } 8406 }
8150 8407
8408 void test_parseFunctionDeclaration_functionWithTypeParameters_comment() {
8409 enableGenericMethodComments = true;
8410 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8411 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8412 FunctionDeclaration declaration = parse(
8413 "parseFunctionDeclaration",
8414 <Object>[commentAndMetadata(comment), null, returnType],
8415 "f/*<E>*/() {}");
8416 expect(declaration.documentationComment, comment);
8417 expect(declaration.returnType, returnType);
8418 expect(declaration.name, isNotNull);
8419 FunctionExpression expression = declaration.functionExpression;
8420 expect(expression, isNotNull);
8421 expect(expression.body, isNotNull);
8422 expect(expression.typeParameters, isNotNull);
8423 expect(expression.parameters, isNotNull);
8424 expect(declaration.propertyKeyword, isNull);
8425 }
8426
8151 void test_parseFunctionDeclaration_getter() { 8427 void test_parseFunctionDeclaration_getter() {
8152 Comment comment = Comment.createDocumentationComment(new List<Token>(0)); 8428 Comment comment = Comment.createDocumentationComment(new List<Token>(0));
8153 TypeName returnType = new TypeName(new SimpleIdentifier(null), null); 8429 TypeName returnType = new TypeName(new SimpleIdentifier(null), null);
8154 FunctionDeclaration declaration = parse("parseFunctionDeclaration", 8430 FunctionDeclaration declaration = parse("parseFunctionDeclaration",
8155 <Object>[commentAndMetadata(comment), null, returnType], "get p => 0;"); 8431 <Object>[commentAndMetadata(comment), null, returnType], "get p => 0;");
8156 expect(declaration.documentationComment, comment); 8432 expect(declaration.documentationComment, comment);
8157 expect(declaration.returnType, returnType); 8433 expect(declaration.returnType, returnType);
8158 expect(declaration.name, isNotNull); 8434 expect(declaration.name, isNotNull);
8159 FunctionExpression expression = declaration.functionExpression; 8435 FunctionExpression expression = declaration.functionExpression;
8160 expect(expression, isNotNull); 8436 expect(expression, isNotNull);
(...skipping 18 matching lines...) Expand all
8179 expect(expression.parameters, isNotNull); 8455 expect(expression.parameters, isNotNull);
8180 expect(declaration.propertyKeyword, isNotNull); 8456 expect(declaration.propertyKeyword, isNotNull);
8181 } 8457 }
8182 8458
8183 void test_parseFunctionDeclarationStatement() { 8459 void test_parseFunctionDeclarationStatement() {
8184 FunctionDeclarationStatement statement = 8460 FunctionDeclarationStatement statement =
8185 parse4("parseFunctionDeclarationStatement", "void f(int p) => p * 2;"); 8461 parse4("parseFunctionDeclarationStatement", "void f(int p) => p * 2;");
8186 expect(statement.functionDeclaration, isNotNull); 8462 expect(statement.functionDeclaration, isNotNull);
8187 } 8463 }
8188 8464
8465 void test_parseFunctionDeclarationStatement_typeParameterComments() {
8466 enableGenericMethodComments = true;
8467 FunctionDeclarationStatement statement = parse4(
8468 "parseFunctionDeclarationStatement",
8469 "/*=E*/ f/*<E>*/(/*=E*/ p) => p * 2;");
8470 FunctionDeclaration f = statement.functionDeclaration;
8471 expect(f, isNotNull);
8472 expect(f.functionExpression.typeParameters, isNotNull);
8473 expect(f.returnType, isNotNull);
8474 SimpleFormalParameter p = f.functionExpression.parameters.parameters[0];
8475 expect(p.type, isNotNull);
8476 }
8477
8189 void test_parseFunctionDeclarationStatement_typeParameters() { 8478 void test_parseFunctionDeclarationStatement_typeParameters() {
8190 enableGenericMethods = true; 8479 enableGenericMethods = true;
8191 FunctionDeclarationStatement statement = 8480 FunctionDeclarationStatement statement =
8192 parse4("parseFunctionDeclarationStatement", "E f<E>(E p) => p * 2;"); 8481 parse4("parseFunctionDeclarationStatement", "E f<E>(E p) => p * 2;");
8193 expect(statement.functionDeclaration, isNotNull); 8482 expect(statement.functionDeclaration, isNotNull);
8483 expect(statement.functionDeclaration.functionExpression.typeParameters,
8484 isNotNull);
8194 } 8485 }
8195 8486
8196 void test_parseFunctionExpression_body_inExpression() { 8487 void test_parseFunctionExpression_body_inExpression() {
8197 FunctionExpression expression = 8488 FunctionExpression expression =
8198 parse4("parseFunctionExpression", "(int i) => i++"); 8489 parse4("parseFunctionExpression", "(int i) => i++");
8199 expect(expression.body, isNotNull); 8490 expect(expression.body, isNotNull);
8200 expect(expression.typeParameters, isNull); 8491 expect(expression.typeParameters, isNull);
8201 expect(expression.parameters, isNotNull); 8492 expect(expression.parameters, isNotNull);
8202 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); 8493 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
8203 } 8494 }
8204 8495
8496 void test_parseFunctionExpression_typeParameterComments() {
8497 enableGenericMethodComments = true;
8498 FunctionExpression expression =
8499 parse4("parseFunctionExpression", "/*<E>*/(/*=E*/ i) => i++");
8500 expect(expression.body, isNotNull);
8501 expect(expression.typeParameters, isNotNull);
8502 expect(expression.parameters, isNotNull);
8503 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
8504 SimpleFormalParameter p = expression.parameters.parameters[0];
8505 expect(p.type, isNotNull);
8506 }
8507
8205 void test_parseFunctionExpression_typeParameters() { 8508 void test_parseFunctionExpression_typeParameters() {
8206 enableGenericMethods = true; 8509 enableGenericMethods = true;
8207 FunctionExpression expression = 8510 FunctionExpression expression =
8208 parse4("parseFunctionExpression", "<E>(E i) => i++"); 8511 parse4("parseFunctionExpression", "<E>(E i) => i++");
8209 expect(expression.body, isNotNull); 8512 expect(expression.body, isNotNull);
8210 expect(expression.typeParameters, isNotNull); 8513 expect(expression.typeParameters, isNotNull);
8211 expect(expression.parameters, isNotNull); 8514 expect(expression.parameters, isNotNull);
8212 expect((expression.body as ExpressionFunctionBody).semicolon, isNull); 8515 expect((expression.body as ExpressionFunctionBody).semicolon, isNull);
8213 } 8516 }
8214 8517
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
8944 9247
8945 void test_parseNormalFormalParameter_function_noType() { 9248 void test_parseNormalFormalParameter_function_noType() {
8946 FunctionTypedFormalParameter parameter = 9249 FunctionTypedFormalParameter parameter =
8947 parse4("parseNormalFormalParameter", "a())"); 9250 parse4("parseNormalFormalParameter", "a())");
8948 expect(parameter.returnType, isNull); 9251 expect(parameter.returnType, isNull);
8949 expect(parameter.identifier, isNotNull); 9252 expect(parameter.identifier, isNotNull);
8950 expect(parameter.typeParameters, isNull); 9253 expect(parameter.typeParameters, isNull);
8951 expect(parameter.parameters, isNotNull); 9254 expect(parameter.parameters, isNotNull);
8952 } 9255 }
8953 9256
9257 void test_parseNormalFormalParameter_function_noType_typeParameterComments() {
9258 enableGenericMethodComments = true;
9259 FunctionTypedFormalParameter parameter =
9260 parse4("parseNormalFormalParameter", "a/*<E>*/())");
9261 expect(parameter.returnType, isNull);
9262 expect(parameter.identifier, isNotNull);
9263 expect(parameter.typeParameters, isNotNull);
9264 expect(parameter.parameters, isNotNull);
9265 }
9266
8954 void test_parseNormalFormalParameter_function_noType_typeParameters() { 9267 void test_parseNormalFormalParameter_function_noType_typeParameters() {
8955 enableGenericMethods = true; 9268 enableGenericMethods = true;
8956 FunctionTypedFormalParameter parameter = 9269 FunctionTypedFormalParameter parameter =
8957 parse4("parseNormalFormalParameter", "a<E>())"); 9270 parse4("parseNormalFormalParameter", "a<E>())");
8958 expect(parameter.returnType, isNull); 9271 expect(parameter.returnType, isNull);
8959 expect(parameter.identifier, isNotNull); 9272 expect(parameter.identifier, isNotNull);
8960 expect(parameter.typeParameters, isNotNull); 9273 expect(parameter.typeParameters, isNotNull);
8961 expect(parameter.parameters, isNotNull); 9274 expect(parameter.parameters, isNotNull);
8962 } 9275 }
8963 9276
8964 void test_parseNormalFormalParameter_function_type() { 9277 void test_parseNormalFormalParameter_function_type() {
8965 FunctionTypedFormalParameter parameter = 9278 FunctionTypedFormalParameter parameter =
8966 parse4("parseNormalFormalParameter", "A a())"); 9279 parse4("parseNormalFormalParameter", "A a())");
8967 expect(parameter.returnType, isNotNull); 9280 expect(parameter.returnType, isNotNull);
8968 expect(parameter.identifier, isNotNull); 9281 expect(parameter.identifier, isNotNull);
8969 expect(parameter.typeParameters, isNull); 9282 expect(parameter.typeParameters, isNull);
8970 expect(parameter.parameters, isNotNull); 9283 expect(parameter.parameters, isNotNull);
8971 } 9284 }
8972 9285
9286 void test_parseNormalFormalParameter_function_type_typeParameterComments() {
9287 enableGenericMethodComments = true;
9288 FunctionTypedFormalParameter parameter =
9289 parse4("parseNormalFormalParameter", "A a/*<E>*/())");
9290 expect(parameter.returnType, isNotNull);
9291 expect(parameter.identifier, isNotNull);
9292 expect(parameter.typeParameters, isNotNull);
9293 expect(parameter.parameters, isNotNull);
9294 }
9295
8973 void test_parseNormalFormalParameter_function_type_typeParameters() { 9296 void test_parseNormalFormalParameter_function_type_typeParameters() {
8974 enableGenericMethods = true; 9297 enableGenericMethods = true;
8975 FunctionTypedFormalParameter parameter = 9298 FunctionTypedFormalParameter parameter =
8976 parse4("parseNormalFormalParameter", "A a<E>())"); 9299 parse4("parseNormalFormalParameter", "A a<E>())");
8977 expect(parameter.returnType, isNotNull); 9300 expect(parameter.returnType, isNotNull);
8978 expect(parameter.identifier, isNotNull); 9301 expect(parameter.identifier, isNotNull);
8979 expect(parameter.typeParameters, isNotNull); 9302 expect(parameter.typeParameters, isNotNull);
8980 expect(parameter.parameters, isNotNull); 9303 expect(parameter.parameters, isNotNull);
8981 } 9304 }
8982 9305
8983 void test_parseNormalFormalParameter_function_void() { 9306 void test_parseNormalFormalParameter_function_void() {
8984 FunctionTypedFormalParameter parameter = 9307 FunctionTypedFormalParameter parameter =
8985 parse4("parseNormalFormalParameter", "void a())"); 9308 parse4("parseNormalFormalParameter", "void a())");
8986 expect(parameter.returnType, isNotNull); 9309 expect(parameter.returnType, isNotNull);
8987 expect(parameter.identifier, isNotNull); 9310 expect(parameter.identifier, isNotNull);
8988 expect(parameter.typeParameters, isNull); 9311 expect(parameter.typeParameters, isNull);
8989 expect(parameter.parameters, isNotNull); 9312 expect(parameter.parameters, isNotNull);
8990 } 9313 }
8991 9314
9315 void test_parseNormalFormalParameter_function_void_typeParameterComments() {
9316 enableGenericMethodComments = true;
9317 FunctionTypedFormalParameter parameter =
9318 parse4("parseNormalFormalParameter", "void a/*<E>*/())");
9319 expect(parameter.returnType, isNotNull);
9320 expect(parameter.identifier, isNotNull);
9321 expect(parameter.typeParameters, isNotNull);
9322 expect(parameter.parameters, isNotNull);
9323 }
9324
8992 void test_parseNormalFormalParameter_function_void_typeParameters() { 9325 void test_parseNormalFormalParameter_function_void_typeParameters() {
8993 enableGenericMethods = true; 9326 enableGenericMethods = true;
8994 FunctionTypedFormalParameter parameter = 9327 FunctionTypedFormalParameter parameter =
8995 parse4("parseNormalFormalParameter", "void a<E>())"); 9328 parse4("parseNormalFormalParameter", "void a<E>())");
8996 expect(parameter.returnType, isNotNull); 9329 expect(parameter.returnType, isNotNull);
8997 expect(parameter.identifier, isNotNull); 9330 expect(parameter.identifier, isNotNull);
8998 expect(parameter.typeParameters, isNotNull); 9331 expect(parameter.typeParameters, isNotNull);
8999 expect(parameter.parameters, isNotNull); 9332 expect(parameter.parameters, isNotNull);
9000 } 9333 }
9001 9334
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
9118 9451
9119 void test_parsePostfixExpression_none_methodInvocation_question_dot() { 9452 void test_parsePostfixExpression_none_methodInvocation_question_dot() {
9120 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m()'); 9453 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m()');
9121 expect(expression.target, isNotNull); 9454 expect(expression.target, isNotNull);
9122 expect(expression.operator.type, TokenType.QUESTION_PERIOD); 9455 expect(expression.operator.type, TokenType.QUESTION_PERIOD);
9123 expect(expression.methodName, isNotNull); 9456 expect(expression.methodName, isNotNull);
9124 expect(expression.typeArguments, isNull); 9457 expect(expression.typeArguments, isNull);
9125 expect(expression.argumentList, isNotNull); 9458 expect(expression.argumentList, isNotNull);
9126 } 9459 }
9127 9460
9461 void test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgume ntComments() {
9462 enableGenericMethodComments = true;
9463 MethodInvocation expression =
9464 parse4('parsePostfixExpression', 'a?.m/*<E>*/()');
9465 expect(expression.target, isNotNull);
9466 expect(expression.operator.type, TokenType.QUESTION_PERIOD);
9467 expect(expression.methodName, isNotNull);
9468 expect(expression.typeArguments, isNotNull);
9469 expect(expression.argumentList, isNotNull);
9470 }
9471
9128 void test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgume nts() { 9472 void test_parsePostfixExpression_none_methodInvocation_question_dot_typeArgume nts() {
9129 enableGenericMethods = true; 9473 enableGenericMethods = true;
9130 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m<E>()'); 9474 MethodInvocation expression = parse4('parsePostfixExpression', 'a?.m<E>()');
9131 expect(expression.target, isNotNull); 9475 expect(expression.target, isNotNull);
9132 expect(expression.operator.type, TokenType.QUESTION_PERIOD); 9476 expect(expression.operator.type, TokenType.QUESTION_PERIOD);
9133 expect(expression.methodName, isNotNull); 9477 expect(expression.methodName, isNotNull);
9134 expect(expression.typeArguments, isNotNull); 9478 expect(expression.typeArguments, isNotNull);
9135 expect(expression.argumentList, isNotNull); 9479 expect(expression.argumentList, isNotNull);
9136 } 9480 }
9137 9481
9482 void test_parsePostfixExpression_none_methodInvocation_typeArgumentComments() {
9483 enableGenericMethodComments = true;
9484 MethodInvocation expression =
9485 parse4("parsePostfixExpression", "a.m/*<E>*/()");
9486 expect(expression.target, isNotNull);
9487 expect(expression.operator.type, TokenType.PERIOD);
9488 expect(expression.methodName, isNotNull);
9489 expect(expression.typeArguments, isNotNull);
9490 expect(expression.argumentList, isNotNull);
9491 }
9492
9138 void test_parsePostfixExpression_none_methodInvocation_typeArguments() { 9493 void test_parsePostfixExpression_none_methodInvocation_typeArguments() {
9139 enableGenericMethods = true; 9494 enableGenericMethods = true;
9140 MethodInvocation expression = parse4("parsePostfixExpression", "a.m<E>()"); 9495 MethodInvocation expression = parse4("parsePostfixExpression", "a.m<E>()");
9141 expect(expression.target, isNotNull); 9496 expect(expression.target, isNotNull);
9142 expect(expression.operator.type, TokenType.PERIOD); 9497 expect(expression.operator.type, TokenType.PERIOD);
9143 expect(expression.methodName, isNotNull); 9498 expect(expression.methodName, isNotNull);
9144 expect(expression.typeArguments, isNotNull); 9499 expect(expression.typeArguments, isNotNull);
9145 expect(expression.argumentList, isNotNull); 9500 expect(expression.argumentList, isNotNull);
9146 } 9501 }
9147 9502
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
9481 expect(argumentList.arguments[0].isSynthetic, isTrue); 9836 expect(argumentList.arguments[0].isSynthetic, isTrue);
9482 expect(argumentList.rightBracket, isNotNull); 9837 expect(argumentList.rightBracket, isNotNull);
9483 } 9838 }
9484 9839
9485 void test_parseStatement_functionDeclaration_noReturnType() { 9840 void test_parseStatement_functionDeclaration_noReturnType() {
9486 FunctionDeclarationStatement statement = 9841 FunctionDeclarationStatement statement =
9487 parse4("parseStatement", "f(a, b) {};"); 9842 parse4("parseStatement", "f(a, b) {};");
9488 expect(statement.functionDeclaration, isNotNull); 9843 expect(statement.functionDeclaration, isNotNull);
9489 } 9844 }
9490 9845
9491 void test_parseStatement_functionDeclaration_noReturnType_typeParameters() { 9846 void test_parseStatement_functionDeclaration_noReturnType_typeParameterComment s() {
9492 enableGenericMethods = true; 9847 enableGenericMethodComments = true;
9493 FunctionDeclarationStatement statement = 9848 FunctionDeclarationStatement statement =
9494 parse4("parseStatement", "f(a, b) {};"); 9849 parse4("parseStatement", "f/*<E>*/(a, b) {};");
9495 expect(statement.functionDeclaration, isNotNull); 9850 expect(statement.functionDeclaration, isNotNull);
9851 expect(statement.functionDeclaration.functionExpression.typeParameters,
9852 isNotNull);
9496 } 9853 }
9497 9854
9498 void test_parseStatement_functionDeclaration_returnType() { 9855 void test_parseStatement_functionDeclaration_returnType() {
9499 // TODO(brianwilkerson) Implement more tests for this method. 9856 // TODO(brianwilkerson) Implement more tests for this method.
9500 FunctionDeclarationStatement statement = 9857 FunctionDeclarationStatement statement =
9501 parse4("parseStatement", "int f(a, b) {};"); 9858 parse4("parseStatement", "int f(a, b) {};", []);
9502 expect(statement.functionDeclaration, isNotNull); 9859 expect(statement.functionDeclaration, isNotNull);
9503 } 9860 }
9504 9861
9505 void test_parseStatement_functionDeclaration_returnType_typeParameters() { 9862 void test_parseStatement_functionDeclaration_returnType_typeParameters() {
9506 enableGenericMethods = true; 9863 enableGenericMethods = true;
9507 FunctionDeclarationStatement statement = 9864 FunctionDeclarationStatement statement =
9508 parse4("parseStatement", "int f<E>(a, b) {};"); 9865 parse4("parseStatement", "int f<E>(a, b) {};");
9509 expect(statement.functionDeclaration, isNotNull); 9866 expect(statement.functionDeclaration, isNotNull);
9510 } 9867 }
9511 9868
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
10343 void test_parseVariableDeclarationListAfterMetadata_final_type() { 10700 void test_parseVariableDeclarationListAfterMetadata_final_type() {
10344 VariableDeclarationList declarationList = parse( 10701 VariableDeclarationList declarationList = parse(
10345 "parseVariableDeclarationListAfterMetadata", 10702 "parseVariableDeclarationListAfterMetadata",
10346 <Object>[emptyCommentAndMetadata()], 10703 <Object>[emptyCommentAndMetadata()],
10347 "final A a"); 10704 "final A a");
10348 expect(declarationList.keyword, isNotNull); 10705 expect(declarationList.keyword, isNotNull);
10349 expect(declarationList.type, isNotNull); 10706 expect(declarationList.type, isNotNull);
10350 expect(declarationList.variables, hasLength(1)); 10707 expect(declarationList.variables, hasLength(1));
10351 } 10708 }
10352 10709
10710 void test_parseVariableDeclarationListAfterMetadata_final_typeComment() {
10711 enableGenericMethodComments = true;
10712 VariableDeclarationList decl = parse(
10713 "parseVariableDeclarationListAfterMetadata",
10714 <Object>[emptyCommentAndMetadata()],
10715 "final/*=T*/ x");
10716 expect(decl.type.name.name, 'T');
10717 expect(decl.isFinal, true);
10718 }
10719
10353 void test_parseVariableDeclarationListAfterMetadata_type_multiple() { 10720 void test_parseVariableDeclarationListAfterMetadata_type_multiple() {
10354 VariableDeclarationList declarationList = parse( 10721 VariableDeclarationList declarationList = parse(
10355 "parseVariableDeclarationListAfterMetadata", 10722 "parseVariableDeclarationListAfterMetadata",
10356 <Object>[emptyCommentAndMetadata()], 10723 <Object>[emptyCommentAndMetadata()],
10357 "A a, b, c"); 10724 "A a, b, c");
10358 expect(declarationList.keyword, isNull); 10725 expect(declarationList.keyword, isNull);
10359 expect(declarationList.type, isNotNull); 10726 expect(declarationList.type, isNotNull);
10360 expect(declarationList.variables, hasLength(3)); 10727 expect(declarationList.variables, hasLength(3));
10361 } 10728 }
10362 10729
(...skipping 20 matching lines...) Expand all
10383 void test_parseVariableDeclarationListAfterMetadata_var_single() { 10750 void test_parseVariableDeclarationListAfterMetadata_var_single() {
10384 VariableDeclarationList declarationList = parse( 10751 VariableDeclarationList declarationList = parse(
10385 "parseVariableDeclarationListAfterMetadata", 10752 "parseVariableDeclarationListAfterMetadata",
10386 <Object>[emptyCommentAndMetadata()], 10753 <Object>[emptyCommentAndMetadata()],
10387 "var a"); 10754 "var a");
10388 expect(declarationList.keyword, isNotNull); 10755 expect(declarationList.keyword, isNotNull);
10389 expect(declarationList.type, isNull); 10756 expect(declarationList.type, isNull);
10390 expect(declarationList.variables, hasLength(1)); 10757 expect(declarationList.variables, hasLength(1));
10391 } 10758 }
10392 10759
10760 void test_parseVariableDeclarationListAfterMetadata_var_typeComment() {
10761 enableGenericMethodComments = true;
10762 VariableDeclarationList decl = parse(
10763 "parseVariableDeclarationListAfterMetadata",
10764 <Object>[emptyCommentAndMetadata()],
10765 "var/*=T*/ x");
10766 expect(decl.type.name.name, 'T');
10767 expect(decl.keyword, isNull);
10768 }
10769
10393 void test_parseVariableDeclarationListAfterType_type() { 10770 void test_parseVariableDeclarationListAfterType_type() {
10394 TypeName type = new TypeName(new SimpleIdentifier(null), null); 10771 TypeName type = new TypeName(new SimpleIdentifier(null), null);
10395 VariableDeclarationList declarationList = parse( 10772 VariableDeclarationList declarationList = parse(
10396 "parseVariableDeclarationListAfterType", 10773 "parseVariableDeclarationListAfterType",
10397 <Object>[emptyCommentAndMetadata(), null, type], 10774 <Object>[emptyCommentAndMetadata(), null, type],
10398 "a"); 10775 "a");
10399 expect(declarationList.keyword, isNull); 10776 expect(declarationList.keyword, isNull);
10400 expect(declarationList.type, type); 10777 expect(declarationList.type, type);
10401 expect(declarationList.variables, hasLength(1)); 10778 expect(declarationList.variables, hasLength(1));
10402 } 10779 }
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
10732 new Scanner(null, new CharSequenceReader(source), listener); 11109 new Scanner(null, new CharSequenceReader(source), listener);
10733 Token tokenStream = scanner.tokenize(); 11110 Token tokenStream = scanner.tokenize();
10734 // 11111 //
10735 // Parse the source. 11112 // Parse the source.
10736 // 11113 //
10737 Parser parser = new Parser(null, listener); 11114 Parser parser = new Parser(null, listener);
10738 return invokeParserMethodImpl( 11115 return invokeParserMethodImpl(
10739 parser, methodName, <Object>[tokenStream], tokenStream) as Token; 11116 parser, methodName, <Object>[tokenStream], tokenStream) as Token;
10740 } 11117 }
10741 } 11118 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/scanner.dart ('k') | pkg/analyzer/test/generated/scanner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698