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

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

Issue 3001993002: improve fasta export directive recovery (Closed)
Patch Set: Created 3 years, 4 months 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 import 'package:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
7 import 'package:analyzer/dart/ast/token.dart'; 7 import 'package:analyzer/dart/ast/token.dart';
8 import 'package:analyzer/dart/ast/visitor.dart'; 8 import 'package:analyzer/dart/ast/visitor.dart';
9 import 'package:analyzer/error/error.dart'; 9 import 'package:analyzer/error/error.dart';
10 import 'package:analyzer/error/listener.dart'; 10 import 'package:analyzer/error/listener.dart';
(...skipping 2627 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 void test_expectedToken_parseStatement_afterVoid() { 2638 void test_expectedToken_parseStatement_afterVoid() {
2639 parseStatement("void}"); 2639 parseStatement("void}");
2640 assertErrorsWithCodes( 2640 assertErrorsWithCodes(
2641 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]); 2641 [ParserErrorCode.EXPECTED_TOKEN, ParserErrorCode.MISSING_IDENTIFIER]);
2642 } 2642 }
2643 2643
2644 void test_expectedToken_semicolonMissingAfterExport() { 2644 void test_expectedToken_semicolonMissingAfterExport() {
2645 CompilationUnit unit = parseCompilationUnit( 2645 CompilationUnit unit = parseCompilationUnit(
2646 "export '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); 2646 "export '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]);
2647 ExportDirective directive = unit.directives[0] as ExportDirective; 2647 ExportDirective directive = unit.directives[0] as ExportDirective;
2648 expect(directive.uri, isNotNull);
2649 expect(directive.uri.stringValue, '');
2650 expect(directive.uri.beginToken.isSynthetic, false);
2651 expect(directive.uri.isSynthetic, false);
2648 Token semicolon = directive.semicolon; 2652 Token semicolon = directive.semicolon;
2649 expect(semicolon, isNotNull); 2653 expect(semicolon, isNotNull);
2650 expect(semicolon.isSynthetic, isTrue); 2654 expect(semicolon.isSynthetic, isTrue);
2655 ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration;
2656 expect(clazz.name.name, 'A');
2657 }
2658
2659 void test_expectedToken_uriAndSemicolonMissingAfterExport() {
2660 CompilationUnit unit = parseCompilationUnit("export class A {}", [
2661 ParserErrorCode.EXPECTED_STRING_LITERAL,
2662 ParserErrorCode.EXPECTED_TOKEN,
2663 ]);
2664 ExportDirective directive = unit.directives[0] as ExportDirective;
2665 expect(directive.uri, isNotNull);
2666 expect(directive.uri.stringValue, '');
2667 expect(directive.uri.beginToken.isSynthetic, true);
2668 expect(directive.uri.isSynthetic, true);
2669 Token semicolon = directive.semicolon;
2670 expect(semicolon, isNotNull);
2671 expect(semicolon.isSynthetic, isTrue);
2672 ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration;
2673 expect(clazz.name.name, 'A');
2651 } 2674 }
2652 2675
2653 void test_expectedToken_semicolonMissingAfterExpression() { 2676 void test_expectedToken_semicolonMissingAfterExpression() {
2654 parseStatement("x"); 2677 parseStatement("x");
2655 assertErrorsWithCodes([ParserErrorCode.EXPECTED_TOKEN]); 2678 assertErrorsWithCodes([ParserErrorCode.EXPECTED_TOKEN]);
2656 } 2679 }
2657 2680
2658 void test_expectedToken_semicolonMissingAfterImport() { 2681 void test_expectedToken_semicolonMissingAfterImport() {
2659 CompilationUnit unit = parseCompilationUnit( 2682 CompilationUnit unit = parseCompilationUnit(
2660 "import '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]); 2683 "import '' class A {}", [ParserErrorCode.EXPECTED_TOKEN]);
(...skipping 12772 matching lines...) Expand 10 before | Expand all | Expand 10 after
15433 expectCommentText(typeVariable.documentationComment, '/// Doc'); 15456 expectCommentText(typeVariable.documentationComment, '/// Doc');
15434 } 15457 }
15435 15458
15436 /** 15459 /**
15437 * Assert that the given [name] is in declaration context. 15460 * Assert that the given [name] is in declaration context.
15438 */ 15461 */
15439 void _assertIsDeclarationName(SimpleIdentifier name) { 15462 void _assertIsDeclarationName(SimpleIdentifier name) {
15440 expect(name.inDeclarationContext(), isTrue); 15463 expect(name.inDeclarationContext(), isTrue);
15441 } 15464 }
15442 } 15465 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698