diff options
Diffstat (limited to 'crates/ide/src/references')
-rw-r--r-- | crates/ide/src/references/rename.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/crates/ide/src/references/rename.rs b/crates/ide/src/references/rename.rs index dd08e1c32..5207388b5 100644 --- a/crates/ide/src/references/rename.rs +++ b/crates/ide/src/references/rename.rs | |||
@@ -9,7 +9,7 @@ use hir::{Module, ModuleDef, ModuleSource, Semantics}; | |||
9 | use ide_db::{ | 9 | use ide_db::{ |
10 | base_db::{AnchoredPathBuf, FileId, FileRange, SourceDatabaseExt}, | 10 | base_db::{AnchoredPathBuf, FileId, FileRange, SourceDatabaseExt}, |
11 | defs::{Definition, NameClass, NameRefClass}, | 11 | defs::{Definition, NameClass, NameRefClass}, |
12 | search::FileReferences, | 12 | search::FileReference, |
13 | RootDatabase, | 13 | RootDatabase, |
14 | }; | 14 | }; |
15 | use syntax::{ | 15 | use syntax::{ |
@@ -176,7 +176,8 @@ fn find_all_refs( | |||
176 | 176 | ||
177 | fn source_edit_from_references( | 177 | fn source_edit_from_references( |
178 | sema: &Semantics<RootDatabase>, | 178 | sema: &Semantics<RootDatabase>, |
179 | &FileReferences { file_id, ref references }: &FileReferences, | 179 | file_id: FileId, |
180 | references: &[FileReference], | ||
180 | new_name: &str, | 181 | new_name: &str, |
181 | ) -> SourceFileEdit { | 182 | ) -> SourceFileEdit { |
182 | let mut edit = TextEdit::builder(); | 183 | let mut edit = TextEdit::builder(); |
@@ -283,10 +284,9 @@ fn rename_mod( | |||
283 | } | 284 | } |
284 | 285 | ||
285 | let RangeInfo { range, info: refs } = find_all_refs(sema, position)?; | 286 | let RangeInfo { range, info: refs } = find_all_refs(sema, position)?; |
286 | let ref_edits = refs | 287 | let ref_edits = refs.references().iter().map(|(&file_id, references)| { |
287 | .references() | 288 | source_edit_from_references(sema, file_id, references, new_name) |
288 | .iter() | 289 | }); |
289 | .map(|reference| source_edit_from_references(sema, reference, new_name)); | ||
290 | source_file_edits.extend(ref_edits); | 290 | source_file_edits.extend(ref_edits); |
291 | 291 | ||
292 | Ok(RangeInfo::new(range, SourceChange::from_edits(source_file_edits, file_system_edits))) | 292 | Ok(RangeInfo::new(range, SourceChange::from_edits(source_file_edits, file_system_edits))) |
@@ -341,7 +341,9 @@ fn rename_to_self( | |||
341 | let mut edits = refs | 341 | let mut edits = refs |
342 | .references() | 342 | .references() |
343 | .iter() | 343 | .iter() |
344 | .map(|reference| source_edit_from_references(sema, reference, "self")) | 344 | .map(|(&file_id, references)| { |
345 | source_edit_from_references(sema, file_id, references, "self") | ||
346 | }) | ||
345 | .collect::<Vec<_>>(); | 347 | .collect::<Vec<_>>(); |
346 | 348 | ||
347 | edits.push(SourceFileEdit { | 349 | edits.push(SourceFileEdit { |
@@ -467,7 +469,9 @@ fn rename_reference( | |||
467 | 469 | ||
468 | let edit = refs | 470 | let edit = refs |
469 | .into_iter() | 471 | .into_iter() |
470 | .map(|reference| source_edit_from_references(sema, &reference, new_name)) | 472 | .map(|(file_id, references)| { |
473 | source_edit_from_references(sema, file_id, &references, new_name) | ||
474 | }) | ||
471 | .collect::<Vec<_>>(); | 475 | .collect::<Vec<_>>(); |
472 | 476 | ||
473 | Ok(RangeInfo::new(range, SourceChange::from(edit))) | 477 | Ok(RangeInfo::new(range, SourceChange::from(edit))) |