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

Unified Diff: pkg/analyzer/lib/src/fasta/ast_builder.dart

Issue 2985703002: new handleInvalidTopLevelDeclaration event in fasta parser (Closed)
Patch Set: rebase and address comment Created 3 years, 4 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_fasta_listener.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_fasta_listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698