| 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/visitor.dart'; | 8 import 'package:analyzer/dart/ast/visitor.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 498 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 499 BinaryExpression, expression.rightOperand); | 499 BinaryExpression, expression.rightOperand); |
| 500 } | 500 } |
| 501 | 501 |
| 502 void test_shiftExpression_super() { | 502 void test_shiftExpression_super() { |
| 503 BinaryExpression expression = parseExpression("super >> 4 << 3"); | 503 BinaryExpression expression = parseExpression("super >> 4 << 3"); |
| 504 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, | 504 EngineTestCase.assertInstanceOf((obj) => obj is BinaryExpression, |
| 505 BinaryExpression, expression.leftOperand); | 505 BinaryExpression, expression.leftOperand); |
| 506 } | 506 } |
| 507 | 507 |
| 508 void test_topLevelFunction_nestedGenericFunction() { |
| 509 enableGenericMethods = true; |
| 510 parseCompilationUnitWithOptions(''' |
| 511 void f() { |
| 512 void g<T>() { |
| 513 } |
| 514 } |
| 515 '''); |
| 516 } |
| 517 |
| 508 void _validate_assignableExpression_arguments_normal_chain_typeArguments( | 518 void _validate_assignableExpression_arguments_normal_chain_typeArguments( |
| 509 String code) { | 519 String code) { |
| 510 PropertyAccess propertyAccess1 = parseExpression(code); | 520 PropertyAccess propertyAccess1 = parseExpression(code); |
| 511 expect(propertyAccess1.propertyName.name, "f"); | 521 expect(propertyAccess1.propertyName.name, "f"); |
| 512 // | 522 // |
| 513 // a<E>(b)<F>(c).d<G>(e) | 523 // a<E>(b)<F>(c).d<G>(e) |
| 514 // | 524 // |
| 515 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( | 525 MethodInvocation invocation2 = EngineTestCase.assertInstanceOf( |
| 516 (obj) => obj is MethodInvocation, | 526 (obj) => obj is MethodInvocation, |
| 517 MethodInvocation, | 527 MethodInvocation, |
| (...skipping 2346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2864 * @return the result of invoking the method | 2874 * @return the result of invoking the method |
| 2865 * @throws Exception if the method could not be invoked or throws an exception | 2875 * @throws Exception if the method could not be invoked or throws an exception |
| 2866 * @throws AssertionFailedError if the result is `null` or the errors produced
while | 2876 * @throws AssertionFailedError if the result is `null` or the errors produced
while |
| 2867 * scanning and parsing the source do not match the expected errors | 2877 * scanning and parsing the source do not match the expected errors |
| 2868 */ | 2878 */ |
| 2869 Object parse4(String methodName, String source, | 2879 Object parse4(String methodName, String source, |
| 2870 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) => | 2880 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) => |
| 2871 parse3(methodName, _EMPTY_ARGUMENTS, source, errorCodes); | 2881 parse3(methodName, _EMPTY_ARGUMENTS, source, errorCodes); |
| 2872 | 2882 |
| 2873 /** | 2883 /** |
| 2884 * Parse the given [source] as a compilation unit. Throw an exception if the |
| 2885 * source could not be parsed, if the compilation errors in the source do not |
| 2886 * match those that are expected, or if the result would have been `null`. |
| 2887 */ |
| 2888 CompilationUnit parseCompilationUnitWithOptions(String source, |
| 2889 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| 2890 GatheringErrorListener listener = new GatheringErrorListener(); |
| 2891 Scanner scanner = |
| 2892 new Scanner(null, new CharSequenceReader(source), listener); |
| 2893 listener.setLineInfo(new TestSource(), scanner.lineStarts); |
| 2894 Token token = scanner.tokenize(); |
| 2895 Parser parser = createParser(listener); |
| 2896 parser.parseAsync = parseAsync; |
| 2897 parser.parseFunctionBodies = parseFunctionBodies; |
| 2898 parser.parseConditionalDirectives = enableConditionalDirectives; |
| 2899 parser.parseGenericMethods = enableGenericMethods; |
| 2900 parser.parseGenericMethodComments = enableGenericMethodComments; |
| 2901 CompilationUnit unit = parser.parseCompilationUnit(token); |
| 2902 expect(unit, isNotNull); |
| 2903 listener.assertErrorsWithCodes(errorCodes); |
| 2904 return unit; |
| 2905 } |
| 2906 |
| 2907 /** |
| 2874 * Parse the given source as an expression. | 2908 * Parse the given source as an expression. |
| 2875 * | 2909 * |
| 2876 * @param source the source to be parsed | 2910 * @param source the source to be parsed |
| 2877 * @param errorCodes the error codes of the errors that are expected to be fou
nd | 2911 * @param errorCodes the error codes of the errors that are expected to be fou
nd |
| 2878 * @return the expression that was parsed | 2912 * @return the expression that was parsed |
| 2879 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do | 2913 * @throws Exception if the source could not be parsed, if the compilation err
ors in the source do |
| 2880 * not match those that are expected, or if the result would have be
en `null` | 2914 * not match those that are expected, or if the result would have be
en `null` |
| 2881 */ | 2915 */ |
| 2882 Expression parseExpression(String source, | 2916 Expression parseExpression(String source, |
| 2883 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { | 2917 [List<ErrorCode> errorCodes = ErrorCode.EMPTY_LIST]) { |
| (...skipping 8618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11502 new Scanner(null, new CharSequenceReader(source), listener); | 11536 new Scanner(null, new CharSequenceReader(source), listener); |
| 11503 Token tokenStream = scanner.tokenize(); | 11537 Token tokenStream = scanner.tokenize(); |
| 11504 // | 11538 // |
| 11505 // Parse the source. | 11539 // Parse the source. |
| 11506 // | 11540 // |
| 11507 Parser parser = new Parser(null, listener); | 11541 Parser parser = new Parser(null, listener); |
| 11508 return invokeParserMethodImpl( | 11542 return invokeParserMethodImpl( |
| 11509 parser, methodName, <Object>[tokenStream], tokenStream) as Token; | 11543 parser, methodName, <Object>[tokenStream], tokenStream) as Token; |
| 11510 } | 11544 } |
| 11511 } | 11545 } |
| OLD | NEW |