mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Replace more occurrences of token.previous with findPrevious
Change-Id: If86539e4a50caec456891e58cb9f928762860282 Reviewed-on: https://dart-review.googlesource.com/48560 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Dan Rubel <danrubel@google.com>
This commit is contained in:
parent
d46915d239
commit
f66532b31b
|
@ -72,9 +72,9 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
|||
}
|
||||
if (entity == node.rightParenthesis) {
|
||||
_addExpressionKeywords(node);
|
||||
Token previous = (entity as Token).previous;
|
||||
Token previous = node.findPrevious(entity as Token);
|
||||
if (previous.isSynthetic) {
|
||||
previous = previous.previous;
|
||||
previous = node.findPrevious(previous);
|
||||
}
|
||||
if (previous.lexeme == ')') {
|
||||
_addSuggestion(Keyword.ASYNC);
|
||||
|
@ -129,9 +129,9 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
|||
Expression expression = (entity as ExpressionStatement).expression;
|
||||
if (expression is SimpleIdentifier) {
|
||||
Token token = expression.token;
|
||||
Token previous = token.previous;
|
||||
Token previous = node.findPrevious(token);
|
||||
if (previous.isSynthetic) {
|
||||
previous = previous.previous;
|
||||
previous = node.findPrevious(previous);
|
||||
}
|
||||
Token next = token.next;
|
||||
if (next.isSynthetic) {
|
||||
|
@ -283,9 +283,9 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
|||
@override
|
||||
visitForEachStatement(ForEachStatement node) {
|
||||
if (entity == node.inKeyword) {
|
||||
Token previous = node.inKeyword.previous;
|
||||
Token previous = node.findPrevious(node.inKeyword);
|
||||
if (previous is SyntheticStringToken && previous.lexeme == 'in') {
|
||||
previous = previous.previous;
|
||||
previous = node.findPrevious(previous);
|
||||
}
|
||||
if (previous != null && previous.type == TokenType.EQ) {
|
||||
_addSuggestions([
|
||||
|
@ -757,7 +757,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
|||
static bool _isPreviousTokenSynthetic(Object entity, TokenType type) {
|
||||
if (entity is AstNode) {
|
||||
Token token = entity.beginToken;
|
||||
Token previousToken = token.previous;
|
||||
Token previousToken = entity.findPrevious(token);
|
||||
return previousToken.isSynthetic && previousToken.type == type;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue