- // the input node has only one token ?
- let first = skip_trivia_token(node.first_token()?, Direction::Next)?;
- let last = skip_trivia_token(node.last_token()?, Direction::Prev)?;
- let is_single_token = first == last;
-
- node.descendants().find_map(|it| {
- let first = skip_trivia_token(it.first_token()?, Direction::Next)?;
- let first = ascend_call_token(db, &expansion, InFile::new(file_id, first))?;
-
- let last = skip_trivia_token(it.last_token()?, Direction::Prev)?;
- let last = ascend_call_token(db, &expansion, InFile::new(file_id, last))?;
-
- if (!is_single_token && first == last) || (first.file_id != last.file_id) {
- return None;
- }
+ let first_token = |node: &SyntaxNode| skip_trivia_token(node.first_token()?, Direction::Next);
+ let last_token = |node: &SyntaxNode| skip_trivia_token(node.last_token()?, Direction::Prev);