Merge #10252
10252: fix: make `goto_definition` multi-token mapping aware r=Veykril a=XFFXFF Implement #10070 in [`goto_definition`](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ide/src/goto_definition.rs) Co-authored-by: zhoufan <1247714429@qq.com>
This commit is contained in:
commit
a435e49d34
@ -39,9 +39,8 @@ pub(crate) fn goto_definition(
|
|||||||
kind if kind.is_trivia() => 0,
|
kind if kind.is_trivia() => 0,
|
||||||
_ => 1,
|
_ => 1,
|
||||||
})?;
|
})?;
|
||||||
let token = sema.descend_into_macros(original_token.clone());
|
if let Some(_) = ast::Comment::cast(original_token.clone()) {
|
||||||
let parent = token.parent()?;
|
let parent = original_token.parent()?;
|
||||||
if let Some(_) = ast::Comment::cast(token.clone()) {
|
|
||||||
let (attributes, def) = doc_attributes(&sema, &parent)?;
|
let (attributes, def) = doc_attributes(&sema, &parent)?;
|
||||||
let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
|
let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
|
||||||
let (_, link, ns) =
|
let (_, link, ns) =
|
||||||
@ -54,6 +53,10 @@ pub(crate) fn goto_definition(
|
|||||||
return Some(RangeInfo::new(original_token.text_range(), vec![nav]));
|
return Some(RangeInfo::new(original_token.text_range(), vec![nav]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let navs = sema.descend_into_macros_many(original_token.clone())
|
||||||
|
.into_iter()
|
||||||
|
.filter_map(|token| {
|
||||||
|
let parent = token.parent()?;
|
||||||
let navs = match_ast! {
|
let navs = match_ast! {
|
||||||
match parent {
|
match parent {
|
||||||
ast::NameRef(name_ref) => {
|
ast::NameRef(name_ref) => {
|
||||||
@ -81,6 +84,10 @@ pub(crate) fn goto_definition(
|
|||||||
_ => return None,
|
_ => return None,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Some(navs)
|
||||||
|
})
|
||||||
|
.flatten()
|
||||||
|
.collect::<Vec<NavigationTarget>>();
|
||||||
|
|
||||||
Some(RangeInfo::new(original_token.text_range(), navs))
|
Some(RangeInfo::new(original_token.text_range(), navs))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user