mirror of
https://github.com/dart-lang/sdk
synced 2024-09-06 00:59:09 +00:00
cleanup insert synthetic identifier
Change-Id: Ia7f2a94664f25ac51c0876d0c3317b78e5c2f63c Reviewed-on: https://dart-review.googlesource.com/64780 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Dan Rubel <danrubel@google.com>
This commit is contained in:
parent
af27e106ee
commit
55921ed4bd
|
@ -1083,10 +1083,7 @@ class Parser {
|
|||
new SyntheticKeywordToken(Keyword.WITH, withKeyword.charOffset);
|
||||
rewriter.insertTokenAfter(token, withKeyword);
|
||||
if (!isValidTypeReference(withKeyword.next)) {
|
||||
rewriter.insertTokenAfter(
|
||||
withKeyword,
|
||||
new SyntheticStringToken(
|
||||
TokenType.IDENTIFIER, '', withKeyword.charOffset));
|
||||
rewriter.insertSyntheticIdentifier(withKeyword);
|
||||
}
|
||||
}
|
||||
listener.beginMixinApplication(withKeyword);
|
||||
|
@ -1872,10 +1869,7 @@ class Parser {
|
|||
Token next = token.next;
|
||||
reportRecoverableError(messageOnToken ?? next,
|
||||
message ?? context.recoveryTemplate.withArguments(next));
|
||||
Token identifier =
|
||||
new SyntheticStringToken(TokenType.IDENTIFIER, '', next.charOffset, 0);
|
||||
rewriter.insertTokenAfter(token, identifier);
|
||||
return token.next;
|
||||
return rewriter.insertSyntheticIdentifier(token);
|
||||
}
|
||||
|
||||
/// Parse a simple identifier at the given [token], and return the identifier
|
||||
|
@ -2308,10 +2302,7 @@ class Parser {
|
|||
next, fasta.templateExpectedButGot.withArguments('.'));
|
||||
rewriter.insertTokenAfter(
|
||||
token, new SyntheticToken(TokenType.PERIOD, next.offset));
|
||||
token = token.next;
|
||||
rewriter.insertTokenAfter(token,
|
||||
new SyntheticStringToken(TokenType.IDENTIFIER, '', next.offset));
|
||||
token = token.next;
|
||||
token = rewriter.insertSyntheticIdentifier(token.next);
|
||||
next = token.next;
|
||||
}
|
||||
// Fall through to recovery
|
||||
|
|
|
@ -55,20 +55,29 @@ class TokenStreamRewriter {
|
|||
next = next.setNext(new SyntheticToken(TokenType.CLOSE_PAREN, offset));
|
||||
leftParen.endGroup = next;
|
||||
next.setNext(token.next);
|
||||
|
||||
// A no-op rewriter could skip this step.
|
||||
token.setNext(leftParen);
|
||||
|
||||
return leftParen;
|
||||
}
|
||||
|
||||
/// Insert a synthetic identifier after [token] and return the new identifier.
|
||||
Token insertSyntheticIdentifier(Token token) {
|
||||
Token identifier = new SyntheticStringToken(
|
||||
TokenType.IDENTIFIER, '', token.next.charOffset, 0)
|
||||
..setNext(token.next);
|
||||
return insertToken(
|
||||
token,
|
||||
new SyntheticStringToken(
|
||||
TokenType.IDENTIFIER, '', token.next.charOffset, 0));
|
||||
}
|
||||
|
||||
// A no-op rewriter could simply return the synthetic identifier here.
|
||||
/// Insert [newToken] after [token] and return [newToken].
|
||||
Token insertToken(Token token, Token newToken) {
|
||||
newToken.setNext(token.next);
|
||||
|
||||
token.setNext(identifier);
|
||||
return identifier;
|
||||
// A no-op rewriter could skip this step.
|
||||
token.setNext(newToken);
|
||||
|
||||
return newToken;
|
||||
}
|
||||
|
||||
/// Insert the chain of tokens starting at the [insertedToken] immediately
|
||||
|
|
Loading…
Reference in a new issue