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

Side by Side Diff: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart

Issue 2738693003: Fix for parsing empty compilation units with Fasta. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « pkg/analyzer/test/generated/parser_fasta_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 fasta.analyzer.ast_builder; 5 library fasta.analyzer.ast_builder;
6 6
7 import 'package:analyzer/analyzer.dart'; 7 import 'package:analyzer/analyzer.dart';
8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory; 8 import 'package:analyzer/dart/ast/ast_factory.dart' show AstFactory;
9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard; 9 import 'package:analyzer/dart/ast/standard_ast_factory.dart' as standard;
10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token; 10 import 'package:analyzer/dart/ast/token.dart' as analyzer show Token;
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 } 845 }
846 846
847 @override 847 @override
848 void endCompilationUnit(int count, Token token) { 848 void endCompilationUnit(int count, Token token) {
849 debugEvent("CompilationUnit"); 849 debugEvent("CompilationUnit");
850 analyzer.Token beginToken = null; // TODO(paulberry) 850 analyzer.Token beginToken = null; // TODO(paulberry)
851 ScriptTag scriptTag = null; // TODO(paulberry) 851 ScriptTag scriptTag = null; // TODO(paulberry)
852 var directives = <Directive>[]; 852 var directives = <Directive>[];
853 var declarations = <CompilationUnitMember>[]; 853 var declarations = <CompilationUnitMember>[];
854 analyzer.Token endToken = null; // TODO(paulberry) 854 analyzer.Token endToken = null; // TODO(paulberry)
855 for (AstNode node in popList(count)) { 855 List<Object> elements = popList(count);
856 if (node is Directive) { 856 if (elements != null) {
857 directives.add(node); 857 for (AstNode node in elements) {
858 } else if (node is CompilationUnitMember) { 858 if (node is Directive) {
859 declarations.add(node); 859 directives.add(node);
860 } else { 860 } else if (node is CompilationUnitMember) {
861 internalError( 861 declarations.add(node);
862 'Unrecognized compilation unit member: ${node.runtimeType}'); 862 } else {
863 internalError(
864 'Unrecognized compilation unit member: ${node.runtimeType}');
865 }
863 } 866 }
864 } 867 }
865 push(ast.compilationUnit( 868 push(ast.compilationUnit(
866 beginToken, scriptTag, directives, declarations, endToken)); 869 beginToken, scriptTag, directives, declarations, endToken));
867 } 870 }
868 871
869 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword, 872 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword,
870 Token semicolon) { 873 Token semicolon) {
871 debugEvent("Import"); 874 debugEvent("Import");
872 List<Combinator> combinators = pop(); 875 List<Combinator> combinators = pop();
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 } else if (identical('static', s)) { 1483 } else if (identical('static', s)) {
1481 staticKeyword = token; 1484 staticKeyword = token;
1482 } else if (identical('var', s)) { 1485 } else if (identical('var', s)) {
1483 finalConstOrVarKeyword = token; 1486 finalConstOrVarKeyword = token;
1484 } else { 1487 } else {
1485 internalError('Unhandled modifier: $s'); 1488 internalError('Unhandled modifier: $s');
1486 } 1489 }
1487 } 1490 }
1488 } 1491 }
1489 } 1492 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_fasta_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698