| Index: pkg/analyzer/lib/src/fasta/ast_builder.dart
|
| diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
|
| index 294bd16e7d44982187d96fdb71509f60936039b7..a0b092ec1f34067018540972df3d2e5e6867af06 100644
|
| --- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
|
| +++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
|
| @@ -1123,6 +1123,16 @@ class AstBuilder extends ScopeListener {
|
| debugEvent("TopLevelDeclaration");
|
| }
|
|
|
| + @override
|
| + void handleInvalidTopLevelDeclaration(Token endToken) {
|
| + debugEvent("InvalidTopLevelDeclaration");
|
| + pop(); // metadata star
|
| + // TODO(danrubel): consider creating a AST node
|
| + // representing the invalid declaration to better support code completion,
|
| + // quick fixes, etc, rather than discarding the metadata and token
|
| + push(NullValue.InvalidTopLevelDeclaration);
|
| + }
|
| +
|
| @override
|
| void beginCompilationUnit(Token token) {
|
| push(token);
|
| @@ -1145,6 +1155,11 @@ class AstBuilder extends ScopeListener {
|
| directives.add(node);
|
| } else if (node is CompilationUnitMember) {
|
| declarations.add(node);
|
| + } else if (node == NullValue.InvalidTopLevelDeclaration) {
|
| + // TODO(danrubel): consider creating a AST node
|
| + // representing the invalid declaration
|
| + // to better support code completion, quick fixes, etc,
|
| + // rather than discarding the metadata and token
|
| } else {
|
| unhandled(
|
| "${node.runtimeType}", "compilation unit", node?.offset, uri);
|
|
|