From 33965f0f3ee236ab57c1389d5693511915ab4554 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 5 Sep 2019 21:36:40 +0300 Subject: fix renaming of modules --- crates/ra_lsp_server/src/main_loop/handlers.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'crates/ra_lsp_server') 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( // We support renaming references like handle_rename does. // In the future we may want to reject the renaming of things like keywords here too. - let refs = match world.analysis().find_all_refs(position)? { + let optional_change = world.analysis().rename(position, "dummy")?; + let range = match optional_change { None => return Ok(None), - Some(refs) => refs, + Some(it) => it.range, }; - // Refs should always have a declaration - let r = refs.declaration(); let file_id = params.text_document.try_conv_with(&world)?; let line_index = world.analysis().file_line_index(file_id)?; - let loc = to_location(r.file_id(), r.range(), &world, &line_index)?; - - Ok(Some(PrepareRenameResponse::Range(loc.range))) + let range = range.conv_with(&line_index); + Ok(Some(PrepareRenameResponse::Range(range))) } pub fn handle_rename(world: WorldSnapshot, params: RenameParams) -> Result> { @@ -488,7 +486,7 @@ pub fn handle_rename(world: WorldSnapshot, params: RenameParams) -> Result return Ok(None), - Some(it) => it, + Some(it) => it.info, }; let source_change_req = change.try_conv_with(&world)?; -- cgit v1.2.3