| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:analyzer/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
| 6 import 'package:analyzer/dart/ast/token.dart' as analyzer; | 6 import 'package:analyzer/dart/ast/token.dart' as analyzer; |
| 7 import 'package:analyzer/error/error.dart'; | 7 import 'package:analyzer/error/error.dart'; |
| 8 import 'package:analyzer/error/listener.dart' show ErrorReporter; | 8 import 'package:analyzer/error/listener.dart' show ErrorReporter; |
| 9 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 9 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| 10 import 'package:analyzer/src/fasta/ast_builder.dart'; | 10 import 'package:analyzer/src/fasta/ast_builder.dart'; |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 } | 627 } |
| 628 | 628 |
| 629 @override | 629 @override |
| 630 @failingTest | 630 @failingTest |
| 631 void test_expectedToken_parseStatement_afterVoid() { | 631 void test_expectedToken_parseStatement_afterVoid() { |
| 632 super.test_expectedToken_parseStatement_afterVoid(); | 632 super.test_expectedToken_parseStatement_afterVoid(); |
| 633 } | 633 } |
| 634 | 634 |
| 635 @override | 635 @override |
| 636 @failingTest | 636 @failingTest |
| 637 void test_expectedToken_semicolonMissingAfterExport() { | |
| 638 super.test_expectedToken_semicolonMissingAfterExport(); | |
| 639 } | |
| 640 | |
| 641 @override | |
| 642 @failingTest | |
| 643 void test_expectedToken_semicolonMissingAfterExpression() { | 637 void test_expectedToken_semicolonMissingAfterExpression() { |
| 644 super.test_expectedToken_semicolonMissingAfterExpression(); | 638 super.test_expectedToken_semicolonMissingAfterExpression(); |
| 645 } | 639 } |
| 646 | 640 |
| 647 @override | 641 @override |
| 648 @failingTest | 642 @failingTest |
| 649 void test_expectedToken_semicolonMissingAfterImport() { | 643 void test_expectedToken_semicolonMissingAfterImport() { |
| 650 super.test_expectedToken_semicolonMissingAfterImport(); | 644 super.test_expectedToken_semicolonMissingAfterImport(); |
| 651 } | 645 } |
| 652 | 646 |
| (...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2363 } | 2357 } |
| 2364 | 2358 |
| 2365 @override | 2359 @override |
| 2366 Expression parseConstExpression(String code) { | 2360 Expression parseConstExpression(String code) { |
| 2367 return _parseExpression(code); | 2361 return _parseExpression(code); |
| 2368 } | 2362 } |
| 2369 | 2363 |
| 2370 @override | 2364 @override |
| 2371 ConstructorInitializer parseConstructorInitializer(String code) { | 2365 ConstructorInitializer parseConstructorInitializer(String code) { |
| 2372 String source = 'class __Test { __Test() : $code; }'; | 2366 String source = 'class __Test { __Test() : $code; }'; |
| 2373 var unit = | 2367 var unit = _runParser(source, null) as CompilationUnit; |
| 2374 _runParser(source, (parser) => parser.parseUnit) as CompilationUnit; | |
| 2375 var clazz = unit.declarations[0] as ClassDeclaration; | 2368 var clazz = unit.declarations[0] as ClassDeclaration; |
| 2376 var constructor = clazz.members[0] as ConstructorDeclaration; | 2369 var constructor = clazz.members[0] as ConstructorDeclaration; |
| 2377 return constructor.initializers.single; | 2370 return constructor.initializers.single; |
| 2378 } | 2371 } |
| 2379 | 2372 |
| 2380 @override | 2373 @override |
| 2381 CompilationUnit parseDirectives(String source, | 2374 CompilationUnit parseDirectives(String source, |
| 2382 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 2375 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 2383 return _runParser(source, (parser) => parser.parseUnit, errorCodes); | 2376 return _runParser(source, null, errorCodes); |
| 2384 } | 2377 } |
| 2385 | 2378 |
| 2386 @override | 2379 @override |
| 2387 BinaryExpression parseEqualityExpression(String code) { | 2380 BinaryExpression parseEqualityExpression(String code) { |
| 2388 return _parseExpression(code); | 2381 return _parseExpression(code); |
| 2389 } | 2382 } |
| 2390 | 2383 |
| 2391 @override | 2384 @override |
| 2392 Expression parseExpression(String source, | 2385 Expression parseExpression(String source, |
| 2393 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 2386 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2800 _astBuilder.className = className; | 2793 _astBuilder.className = className; |
| 2801 _eventListener.begin('CompilationUnit'); | 2794 _eventListener.begin('CompilationUnit'); |
| 2802 var result = _run((parser) => parser.parseMember) as ClassMember; | 2795 var result = _run((parser) => parser.parseMember) as ClassMember; |
| 2803 _eventListener.end('CompilationUnit'); | 2796 _eventListener.end('CompilationUnit'); |
| 2804 _astBuilder.className = null; | 2797 _astBuilder.className = null; |
| 2805 return result; | 2798 return result; |
| 2806 } | 2799 } |
| 2807 | 2800 |
| 2808 @override | 2801 @override |
| 2809 CompilationUnit parseCompilationUnit2() { | 2802 CompilationUnit parseCompilationUnit2() { |
| 2810 var result = _run((parser) => parser.parseUnit) as CompilationUnit; | 2803 var result = _run(null) as CompilationUnit; |
| 2811 _eventListener.expectEmpty(); | 2804 _eventListener.expectEmpty(); |
| 2812 return result; | 2805 return result; |
| 2813 } | 2806 } |
| 2814 | 2807 |
| 2815 AnnotatedNode parseTopLevelDeclaration(bool isDirective) { | 2808 AnnotatedNode parseTopLevelDeclaration(bool isDirective) { |
| 2816 _eventListener.begin('CompilationUnit'); | 2809 _eventListener.begin('CompilationUnit'); |
| 2817 _currentFastaToken = | 2810 _currentFastaToken = |
| 2818 _fastaParser.parseTopLevelDeclaration(_currentFastaToken); | 2811 _fastaParser.parseTopLevelDeclaration(_currentFastaToken); |
| 2819 expect(_currentFastaToken.isEof, isTrue); | 2812 expect(_currentFastaToken.isEof, isTrue); |
| 2820 expect(_astBuilder.stack, hasLength(0)); | 2813 expect(_astBuilder.stack, hasLength(0)); |
| 2821 expect(_astBuilder.scriptTag, isNull); | 2814 expect(_astBuilder.scriptTag, isNull); |
| 2822 expect(_astBuilder.directives, hasLength(isDirective ? 1 : 0)); | 2815 expect(_astBuilder.directives, hasLength(isDirective ? 1 : 0)); |
| 2823 expect(_astBuilder.declarations, hasLength(isDirective ? 0 : 1)); | 2816 expect(_astBuilder.declarations, hasLength(isDirective ? 0 : 1)); |
| 2824 _eventListener.end('CompilationUnit'); | 2817 _eventListener.end('CompilationUnit'); |
| 2825 return (isDirective ? _astBuilder.directives : _astBuilder.declarations) | 2818 return (isDirective ? _astBuilder.directives : _astBuilder.declarations) |
| 2826 .first; | 2819 .first; |
| 2827 } | 2820 } |
| 2828 | 2821 |
| 2829 /** | 2822 /** |
| 2830 * Runs a single parser function, and returns the result as an analyzer AST. | 2823 * Runs a single parser function, and returns the result as an analyzer AST. |
| 2831 */ | 2824 */ |
| 2832 Object _run(ParseFunction getParseFunction(fasta.Parser parser)) { | 2825 Object _run(ParseFunction getParseFunction(fasta.Parser parser)) { |
| 2833 var parseFunction = getParseFunction(_fastaParser); | 2826 ParseFunction parseFunction; |
| 2827 if (getParseFunction != null) { |
| 2828 parseFunction = getParseFunction(_fastaParser); |
| 2829 _fastaParser.listener.firstToken = _currentFastaToken; |
| 2830 } else { |
| 2831 parseFunction = _fastaParser.parseUnit; |
| 2832 // firstToken should be set by beginCompilationUnit event. |
| 2833 } |
| 2834 _currentFastaToken = parseFunction(_currentFastaToken); | 2834 _currentFastaToken = parseFunction(_currentFastaToken); |
| 2835 expect(_currentFastaToken.isEof, isTrue); | 2835 expect(_currentFastaToken.isEof, isTrue); |
| 2836 expect(_astBuilder.stack, hasLength(1)); | 2836 expect(_astBuilder.stack, hasLength(1)); |
| 2837 return _astBuilder.pop(); | 2837 return _astBuilder.pop(); |
| 2838 } | 2838 } |
| 2839 } | 2839 } |
| 2840 | 2840 |
| 2841 /** | 2841 /** |
| 2842 * Proxy implementation of [Scope] used by Fasta parser tests. | 2842 * Proxy implementation of [Scope] used by Fasta parser tests. |
| 2843 * | 2843 * |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2987 assertNoErrors(); | 2987 assertNoErrors(); |
| 2988 } | 2988 } |
| 2989 | 2989 |
| 2990 @failingTest | 2990 @failingTest |
| 2991 void test_parseCompilationUnitMember_abstractAsPrefix2() { | 2991 void test_parseCompilationUnitMember_abstractAsPrefix2() { |
| 2992 // TODO(danrubel): should not be generating an error | 2992 // TODO(danrubel): should not be generating an error |
| 2993 super.test_parseCompilationUnitMember_abstractAsPrefix(); | 2993 super.test_parseCompilationUnitMember_abstractAsPrefix(); |
| 2994 assertNoErrors(); | 2994 assertNoErrors(); |
| 2995 } | 2995 } |
| 2996 } | 2996 } |
| OLD | NEW |