mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
do comment handling on the original token
This commit is contained in:
parent
ea3535cefc
commit
227450f9b9
1 changed files with 14 additions and 24 deletions
|
@ -39,31 +39,21 @@ pub(crate) fn goto_definition(
|
||||||
kind if kind.is_trivia() => 0,
|
kind if kind.is_trivia() => 0,
|
||||||
_ => 1,
|
_ => 1,
|
||||||
})?;
|
})?;
|
||||||
let tokens = sema.descend_into_macros_many(original_token.clone());
|
if let Some(_) = ast::Comment::cast(original_token.clone()) {
|
||||||
let navs = tokens
|
let parent = original_token.parent()?;
|
||||||
.clone()
|
let (attributes, def) = doc_attributes(&sema, &parent)?;
|
||||||
.into_iter()
|
let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
|
||||||
.filter_map(|token| {
|
let (_, link, ns) =
|
||||||
let parent = token.parent()?;
|
extract_definitions_from_docs(&docs).into_iter().find(|&(range, ..)| {
|
||||||
if let Some(_) = ast::Comment::cast(token.clone()) {
|
doc_mapping.map(range).map_or(false, |InFile { file_id, value: range }| {
|
||||||
let (attributes, def) = doc_attributes(&sema, &parent)?;
|
file_id == position.file_id.into() && range.contains(position.offset)
|
||||||
let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
|
})
|
||||||
let (_, link, ns) =
|
})?;
|
||||||
extract_definitions_from_docs(&docs).into_iter().find(|&(range, ..)| {
|
let nav = resolve_doc_path_for_def(db, def, &link, ns)?.try_to_nav(db)?;
|
||||||
doc_mapping.map(range).map_or(false, |InFile { file_id, value: range }| {
|
return Some(RangeInfo::new(original_token.text_range(), vec![nav]));
|
||||||
file_id == position.file_id.into() && range.contains(position.offset)
|
|
||||||
})
|
|
||||||
})?;
|
|
||||||
let nav = resolve_doc_path_for_def(db, def, &link, ns)?.try_to_nav(db)?;
|
|
||||||
return Some(nav);
|
|
||||||
}
|
|
||||||
None
|
|
||||||
})
|
|
||||||
.collect::<Vec<NavigationTarget>>();
|
|
||||||
if navs.len() > 0 {
|
|
||||||
return Some(RangeInfo::new(original_token.text_range(), navs));
|
|
||||||
}
|
}
|
||||||
let navs = tokens
|
|
||||||
|
let navs = sema.descend_into_macros_many(original_token.clone())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|token| {
|
.filter_map(|token| {
|
||||||
let parent = token.parent()?;
|
let parent = token.parent()?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue