aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/main_loop/handlers.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs')
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs34
1 files changed, 24 insertions, 10 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index a5b6f48af..a592f0a12 100644
--- a/crates/ra_lsp_server/src/main_loop/handlers.rs
+++ b/crates/ra_lsp_server/src/main_loop/handlers.rs
@@ -536,18 +536,32 @@ pub fn handle_references(
536 536
537 let locations = if params.context.include_declaration { 537 let locations = if params.context.include_declaration {
538 refs.into_iter() 538 refs.into_iter()
539 .filter_map(|r| { 539 .filter_map(|reference| {
540 let line_index = world.analysis().file_line_index(r.file_range.file_id).ok()?; 540 let line_index =
541 to_location(r.file_range.file_id, r.file_range.range, &world, &line_index).ok() 541 world.analysis().file_line_index(reference.file_range.file_id).ok()?;
542 to_location(
543 reference.file_range.file_id,
544 reference.file_range.range,
545 &world,
546 &line_index,
547 )
548 .ok()
542 }) 549 })
543 .collect() 550 .collect()
544 } else { 551 } else {
545 // Only iterate over the references if include_declaration was false 552 // Only iterate over the references if include_declaration was false
546 refs.references() 553 refs.references()
547 .iter() 554 .iter()
548 .filter_map(|r| { 555 .filter_map(|reference| {
549 let line_index = world.analysis().file_line_index(r.file_range.file_id).ok()?; 556 let line_index =
550 to_location(r.file_range.file_id, r.file_range.range, &world, &line_index).ok() 557 world.analysis().file_line_index(reference.file_range.file_id).ok()?;
558 to_location(
559 reference.file_range.file_id,
560 reference.file_range.range,
561 &world,
562 &line_index,
563 )
564 .ok()
551 }) 565 })
552 .collect() 566 .collect()
553 }; 567 };
@@ -836,10 +850,10 @@ pub fn handle_document_highlight(
836 850
837 Ok(Some( 851 Ok(Some(
838 refs.into_iter() 852 refs.into_iter()
839 .filter(|r| r.file_range.file_id == file_id) 853 .filter(|reference| reference.file_range.file_id == file_id)
840 .map(|r| DocumentHighlight { 854 .map(|reference| DocumentHighlight {
841 range: r.file_range.range.conv_with(&line_index), 855 range: reference.file_range.range.conv_with(&line_index),
842 kind: None, 856 kind: reference.access.map(|it| it.conv()),
843 }) 857 })
844 .collect(), 858 .collect(),
845 )) 859 ))