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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
index 524ba0a92e1e557b637fdadb38f6d43388cddb59..1f9ca9de5881d0ae533a1df161302bb7472159fa 100644
--- a/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
+++ b/pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart
@@ -663,4 +663,70 @@ class AstBuilder extends ScopeListener {
push(ast.compilationUnit(
beginToken, scriptTag, directives, declarations, endToken));
}
+
+ void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword,
+ Token semicolon) {
+ debugEvent("Import");
+ List<Combinator> combinators = pop();
+ SimpleIdentifier prefix;
+ if (asKeyword != null) prefix = pop();
+ List<Configuration> configurations = pop();
+ assert(configurations == null); // TODO(paulberry)
+ StringLiteral uri = pop();
+ List<Annotation> metadata = pop();
+ assert(metadata == null);
+ // TODO(paulberry): capture doc comments.
+ Comment comment = null;
+ push(ast.importDirective(
+ comment,
+ metadata,
+ toAnalyzerToken(importKeyword),
+ uri,
+ configurations,
+ toAnalyzerToken(deferredKeyword),
+ toAnalyzerToken(asKeyword),
+ prefix,
+ combinators,
+ toAnalyzerToken(semicolon)));
+ }
+
+ void endExport(Token exportKeyword, Token semicolon) {
+ debugEvent("Export");
+ List<Combinator> combinators = pop();
+ List<Configuration> configurations = pop();
+ assert(configurations == null); // TODO(paulberry)
+ StringLiteral uri = pop();
+ List<Annotation> metadata = pop();
+ assert(metadata == null);
+ // TODO(paulberry): capture doc comments.
+ Comment comment = null;
+ push(ast.exportDirective(comment, metadata, toAnalyzerToken(exportKeyword),
+ uri, configurations, combinators, toAnalyzerToken(semicolon)));
+ }
+
+ @override
+ void endConditionalUris(int count) {
+ debugEvent("ConditionalUris");
+ push(popList(count) ?? NullValue.ConditionalUris);
+ }
+
+ @override
+ void endIdentifierList(int count) {
+ debugEvent("IdentifierList");
+ push(popList(count) ?? NullValue.IdentifierList);
+ }
+
+ @override
+ void endShow(Token showKeyword) {
+ debugEvent("Show");
+ List<SimpleIdentifier> shownNames = pop();
+ push(ast.showCombinator(toAnalyzerToken(showKeyword), shownNames));
+ }
+
+ @override
+ void endHide(Token hideKeyword) {
+ debugEvent("Hide");
+ List<SimpleIdentifier> hiddenNames = pop();
+ push(ast.hideCombinator(toAnalyzerToken(hideKeyword), hiddenNames));
+ }
}
« 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