mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
fix: Do not force descend into derives for goto IDE features
Doing so can cause us to duplicate navigation targets for the same ranges which breaks convenience features of some editors where go to def can trigger find all references
This commit is contained in:
parent
c15fc9a344
commit
c8cedae2f9
@ -244,7 +244,7 @@ impl<DB: HirDatabase + ?Sized> Semantics<'_, DB> {
|
|||||||
offset: TextSize,
|
offset: TextSize,
|
||||||
) -> impl Iterator<Item = ast::NameLike> + 'slf {
|
) -> impl Iterator<Item = ast::NameLike> + 'slf {
|
||||||
node.token_at_offset(offset)
|
node.token_at_offset(offset)
|
||||||
.map(move |token| self.descend_into_macros_no_opaque(token))
|
.map(move |token| self.descend_into_macros_no_opaque(token, true))
|
||||||
.map(|descendants| descendants.into_iter().filter_map(move |it| it.value.parent()))
|
.map(|descendants| descendants.into_iter().filter_map(move |it| it.value.parent()))
|
||||||
// re-order the tokens from token_at_offset by returning the ancestors with the smaller first nodes first
|
// re-order the tokens from token_at_offset by returning the ancestors with the smaller first nodes first
|
||||||
// See algo::ancestors_at_offset, which uses the same approach
|
// See algo::ancestors_at_offset, which uses the same approach
|
||||||
@ -1009,10 +1009,11 @@ impl<'db> SemanticsImpl<'db> {
|
|||||||
pub fn descend_into_macros_no_opaque(
|
pub fn descend_into_macros_no_opaque(
|
||||||
&self,
|
&self,
|
||||||
token: SyntaxToken,
|
token: SyntaxToken,
|
||||||
|
always_descend_into_derives: bool,
|
||||||
) -> SmallVec<[InFile<SyntaxToken>; 1]> {
|
) -> SmallVec<[InFile<SyntaxToken>; 1]> {
|
||||||
let mut res = smallvec![];
|
let mut res = smallvec![];
|
||||||
let token = self.wrap_token_infile(token);
|
let token = self.wrap_token_infile(token);
|
||||||
self.descend_into_macros_all(token.clone(), true, &mut |t, ctx| {
|
self.descend_into_macros_all(token.clone(), always_descend_into_derives, &mut |t, ctx| {
|
||||||
if !ctx.is_opaque(self.db) {
|
if !ctx.is_opaque(self.db) {
|
||||||
// Don't descend into opaque contexts
|
// Don't descend into opaque contexts
|
||||||
res.push(t);
|
res.push(t);
|
||||||
|
@ -29,7 +29,7 @@ pub(crate) fn goto_declaration(
|
|||||||
.find(|it| matches!(it.kind(), IDENT | T![self] | T![super] | T![crate] | T![Self]))?;
|
.find(|it| matches!(it.kind(), IDENT | T![self] | T![super] | T![crate] | T![Self]))?;
|
||||||
let range = original_token.text_range();
|
let range = original_token.text_range();
|
||||||
let info: Vec<NavigationTarget> = sema
|
let info: Vec<NavigationTarget> = sema
|
||||||
.descend_into_macros_no_opaque(original_token)
|
.descend_into_macros_no_opaque(original_token, false)
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|token| {
|
.filter_map(|token| {
|
||||||
let parent = token.value.parent()?;
|
let parent = token.value.parent()?;
|
||||||
|
@ -88,7 +88,7 @@ pub(crate) fn goto_definition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let navs = sema
|
let navs = sema
|
||||||
.descend_into_macros_no_opaque(original_token.clone())
|
.descend_into_macros_no_opaque(original_token.clone(), false)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|token| {
|
.filter_map(|token| {
|
||||||
let parent = token.value.parent()?;
|
let parent = token.value.parent()?;
|
||||||
|
@ -70,7 +70,7 @@ pub(crate) fn goto_type_definition(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let range = token.text_range();
|
let range = token.text_range();
|
||||||
sema.descend_into_macros_no_opaque(token)
|
sema.descend_into_macros_no_opaque(token,false)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|token| {
|
.filter_map(|token| {
|
||||||
sema
|
sema
|
||||||
|
Loading…
x
Reference in New Issue
Block a user