aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index eb805a6d3..948d543ea 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -460,18 +460,16 @@ pub fn handle_prepare_rename(
460 460
461 // We support renaming references like handle_rename does. 461 // We support renaming references like handle_rename does.
462 // In the future we may want to reject the renaming of things like keywords here too. 462 // In the future we may want to reject the renaming of things like keywords here too.
463 let refs = match world.analysis().find_all_refs(position)? { 463 let optional_change = world.analysis().rename(position, "dummy")?;
464 let range = match optional_change {
464 None => return Ok(None), 465 None => return Ok(None),
465 Some(refs) => refs, 466 Some(it) => it.range,
466 }; 467 };
467 468
468 // Refs should always have a declaration
469 let r = refs.declaration();
470 let file_id = params.text_document.try_conv_with(&world)?; 469 let file_id = params.text_document.try_conv_with(&world)?;
471 let line_index = world.analysis().file_line_index(file_id)?; 470 let line_index = world.analysis().file_line_index(file_id)?;
472 let loc = to_location(r.file_id(), r.range(), &world, &line_index)?; 471 let range = range.conv_with(&line_index);
473 472 Ok(Some(PrepareRenameResponse::Range(range)))
474 Ok(Some(PrepareRenameResponse::Range(loc.range)))
475} 473}
476 474
477pub fn handle_rename(world: WorldSnapshot, params: RenameParams) -> Result<Option<WorkspaceEdit>> { 475pub fn handle_rename(world: WorldSnapshot, params: RenameParams) -> Result<Option<WorkspaceEdit>> {
@@ -488,7 +486,7 @@ pub fn handle_rename(world: WorldSnapshot, params: RenameParams) -> Result<Optio
488 let optional_change = world.analysis().rename(position, &*params.new_name)?; 486 let optional_change = world.analysis().rename(position, &*params.new_name)?;
489 let change = match optional_change { 487 let change = match optional_change {
490 None => return Ok(None), 488 None => return Ok(None),
491 Some(it) => it, 489 Some(it) => it.info,
492 }; 490 };
493 491
494 let source_change_req = change.try_conv_with(&world)?; 492 let source_change_req = change.try_conv_with(&world)?;