| Index: dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart
|
| diff --git a/dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart b/dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart
|
| index 289c2c821ef91460cdd74a8db0fb89e2e320880b..182360ef6064ae29dada6eddb058992806364984 100644
|
| --- a/dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart
|
| +++ b/dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart
|
| @@ -348,6 +348,9 @@ class Listener {
|
| void endRethrowStatement(Token throwToken, Token endToken) {
|
| }
|
|
|
| + void endTopLevelDeclaration(Token token) {
|
| + }
|
| +
|
| void beginTopLevelMember(Token token) {
|
| }
|
|
|
| @@ -682,7 +685,7 @@ class ElementListener extends Listener {
|
|
|
| void endLibraryName(Token libraryKeyword, Token semicolon) {
|
| Expression name = popNode();
|
| - addLibraryTag(new LibraryName(libraryKeyword, name));
|
| + addLibraryTag(new LibraryName(libraryKeyword, name, popMetadata(compilationUnitElement)));
|
| }
|
|
|
| void endImport(Token importKeyword, Token asKeyword, Token semicolon) {
|
| @@ -692,7 +695,8 @@ class ElementListener extends Listener {
|
| prefix = popNode();
|
| }
|
| StringNode uri = popLiteralString();
|
| - addLibraryTag(new Import(importKeyword, uri, prefix, combinators));
|
| + addLibraryTag(new Import(importKeyword, uri, prefix, combinators,
|
| + popMetadata(compilationUnitElement)));
|
| }
|
|
|
| void endExport(Token exportKeyword, Token semicolon) {
|
| @@ -728,12 +732,12 @@ class ElementListener extends Listener {
|
|
|
| void endPart(Token partKeyword, Token semicolon) {
|
| StringNode uri = popLiteralString();
|
| - addLibraryTag(new Part(partKeyword, uri));
|
| + addLibraryTag(new Part(partKeyword, uri, popMetadata(compilationUnitElement)));
|
| }
|
|
|
| void endPartOf(Token partKeyword, Token semicolon) {
|
| Expression name = popNode();
|
| - addPartOfTag(new PartOf(partKeyword, name));
|
| + addPartOfTag(new PartOf(partKeyword, name, popMetadata(compilationUnitElement)));
|
| }
|
|
|
| void addPartOfTag(PartOf tag) {
|
| @@ -768,6 +772,14 @@ class ElementListener extends Listener {
|
| pushMetadata(new PartialMetadataAnnotation(beginToken));
|
| }
|
|
|
| + void endTopLevelDeclaration(Token token) {
|
| + if (!metadata.isEmpty) {
|
| + recoverableError('Error: Metadata not supported here.',
|
| + token: metadata.head.beginToken);
|
| + metadata = const Link<MetadataAnnotation>();
|
| + }
|
| + }
|
| +
|
| void endClassDeclaration(int interfacesCount, Token beginToken,
|
| Token extendsKeyword, Token implementsKeyword,
|
| Token endToken) {
|
| @@ -1050,11 +1062,17 @@ class ElementListener extends Listener {
|
| }
|
|
|
| void pushElement(Element element) {
|
| + popMetadata(element);
|
| + compilationUnitElement.addMember(element, listener);
|
| + }
|
| +
|
| + Link<MetadataAnnotation> popMetadata(Element element) {
|
| + var result = metadata;
|
| for (Link link = metadata; !link.isEmpty; link = link.tail) {
|
| element.addMetadata(link.head);
|
| }
|
| metadata = const Link<MetadataAnnotation>();
|
| - compilationUnitElement.addMember(element, listener);
|
| + return result;
|
| }
|
|
|
| void pushMetadata(MetadataAnnotation annotation) {
|
|
|