From 294e8a1ac1855f0c604f961878aa3f7af236a732 Mon Sep 17 00:00:00 2001 From: Brian Wilkerson Date: Wed, 20 Dec 2017 17:57:13 +0000 Subject: [PATCH] Create a recovery method in ClassMethodModifierContext Change-Id: I3e721995efd71f9905fd9dc001b05148fd48973b Reviewed-on: https://dart-review.googlesource.com/30883 Reviewed-by: Dan Rubel Commit-Queue: Brian Wilkerson --- .../lib/src/fasta/parser/modifier_context.dart | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/front_end/lib/src/fasta/parser/modifier_context.dart b/pkg/front_end/lib/src/fasta/parser/modifier_context.dart index c8920eeeb4c..5d9eddeb0fc 100644 --- a/pkg/front_end/lib/src/fasta/parser/modifier_context.dart +++ b/pkg/front_end/lib/src/fasta/parser/modifier_context.dart @@ -478,11 +478,7 @@ class ClassMethodModifierContext { } else if (identical(value, 'static')) { token = parseStaticRecovery(token); } else if (identical(value, 'typedef')) { - // TODO(brianwilkerson): Move this into a `parseTypedefRecovery` method - // that can be more sophisticated about skipping the rest of the typedef - // declaration. - parser.reportRecoverableError(token.next, fasta.messageTypedefInClass); - token = token.next; + token = parseTypedefRecovery(token); } else if (identical(value, 'var')) { token = parseVarRecovery(token); } else if (token.next.isModifier) { @@ -637,6 +633,16 @@ class ClassMethodModifierContext { return next; } + Token parseTypedefRecovery(Token token) { + token = token.next; + assert(optional('typedef', token)); + parser.reportRecoverableError(token, fasta.messageTypedefInClass); + // TODO(brianwilkerson) If the declaration appears to be a valid typedef + // then skip the entire declaration so that we generate a single error + // (above) rather than many unhelpful errors. + return token; + } + Token parseVarRecovery(Token token) { token = token.next; if (token.next.isIdentifier && optional('(', token.next.next)) {