| 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/dart/ast/token.dart' show TokenType; | 7 import 'package:analyzer/dart/ast/token.dart' show TokenType; |
| 8 import 'package:analyzer/error/error.dart'; | 8 import 'package:analyzer/error/error.dart'; |
| 9 import 'package:analyzer/error/listener.dart' show ErrorReporter; | 9 import 'package:analyzer/error/listener.dart' show ErrorReporter; |
| 10 import 'package:analyzer/src/dart/scanner/scanner.dart'; | 10 import 'package:analyzer/src/dart/scanner/scanner.dart'; |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 628 } |
| 629 | 629 |
| 630 @override | 630 @override |
| 631 @failingTest | 631 @failingTest |
| 632 void test_expectedToken_parseStatement_afterVoid() { | 632 void test_expectedToken_parseStatement_afterVoid() { |
| 633 super.test_expectedToken_parseStatement_afterVoid(); | 633 super.test_expectedToken_parseStatement_afterVoid(); |
| 634 } | 634 } |
| 635 | 635 |
| 636 @override | 636 @override |
| 637 @failingTest | 637 @failingTest |
| 638 void test_expectedToken_semicolonMissingAfterExport() { | |
| 639 super.test_expectedToken_semicolonMissingAfterExport(); | |
| 640 } | |
| 641 | |
| 642 @override | |
| 643 @failingTest | |
| 644 void test_expectedToken_semicolonMissingAfterExpression() { | 638 void test_expectedToken_semicolonMissingAfterExpression() { |
| 645 super.test_expectedToken_semicolonMissingAfterExpression(); | 639 super.test_expectedToken_semicolonMissingAfterExpression(); |
| 646 } | 640 } |
| 647 | 641 |
| 648 @override | 642 @override |
| 649 @failingTest | 643 @failingTest |
| 650 void test_expectedToken_semicolonMissingAfterImport() { | 644 void test_expectedToken_semicolonMissingAfterImport() { |
| 651 super.test_expectedToken_semicolonMissingAfterImport(); | 645 super.test_expectedToken_semicolonMissingAfterImport(); |
| 652 } | 646 } |
| 653 | 647 |
| (...skipping 1714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2368 } | 2362 } |
| 2369 | 2363 |
| 2370 @override | 2364 @override |
| 2371 Expression parseConstExpression(String code) { | 2365 Expression parseConstExpression(String code) { |
| 2372 return _parseExpression(code); | 2366 return _parseExpression(code); |
| 2373 } | 2367 } |
| 2374 | 2368 |
| 2375 @override | 2369 @override |
| 2376 ConstructorInitializer parseConstructorInitializer(String code) { | 2370 ConstructorInitializer parseConstructorInitializer(String code) { |
| 2377 String source = 'class __Test { __Test() : $code; }'; | 2371 String source = 'class __Test { __Test() : $code; }'; |
| 2378 var unit = | 2372 var unit = _runParser(source, null) as CompilationUnit; |
| 2379 _runParser(source, (parser) => parser.parseUnit) as CompilationUnit; | |
| 2380 var clazz = unit.declarations[0] as ClassDeclaration; | 2373 var clazz = unit.declarations[0] as ClassDeclaration; |
| 2381 var constructor = clazz.members[0] as ConstructorDeclaration; | 2374 var constructor = clazz.members[0] as ConstructorDeclaration; |
| 2382 return constructor.initializers.single; | 2375 return constructor.initializers.single; |
| 2383 } | 2376 } |
| 2384 | 2377 |
| 2385 @override | 2378 @override |
| 2386 CompilationUnit parseDirectives(String source, | 2379 CompilationUnit parseDirectives(String source, |
| 2387 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 2380 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| 2388 return _runParser(source, (parser) => parser.parseUnit, errorCodes); | 2381 return _runParser(source, null, errorCodes); |
| 2389 } | 2382 } |
| 2390 | 2383 |
| 2391 @override | 2384 @override |
| 2392 BinaryExpression parseEqualityExpression(String code) { | 2385 BinaryExpression parseEqualityExpression(String code) { |
| 2393 return _parseExpression(code); | 2386 return _parseExpression(code); |
| 2394 } | 2387 } |
| 2395 | 2388 |
| 2396 @override | 2389 @override |
| 2397 Expression parseExpression(String source, | 2390 Expression parseExpression(String source, |
| 2398 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { | 2391 [List<ErrorCode> errorCodes = const <ErrorCode>[]]) { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2807 _astBuilder.className = className; | 2800 _astBuilder.className = className; |
| 2808 _eventListener.begin('CompilationUnit'); | 2801 _eventListener.begin('CompilationUnit'); |
| 2809 var result = _run((parser) => parser.parseMember) as ClassMember; | 2802 var result = _run((parser) => parser.parseMember) as ClassMember; |
| 2810 _eventListener.end('CompilationUnit'); | 2803 _eventListener.end('CompilationUnit'); |
| 2811 _astBuilder.className = null; | 2804 _astBuilder.className = null; |
| 2812 return result; | 2805 return result; |
| 2813 } | 2806 } |
| 2814 | 2807 |
| 2815 @override | 2808 @override |
| 2816 CompilationUnit parseCompilationUnit2() { | 2809 CompilationUnit parseCompilationUnit2() { |
| 2817 var result = _run((parser) => parser.parseUnit) as CompilationUnit; | 2810 var result = _run(null) as CompilationUnit; |
| 2818 _eventListener.expectEmpty(); | 2811 _eventListener.expectEmpty(); |
| 2819 return result; | 2812 return result; |
| 2820 } | 2813 } |
| 2821 | 2814 |
| 2822 AnnotatedNode parseTopLevelDeclaration(bool isDirective) { | 2815 AnnotatedNode parseTopLevelDeclaration(bool isDirective) { |
| 2823 _eventListener.begin('CompilationUnit'); | 2816 _eventListener.begin('CompilationUnit'); |
| 2824 _currentFastaToken = | 2817 _currentFastaToken = |
| 2825 _fastaParser.parseTopLevelDeclaration(_currentFastaToken); | 2818 _fastaParser.parseTopLevelDeclaration(_currentFastaToken); |
| 2826 expect(_currentFastaToken.isEof, isTrue); | 2819 expect(_currentFastaToken.isEof, isTrue); |
| 2827 expect(_astBuilder.stack, hasLength(0)); | 2820 expect(_astBuilder.stack, hasLength(0)); |
| 2828 expect(_astBuilder.scriptTag, isNull); | 2821 expect(_astBuilder.scriptTag, isNull); |
| 2829 expect(_astBuilder.directives, hasLength(isDirective ? 1 : 0)); | 2822 expect(_astBuilder.directives, hasLength(isDirective ? 1 : 0)); |
| 2830 expect(_astBuilder.declarations, hasLength(isDirective ? 0 : 1)); | 2823 expect(_astBuilder.declarations, hasLength(isDirective ? 0 : 1)); |
| 2831 _eventListener.end('CompilationUnit'); | 2824 _eventListener.end('CompilationUnit'); |
| 2832 return (isDirective ? _astBuilder.directives : _astBuilder.declarations) | 2825 return (isDirective ? _astBuilder.directives : _astBuilder.declarations) |
| 2833 .first; | 2826 .first; |
| 2834 } | 2827 } |
| 2835 | 2828 |
| 2836 /** | 2829 /** |
| 2837 * Runs a single parser function, and returns the result as an analyzer AST. | 2830 * Runs a single parser function, and returns the result as an analyzer AST. |
| 2838 */ | 2831 */ |
| 2839 Object _run(ParseFunction getParseFunction(fasta.Parser parser)) { | 2832 Object _run(ParseFunction getParseFunction(fasta.Parser parser)) { |
| 2840 var parseFunction = getParseFunction(_fastaParser); | 2833 ParseFunction parseFunction; |
| 2834 if (getParseFunction != null) { |
| 2835 parseFunction = getParseFunction(_fastaParser); |
| 2836 _fastaParser.firstToken = _currentFastaToken; |
| 2837 } else { |
| 2838 parseFunction = _fastaParser.parseUnit; |
| 2839 // firstToken should be set by beginCompilationUnit event. |
| 2840 } |
| 2841 _currentFastaToken = parseFunction(_currentFastaToken); | 2841 _currentFastaToken = parseFunction(_currentFastaToken); |
| 2842 expect(_currentFastaToken.isEof, isTrue); | 2842 expect(_currentFastaToken.isEof, isTrue); |
| 2843 expect(_astBuilder.stack, hasLength(1)); | 2843 expect(_astBuilder.stack, hasLength(1)); |
| 2844 return _astBuilder.pop(); | 2844 return _astBuilder.pop(); |
| 2845 } | 2845 } |
| 2846 } | 2846 } |
| 2847 | 2847 |
| 2848 /** | 2848 /** |
| 2849 * Proxy implementation of [Scope] used by Fasta parser tests. | 2849 * Proxy implementation of [Scope] used by Fasta parser tests. |
| 2850 * | 2850 * |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3026 assertNoErrors(); | 3026 assertNoErrors(); |
| 3027 } | 3027 } |
| 3028 | 3028 |
| 3029 @failingTest | 3029 @failingTest |
| 3030 void test_parseCompilationUnitMember_abstractAsPrefix2() { | 3030 void test_parseCompilationUnitMember_abstractAsPrefix2() { |
| 3031 // TODO(danrubel): should not be generating an error | 3031 // TODO(danrubel): should not be generating an error |
| 3032 super.test_parseCompilationUnitMember_abstractAsPrefix(); | 3032 super.test_parseCompilationUnitMember_abstractAsPrefix(); |
| 3033 assertNoErrors(); | 3033 assertNoErrors(); |
| 3034 } | 3034 } |
| 3035 } | 3035 } |
| OLD | NEW |