diff options
Diffstat (limited to 'crates/ide')
-rw-r--r-- | crates/ide/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/references.rs | 8 | ||||
-rw-r--r-- | crates/ide/src/references/rename.rs | 12 |
3 files changed, 8 insertions, 14 deletions
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index a245d9341..592b12925 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs | |||
@@ -94,7 +94,7 @@ pub use ide_db::{ | |||
94 | call_info::CallInfo, | 94 | call_info::CallInfo, |
95 | label::Label, | 95 | label::Label, |
96 | line_index::{LineCol, LineIndex}, | 96 | line_index::{LineCol, LineIndex}, |
97 | search::{FileReference, ReferenceAccess, SearchScope}, | 97 | search::{ReferenceAccess, SearchScope}, |
98 | source_change::{FileSystemEdit, SourceChange}, | 98 | source_change::{FileSystemEdit, SourceChange}, |
99 | symbol_index::Query, | 99 | symbol_index::Query, |
100 | RootDatabase, | 100 | RootDatabase, |
diff --git a/crates/ide/src/references.rs b/crates/ide/src/references.rs index f96fac9c1..77c208be9 100644 --- a/crates/ide/src/references.rs +++ b/crates/ide/src/references.rs | |||
@@ -66,12 +66,8 @@ pub(crate) fn find_all_refs( | |||
66 | let mut usages = def.usages(sema).set_scope(search_scope).all(); | 66 | let mut usages = def.usages(sema).set_scope(search_scope).all(); |
67 | if let Some(ctor_filter) = ctor_filter { | 67 | if let Some(ctor_filter) = ctor_filter { |
68 | // filter for constructor-literals | 68 | // filter for constructor-literals |
69 | usages.references.iter_mut().for_each(|(&file_id, it)| { | 69 | usages.references.values_mut().for_each(|it| { |
70 | let root = sema.parse(file_id); | 70 | it.retain(|reference| reference.name.as_name_ref().map_or(false, ctor_filter)); |
71 | let root = root.syntax(); | ||
72 | it.retain(|reference| { | ||
73 | reference.as_name_ref(root).map_or(false, |name_ref| ctor_filter(&name_ref)) | ||
74 | }) | ||
75 | }); | 71 | }); |
76 | usages.references.retain(|_, it| !it.is_empty()); | 72 | usages.references.retain(|_, it| !it.is_empty()); |
77 | } | 73 | } |
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index 64992c72d..b04214291 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs | |||
@@ -164,20 +164,18 @@ fn find_definition( | |||
164 | } | 164 | } |
165 | 165 | ||
166 | fn source_edit_from_references( | 166 | fn source_edit_from_references( |
167 | sema: &Semantics<RootDatabase>, | 167 | _sema: &Semantics<RootDatabase>, |
168 | file_id: FileId, | 168 | file_id: FileId, |
169 | references: &[FileReference], | 169 | references: &[FileReference], |
170 | def: Definition, | 170 | def: Definition, |
171 | new_name: &str, | 171 | new_name: &str, |
172 | ) -> (FileId, TextEdit) { | 172 | ) -> (FileId, TextEdit) { |
173 | let root = sema.parse(file_id); | ||
174 | let mut edit = TextEdit::builder(); | 173 | let mut edit = TextEdit::builder(); |
175 | for reference in references { | 174 | for reference in references { |
176 | let (range, replacement) = match &reference.name_from_syntax(root.syntax()) { | 175 | let (range, replacement) = match &reference.name { |
177 | Some(NameLike::Name(_)) => (None, format!("{}", new_name)), | 176 | NameLike::Name(_) => (None, format!("{}", new_name)), |
178 | Some(NameLike::NameRef(name_ref)) => source_edit_from_name_ref(name_ref, new_name, def), | 177 | NameLike::NameRef(name_ref) => source_edit_from_name_ref(name_ref, new_name, def), |
179 | Some(NameLike::Lifetime(_)) => (None, format!("{}", new_name)), | 178 | NameLike::Lifetime(_) => (None, format!("{}", new_name)), |
180 | None => (None, new_name.to_owned()), | ||
181 | }; | 179 | }; |
182 | // FIXME: Some(range) will be incorrect when we are inside macros | 180 | // FIXME: Some(range) will be incorrect when we are inside macros |
183 | edit.replace(range.unwrap_or(reference.range), replacement); | 181 | edit.replace(range.unwrap_or(reference.range), replacement); |