diff options
author | Lukas Wirth <[email protected]> | 2020-11-14 18:11:09 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2020-11-14 18:11:09 +0000 |
commit | 924eecf4af4d57c597c2e77c5e58c22b2a37bdb6 (patch) | |
tree | de445be048cad200c909464ad5687ecaa71e5ca1 /crates/ide/src/references.rs | |
parent | e55a44a831477e2fc8e11340c3d91db883b97c8e (diff) |
Properly handle shorthands in destructure patterns when renaming
Diffstat (limited to 'crates/ide/src/references.rs')
-rw-r--r-- | crates/ide/src/references.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index e05465b32..10cd42032 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -110,14 +110,23 @@ pub(crate) fn find_all_refs( | |||
110 | .filter(|r| search_kind == ReferenceKind::Other || search_kind == r.kind) | 110 | .filter(|r| search_kind == ReferenceKind::Other || search_kind == r.kind) |
111 | .collect(); | 111 | .collect(); |
112 | 112 | ||
113 | let decl_range = def.try_to_nav(sema.db)?.focus_or_full_range(); | 113 | let nav = def.try_to_nav(sema.db)?; |
114 | 114 | let decl_range = nav.focus_or_full_range(); | |
115 | let declaration = Declaration { | 115 | |
116 | nav: def.try_to_nav(sema.db)?, | 116 | let mut kind = ReferenceKind::Other; |
117 | kind: ReferenceKind::Other, | 117 | if let Definition::Local(local) = def { |
118 | access: decl_access(&def, &syntax, decl_range), | 118 | if let either::Either::Left(pat) = local.source(sema.db).value { |
119 | if matches!( | ||
120 | pat.syntax().parent().and_then(ast::RecordPatField::cast), | ||
121 | Some(pat_field) if pat_field.name_ref().is_none() | ||
122 | ) { | ||
123 | kind = ReferenceKind::FieldShorthandForLocal; | ||
124 | } | ||
125 | } | ||
119 | }; | 126 | }; |
120 | 127 | ||
128 | let declaration = Declaration { nav, kind, access: decl_access(&def, &syntax, decl_range) }; | ||
129 | |||
121 | Some(RangeInfo::new(range, ReferenceSearchResult { declaration, references })) | 130 | Some(RangeInfo::new(range, ReferenceSearchResult { declaration, references })) |
122 | } | 131 | } |
123 | 132 | ||