diff options
author | Jeremy A. Kolb <[email protected]> | 2018-10-18 18:40:12 +0100 |
---|---|---|
committer | Jeremy A. Kolb <[email protected]> | 2018-10-18 18:40:12 +0100 |
commit | 3746689e9ddea455d10a41d9fc3af33b22a3707d (patch) | |
tree | 04c4e94e40f5496d961ca2f3dc649da1dd84604e /crates/ra_lsp_server/src/main_loop | |
parent | 2a704035f4b36a0db737f59a7c939d17656b516f (diff) |
Implement Find All References for local variables
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 16 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/mod.rs | 1 |
2 files changed, 17 insertions, 0 deletions
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( | |||
460 | } | 460 | } |
461 | } | 461 | } |
462 | 462 | ||
463 | pub fn handle_references( | ||
464 | world: ServerWorld, | ||
465 | params: req::ReferenceParams, | ||
466 | token: JobToken, | ||
467 | ) -> Result<Option<Vec<Location>>> { | ||
468 | let file_id = params.text_document.try_conv_with(&world)?; | ||
469 | let line_index = world.analysis().file_line_index(file_id); | ||
470 | let offset = params.position.conv_with(&line_index); | ||
471 | |||
472 | let refs = world.analysis().find_all_refs(file_id, offset, &token); | ||
473 | |||
474 | Ok(Some(refs.into_iter() | ||
475 | .filter_map(|r| to_location(r.0, r.1, &world, &line_index).ok()) | ||
476 | .collect())) | ||
477 | } | ||
478 | |||
463 | pub fn handle_code_action( | 479 | pub fn handle_code_action( |
464 | world: ServerWorld, | 480 | world: ServerWorld, |
465 | params: req::CodeActionParams, | 481 | 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( | |||
248 | .on::<req::CodeActionRequest>(handlers::handle_code_action)? | 248 | .on::<req::CodeActionRequest>(handlers::handle_code_action)? |
249 | .on::<req::FoldingRangeRequest>(handlers::handle_folding_range)? | 249 | .on::<req::FoldingRangeRequest>(handlers::handle_folding_range)? |
250 | .on::<req::SignatureHelpRequest>(handlers::handle_signature_help)? | 250 | .on::<req::SignatureHelpRequest>(handlers::handle_signature_help)? |
251 | .on::<req::References>(handlers::handle_references)? | ||
251 | .finish(); | 252 | .finish(); |
252 | match req { | 253 | match req { |
253 | Ok((id, handle)) => { | 254 | Ok((id, handle)) => { |