do comment handling on the original token
@@ -39,13 +39,8 @@ pub(crate) fn goto_definition(
kind if kind.is_trivia() => 0,
_ => 1,
})?;
- let tokens = sema.descend_into_macros_many(original_token.clone());
- let navs = tokens
- .clone()
- .into_iter()
- .filter_map(|token| {
- let parent = token.parent()?;
- if let Some(_) = ast::Comment::cast(token.clone()) {
+ if let Some(_) = ast::Comment::cast(original_token.clone()) {
+ let parent = original_token.parent()?;
let (attributes, def) = doc_attributes(&sema, &parent)?;
let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
let (_, link, ns) =
@@ -55,15 +50,10 @@ pub(crate) fn goto_definition(
})
})?;
let nav = resolve_doc_path_for_def(db, def, &link, ns)?.try_to_nav(db)?;
- return Some(nav);
+ return Some(RangeInfo::new(original_token.text_range(), vec![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()
.filter_map(|token| {
let parent = token.parent()?;
