From d993f329a01deb3cdc011c3eb1dfd859302fec04 Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Sat, 4 Jan 2020 17:46:01 -0500 Subject: Basic DocumentHighlightKind support for assignments --- crates/ra_lsp_server/src/main_loop/handlers.rs | 34 ++++++++++++++++++-------- 1 file changed, 24 insertions(+), 10 deletions(-) (limited to 'crates/ra_lsp_server/src/main_loop/handlers.rs') 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( let locations = if params.context.include_declaration { refs.into_iter() - .filter_map(|r| { - let line_index = world.analysis().file_line_index(r.file_range.file_id).ok()?; - to_location(r.file_range.file_id, r.file_range.range, &world, &line_index).ok() + .filter_map(|reference| { + let line_index = + world.analysis().file_line_index(reference.file_range.file_id).ok()?; + to_location( + reference.file_range.file_id, + reference.file_range.range, + &world, + &line_index, + ) + .ok() }) .collect() } else { // Only iterate over the references if include_declaration was false refs.references() .iter() - .filter_map(|r| { - let line_index = world.analysis().file_line_index(r.file_range.file_id).ok()?; - to_location(r.file_range.file_id, r.file_range.range, &world, &line_index).ok() + .filter_map(|reference| { + let line_index = + world.analysis().file_line_index(reference.file_range.file_id).ok()?; + to_location( + reference.file_range.file_id, + reference.file_range.range, + &world, + &line_index, + ) + .ok() }) .collect() }; @@ -836,10 +850,10 @@ pub fn handle_document_highlight( Ok(Some( refs.into_iter() - .filter(|r| r.file_range.file_id == file_id) - .map(|r| DocumentHighlight { - range: r.file_range.range.conv_with(&line_index), - kind: None, + .filter(|reference| reference.file_range.file_id == file_id) + .map(|reference| DocumentHighlight { + range: reference.file_range.range.conv_with(&line_index), + kind: reference.access.map(|it| it.conv()), }) .collect(), )) -- cgit v1.2.3