Index: pkg/compiler/lib/src/parser/node_listener.dart |
diff --git a/pkg/compiler/lib/src/parser/node_listener.dart b/pkg/compiler/lib/src/parser/node_listener.dart |
index feaa44c7397c5e8823fc2eed767e85e11af9268e..f3e343c7a4cf15475b8dac35dc4030f46f4f1a29 100644 |
--- a/pkg/compiler/lib/src/parser/node_listener.dart |
+++ b/pkg/compiler/lib/src/parser/node_listener.dart |
@@ -27,6 +27,53 @@ class NodeListener extends ElementListener { |
pushNode(tag); |
} |
+ void endLibraryName(Token libraryKeyword, Token semicolon) { |
+ Expression name = popNode(); |
+ pushNode(new LibraryName(libraryKeyword, name, |
+ // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
+ // (element) instead of Metatada (node). |
+ null)); |
+ } |
+ |
+ void endImport(Token importKeyword, Token deferredKeyword, Token asKeyword, |
+ Token semicolon) { |
+ NodeList combinators = popNode(); |
+ Identifier prefix = asKeyword != null ? popNode() : null; |
+ NodeList conditionalUris = popNode(); |
+ StringNode uri = popLiteralString(); |
+ pushNode(new Import(importKeyword, uri, conditionalUris, prefix, |
+ combinators, |
+ // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
+ // (element) instead of Metatada (node). |
+ null, isDeferred: deferredKeyword != null)); |
+ } |
+ |
+ void endExport(Token exportKeyword, Token semicolon) { |
+ NodeList combinators = popNode(); |
+ NodeList conditionalUris = popNode(); |
+ StringNode uri = popLiteralString(); |
+ pushNode(new Export(exportKeyword, uri, conditionalUris, combinators, |
+ // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
+ // (element) instead of Metatada (node). |
+ null)); |
+ } |
+ |
+ void endPart(Token partKeyword, Token semicolon) { |
+ StringNode uri = popLiteralString(); |
+ pushNode(new Part(partKeyword, uri, |
+ // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
+ // (element) instead of Metatada (node). |
+ null)); |
+ } |
+ |
+ void endPartOf(Token partKeyword, Token semicolon) { |
+ Expression name = popNode(); // name |
+ pushNode(new PartOf(partKeyword, name, |
+ // TODO(sigmund): Import AST nodes have pointers to MetadataAnnotation |
+ // (element) instead of Metatada (node). |
+ null)); |
+ } |
+ |
void endClassDeclaration(int interfacesCount, Token beginToken, |
Token extendsKeyword, Token implementsKeyword, Token endToken) { |
NodeList body = popNode(); |
@@ -40,6 +87,15 @@ class NodeListener extends ElementListener { |
interfaces, beginToken, extendsKeyword, body, endToken)); |
} |
+ void endTopLevelDeclaration(Token token) { |
+ // TODO(sigmund): consider moving metadata into each declaration |
+ // element instead. |
+ Node node = popNode(); // top-level declaration |
+ popNode(); // Discard metadata |
+ pushNode(node); |
+ super.endTopLevelDeclaration(token); |
+ } |
+ |
void endCompilationUnit(int count, Token token) { |
pushNode(makeNodeList(count, null, null, '\n')); |
} |
@@ -82,15 +138,15 @@ class NodeListener extends ElementListener { |
} |
void endTopLevelMethod(Token beginToken, Token getOrSet, Token endToken) { |
- popNode(); // body |
- popNode(); // formalParameters |
- popNode(); // typeVariables |
+ Statement body = popNode(); |
+ AsyncModifier asyncModifier = popNode(); |
+ NodeList formals = popNode(); |
+ NodeList typeVariables = popNode(); |
Identifier name = popNode(); |
- popNode(); // type |
+ TypeAnnotation type = popNode(); |
Modifiers modifiers = popNode(); |
- PartialFunctionElement element = new PartialFunctionElement(name.source, |
- beginToken, getOrSet, endToken, modifiers, compilationUnitElement); |
- pushElement(element); |
+ pushNode(new FunctionExpression(name, typeVariables, formals, body, type, |
Siggi Cherem (dart-lang)
2016/09/30 22:28:07
note: this was inconsistent (likely copy/paste err
|
+ modifiers, null, getOrSet, asyncModifier)); |
} |
void endFormalParameter(Token thisKeyword) { |
@@ -481,6 +537,15 @@ class NodeListener extends ElementListener { |
pushNode(null); |
} |
+ void endMember() { |
+ // TODO(sigmund): consider moving metadata into each declaration |
+ // element instead. |
+ Node node = popNode(); // member |
+ popNode(); // Discard metadata |
+ pushNode(node); |
+ super.endMember(); |
+ } |
+ |
void endFields(int count, Token beginToken, Token endToken) { |
NodeList variables = makeNodeList(count, null, endToken, ","); |
TypeAnnotation type = popNode(); |
@@ -693,13 +758,10 @@ class NodeListener extends ElementListener { |
} |
void endMetadataStar(int count, bool forParameter) { |
- // TODO(johnniwinther): Handle metadata for all node kinds. |
- if (forParameter) { |
- if (0 == count) { |
- pushNode(null); |
- } else { |
- pushNode(makeNodeList(count, null, null, ' ')); |
- } |
+ if (0 == count) { |
+ pushNode(null); |
+ } else { |
+ pushNode(makeNodeList(count, null, null, ' ')); |
} |
} |