aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop/handlers.rs
diff options
context:
space:
mode:
authorDJMcNab <[email protected]>2018-12-30 18:14:55 +0000
committerDJMcNab <[email protected]>2018-12-30 18:14:55 +0000
commitc402b007a3272efada7924fce4eecf698b98968b (patch)
treeeea606837139333d511468d5127d2c20d806930f /crates/ra_lsp_server/src/main_loop/handlers.rs
parent0f95d8523e0646aac8fb69c61f7b0d7a8efe42bb (diff)
Move renames into ra_analysis
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-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 {