From 3746689e9ddea455d10a41d9fc3af33b22a3707d Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Thu, 18 Oct 2018 13:40:12 -0400 Subject: Implement Find All References for local variables --- crates/ra_lsp_server/src/main_loop/handlers.rs | 16 ++++++++++++++++ crates/ra_lsp_server/src/main_loop/mod.rs | 1 + 2 files changed, 17 insertions(+) (limited to 'crates/ra_lsp_server/src/main_loop') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index c25b63852..9b8d40eaa 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -460,6 +460,22 @@ pub fn handle_signature_help( } } +pub fn handle_references( + world: ServerWorld, + params: req::ReferenceParams, + token: JobToken, +) -> Result>> { + let file_id = params.text_document.try_conv_with(&world)?; + let line_index = world.analysis().file_line_index(file_id); + let offset = params.position.conv_with(&line_index); + + let refs = world.analysis().find_all_refs(file_id, offset, &token); + + Ok(Some(refs.into_iter() + .filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok()) + .collect())) +} + pub fn handle_code_action( world: ServerWorld, params: req::CodeActionParams, diff --git a/crates/ra_lsp_server/src/main_loop/mod.rs b/crates/ra_lsp_server/src/main_loop/mod.rs index a11baf4aa..7efec8a7a 100644 --- a/crates/ra_lsp_server/src/main_loop/mod.rs +++ b/crates/ra_lsp_server/src/main_loop/mod.rs @@ -248,6 +248,7 @@ fn on_request( .on::(handlers::handle_code_action)? .on::(handlers::handle_folding_range)? .on::(handlers::handle_signature_help)? + .on::(handlers::handle_references)? .finish(); match req { Ok((id, handle)) => { -- cgit v1.2.3