mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:36:59 +00:00
Create a recovery method in ClassMethodModifierContext
Change-Id: I3e721995efd71f9905fd9dc001b05148fd48973b Reviewed-on: https://dart-review.googlesource.com/30883 Reviewed-by: Dan Rubel <danrubel@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
36057d82fa
commit
294e8a1ac1
|
@ -478,11 +478,7 @@ class ClassMethodModifierContext {
|
||||||
} else if (identical(value, 'static')) {
|
} else if (identical(value, 'static')) {
|
||||||
token = parseStaticRecovery(token);
|
token = parseStaticRecovery(token);
|
||||||
} else if (identical(value, 'typedef')) {
|
} else if (identical(value, 'typedef')) {
|
||||||
// TODO(brianwilkerson): Move this into a `parseTypedefRecovery` method
|
token = parseTypedefRecovery(token);
|
||||||
// that can be more sophisticated about skipping the rest of the typedef
|
|
||||||
// declaration.
|
|
||||||
parser.reportRecoverableError(token.next, fasta.messageTypedefInClass);
|
|
||||||
token = token.next;
|
|
||||||
} else if (identical(value, 'var')) {
|
} else if (identical(value, 'var')) {
|
||||||
token = parseVarRecovery(token);
|
token = parseVarRecovery(token);
|
||||||
} else if (token.next.isModifier) {
|
} else if (token.next.isModifier) {
|
||||||
|
@ -637,6 +633,16 @@ class ClassMethodModifierContext {
|
||||||
return next;
|
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 parseVarRecovery(Token token) {
|
||||||
token = token.next;
|
token = token.next;
|
||||||
if (token.next.isIdentifier && optional('(', token.next.next)) {
|
if (token.next.isIdentifier && optional('(', token.next.next)) {
|
||||||
|
|
Loading…
Reference in a new issue