aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-30 20:43:58 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-30 20:43:58 +0000
commitacc61cc28461b72e8a03869b0ad60c144b4b3b20 (patch)
tree72d9523c52aca48aac9dd8c5524bb044f547002b /crates/ra_lsp_server/src
parentf9b58454a43274d3b1d4d0e74cdef597b75f9a97 (diff)
parent872950bc188ba104ecd1f532427dea6dc52533bd (diff)
Merge #375
375: Move renames into ra_analysis and rename the correct range r=DJMcNab a=DJMcNab Fixes #230. Supersedes #235. TODO: add some tests for this Co-authored-by: DJMcNab <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs21
1 files changed, 8 insertions, 13 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index a2c12a4c1..3b7a14a5c 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -557,24 +557,19 @@ pub fn handle_rename(world: ServerWorld, params: RenameParams) -> Result<Option<
557 .into()); 557 .into());
558 } 558 }
559 559
560 let refs = world 560 let renames = world
561 .analysis() 561 .analysis()
562 .find_all_refs(FilePosition { file_id, offset })?; 562 .rename(FilePosition { file_id, offset }, &*params.new_name)?;
563 if refs.is_empty() { 563 if renames.is_empty() {
564 return Ok(None); 564 return Ok(None);
565 } 565 }
566 566
567 let mut changes = HashMap::new(); 567 let mut changes = HashMap::new();
568 for r in refs { 568 for edit in renames {
569 if let Ok(loc) = to_location(r.0, r.1, &world, &line_index) { 569 changes
570 changes 570 .entry(file_id.try_conv_with(&world)?)
571 .entry(loc.uri) 571 .or_insert_with(Vec::new)
572 .or_insert_with(Vec::new) 572 .extend(edit.edit.conv_with(&line_index));
573 .push(TextEdit {
574 range: loc.range,
575 new_text: params.new_name.clone(),
576 });
577 }
578 } 573 }
579 574
580 Ok(Some(WorkspaceEdit { 575 Ok(Some(WorkspaceEdit {