@@ -608,16 +608,8 @@ fn classify_name_ref(
608
608
609
609
let reciever_is_part_of_indivisible_expression = match &receiver {
610
610
Some(ast::Expr::IfExpr(_)) => {
611
- let next_sibling = field.dot_token().and_then(|token| {
612
- let dot_token = original_file.covering_element(token.text_range());
613
- let next_sibling = dot_token.as_token().and_then(|t| t.next_token()).and_then(|t| next_non_trivia_sibling(t.into()));
614
- next_sibling
615
- });
616
- match next_sibling {
617
- Some(syntax::NodeOrToken::Node(n)) => n.first_child_or_token().map(|t| t.kind()) == Some(SyntaxKind::ELSE_KW),
618
- Some(syntax::NodeOrToken::Token(t)) => t.kind() == SyntaxKind::ELSE_KW,
619
- None => false
620
- }
611
+ let next_token_kind = next_non_trivia_token(name_ref.syntax().clone()).map(|t| t.kind());
612
+ next_token_kind == Some(SyntaxKind::ELSE_KW)
621
613
},
622
614
_ => false
623
615
};
@@ -1337,6 +1329,22 @@ fn previous_non_trivia_token(e: impl Into<SyntaxElement>) -> Option<SyntaxToken>
1337
1329
None
1338
1330
}
1339
1331
1332
+ fn next_non_trivia_token(e: impl Into<SyntaxElement>) -> Option<SyntaxToken> {
1333
+ let mut token = match e.into() {
1334
+ SyntaxElement::Node(n) => n.last_token()?,
1335
+ SyntaxElement::Token(t) => t,
1336
+ }
1337
+ .next_token();
1338
+ while let Some(inner) = token {
1339
+ if !inner.kind().is_trivia() {
1340
+ return Some(inner);
1341
+ } else {
1342
+ token = inner.next_token();
1343
+ }
1344
+ }
1345
+ None
1346
+ }
1347
+
1340
1348
fn next_non_trivia_sibling(ele: SyntaxElement) -> Option<SyntaxElement> {
1341
1349
let mut e = ele.next_sibling_or_token();
1342
1350
while let Some(inner) = e {
0 commit comments