aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-10-23 09:20:18 +0100
committerGitHub <[email protected]>2019-10-23 09:20:18 +0100
commit4f4fe14fab96c8b40763f9ed5bef51942fd7e504 (patch)
treecdf5a5b39600b41a9eee301b9760cde1282aeb33 /crates/ra_lsp_server/src
parentc15ee97fff4324981d03f65210d794664c28f0e4 (diff)
parentdecfd28bd14b56befa17257694caacc57a090939 (diff)
Merge #1892
1892: Find usages r=matklad a=viorina Fixes #1622. Co-authored-by: Ekaterina Babshukova <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index af3cd04ea..307082865 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -481,7 +481,6 @@ pub fn handle_references(
481 params: req::ReferenceParams, 481 params: req::ReferenceParams,
482) -> Result<Option<Vec<Location>>> { 482) -> Result<Option<Vec<Location>>> {
483 let position = params.text_document_position.try_conv_with(&world)?; 483 let position = params.text_document_position.try_conv_with(&world)?;
484 let line_index = world.analysis().file_line_index(position.file_id)?;
485 484
486 let refs = match world.analysis().find_all_refs(position)? { 485 let refs = match world.analysis().find_all_refs(position)? {
487 None => return Ok(None), 486 None => return Ok(None),
@@ -490,13 +489,19 @@ pub fn handle_references(
490 489
491 let locations = if params.context.include_declaration { 490 let locations = if params.context.include_declaration {
492 refs.into_iter() 491 refs.into_iter()
493 .filter_map(|r| to_location(r.file_id, r.range, &world, &line_index).ok()) 492 .filter_map(|r| {
493 let line_index = world.analysis().file_line_index(r.file_id).ok()?;
494 to_location(r.file_id, r.range, &world, &line_index).ok()
495 })
494 .collect() 496 .collect()
495 } else { 497 } else {
496 // Only iterate over the references if include_declaration was false 498 // Only iterate over the references if include_declaration was false
497 refs.references() 499 refs.references()
498 .iter() 500 .iter()
499 .filter_map(|r| to_location(r.file_id, r.range, &world, &line_index).ok()) 501 .filter_map(|r| {
502 let line_index = world.analysis().file_line_index(r.file_id).ok()?;
503 to_location(r.file_id, r.range, &world, &line_index).ok()
504 })
500 .collect() 505 .collect()
501 }; 506 };
502 507
@@ -746,6 +751,7 @@ pub fn handle_document_highlight(
746 751
747 Ok(Some( 752 Ok(Some(
748 refs.into_iter() 753 refs.into_iter()
754 .filter(|r| r.file_id == file_id)
749 .map(|r| DocumentHighlight { range: r.range.conv_with(&line_index), kind: None }) 755 .map(|r| DocumentHighlight { range: r.range.conv_with(&line_index), kind: None })
750 .collect(), 756 .collect(),
751 )) 757 ))