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

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

Issue 2691423007: Add AstBuilder support for import and export directives. (Closed)
Patch Set: Move comment Created 3 years, 10 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) 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:front_end/src/fasta/scanner/token.dart' 7 import 'package:front_end/src/fasta/scanner/token.dart'
8 show BeginGroupToken, Token; 8 show BeginGroupToken, Token;
9 9
10 import 'package:analyzer/analyzer.dart'; 10 import 'package:analyzer/analyzer.dart';
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } else if (node is CompilationUnitMember) { 656 } else if (node is CompilationUnitMember) {
657 declarations.add(node); 657 declarations.add(node);
658 } else { 658 } else {
659 internalError( 659 internalError(
660 'Unrecognized compilation unit member: ${node.runtimeType}'); 660 'Unrecognized compilation unit member: ${node.runtimeType}');
661 } 661 }
662 } 662 }
663 push(ast.compilationUnit( 663 push(ast.compilationUnit(
664 beginToken, scriptTag, directives, declarations, endToken)); 664 beginToken, scriptTag, directives, declarations, endToken));
665 } 665 }
666
667 void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword,
668 Token semicolon) {
669 debugEvent("Import");
670 List<Combinator> combinators = pop();
671 SimpleIdentifier prefix;
672 if (asKeyword != null) prefix = pop();
673 List<Configuration> configurations = pop();
674 assert(configurations == null); // TODO(paulberry)
675 StringLiteral uri = pop();
676 List<Annotation> metadata = pop();
677 assert(metadata == null);
678 // TODO(paulberry): capture doc comments.
679 Comment comment = null;
680 push(ast.importDirective(
681 comment,
682 metadata,
683 toAnalyzerToken(importKeyword),
684 uri,
685 configurations,
686 toAnalyzerToken(deferredKeyword),
687 toAnalyzerToken(asKeyword),
688 prefix,
689 combinators,
690 toAnalyzerToken(semicolon)));
691 }
692
693 void endExport(Token exportKeyword, Token semicolon) {
694 debugEvent("Export");
695 List<Combinator> combinators = pop();
696 List<Configuration> configurations = pop();
697 assert(configurations == null); // TODO(paulberry)
698 StringLiteral uri = pop();
699 List<Annotation> metadata = pop();
700 assert(metadata == null);
701 // TODO(paulberry): capture doc comments.
702 Comment comment = null;
703 push(ast.exportDirective(comment, metadata, toAnalyzerToken(exportKeyword),
704 uri, configurations, combinators, toAnalyzerToken(semicolon)));
705 }
706
707 @override
708 void endConditionalUris(int count) {
709 debugEvent("ConditionalUris");
710 push(popList(count) ?? NullValue.ConditionalUris);
711 }
712
713 @override
714 void endIdentifierList(int count) {
715 debugEvent("IdentifierList");
716 push(popList(count) ?? NullValue.IdentifierList);
717 }
718
719 @override
720 void endShow(Token showKeyword) {
721 debugEvent("Show");
722 List<SimpleIdentifier> shownNames = pop();
723 push(ast.showCombinator(toAnalyzerToken(showKeyword), shownNames));
724 }
725
726 @override
727 void endHide(Token hideKeyword) {
728 debugEvent("Hide");
729 List<SimpleIdentifier> hiddenNames = pop();
730 push(ast.hideCombinator(toAnalyzerToken(hideKeyword), hiddenNames));
731 }
666 } 732 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/parser_fasta_test.dart ('k') | pkg/front_end/lib/src/fasta/parser/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698