Fix token ascension single token check being inverted
This commit is contained in:
parent
0808ade4e4
commit
5fd3688018
@ -705,19 +705,21 @@ fn ascend_node_border_tokens(
|
||||
) -> Option<InFile<(SyntaxToken, SyntaxToken)>> {
|
||||
let expansion = file_id.expansion_info(db)?;
|
||||
|
||||
// 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 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);
|
||||
|
||||
let first = first_token(node)?;
|
||||
let last = last_token(node)?;
|
||||
let is_single_token = first == last;
|
||||
|
||||
node.descendants().find_map(|it| {
|
||||
let first = skip_trivia_token(it.first_token()?, Direction::Next)?;
|
||||
let first = first_token(&it)?;
|
||||
let first = ascend_call_token(db, &expansion, InFile::new(file_id, first))?;
|
||||
|
||||
let last = skip_trivia_token(it.last_token()?, Direction::Prev)?;
|
||||
let last = last_token(&it)?;
|
||||
let last = ascend_call_token(db, &expansion, InFile::new(file_id, last))?;
|
||||
|
||||
if (!is_single_token && first == last) || (first.file_id != last.file_id) {
|
||||
if (is_single_token && first != last) || (first.file_id != last.file_id) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -405,7 +405,7 @@ fn caller() {
|
||||
call!(call$0ee);
|
||||
}
|
||||
"#,
|
||||
expect![[r#"callee Function FileId(0) 144..159 152..158"#]],
|
||||
expect![[r#"callee Function FileId(0) 152..158 152..158"#]],
|
||||
expect![[r#"caller Function FileId(0) 160..194 163..169 : [184..190]"#]],
|
||||
expect![[]],
|
||||
);
|
||||
@ -426,7 +426,7 @@ fn caller() {
|
||||
call!(callee);
|
||||
}
|
||||
"#,
|
||||
expect![[r#"callee Function FileId(0) 144..159 152..158"#]],
|
||||
expect![[r#"callee Function FileId(0) 152..158 152..158"#]],
|
||||
expect![[r#"caller Function FileId(0) 160..194 163..169 : [184..190]"#]],
|
||||
expect![[]],
|
||||
);
|
||||
|
@ -1484,12 +1484,12 @@ fn f() {
|
||||
}
|
||||
"#,
|
||||
expect![[r#"
|
||||
func Function FileId(0) 137..146 140..144
|
||||
func Function FileId(0) 140..144 140..144
|
||||
|
||||
FileId(0) 161..165
|
||||
|
||||
|
||||
func Function FileId(0) 137..146 140..144
|
||||
func Function FileId(0) 140..144 140..144
|
||||
|
||||
FileId(0) 181..185
|
||||
"#]],
|
||||
|
Loading…
Reference in New Issue
Block a user