-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: make goto_definition multi-token mapping aware
#10252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
goto_definition multi-token mapping aware
|
@Veykril Please take a look. |
crates/ide/src/goto_definition.rs
Outdated
| let navs = tokens | ||
| .clone() | ||
| .into_iter() | ||
| .filter_map(|token| { | ||
| let parent = token.parent()?; | ||
| if let Some(_) = ast::Comment::cast(token.clone()) { | ||
| let (attributes, def) = doc_attributes(&sema, &parent)?; | ||
| let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?; | ||
| let (_, link, ns) = | ||
| extract_definitions_from_docs(&docs).into_iter().find(|&(range, ..)| { | ||
| doc_mapping.map(range).map_or(false, |InFile { file_id, value: range }| { | ||
| 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)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized, this extra comment logic actually doesn't work for comments inside macros currently so instead of doing this you can just do this special comment handling once on the original token and if that fails just do the token descending as planned.
That should simplify things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized, this extra comment logic actually doesn't work for comments inside macros currently
Do you mean this?
macro_rules! foo_macro {
($(#[$attr:meta])* $name:ident) => {
$(#[$attr])*
pub struct $name;
}
}
foo_macro!(
/// Doc comment for [`Foo$0`]
Foo
// ^^^
);5bb9949 to
227450f
Compare
|
Yep, that was the case I meant 👍 |
|
changelog fix (first contribution) make goto_definition multi-token mapping aware |
Implement #10070 in
goto_definition