From 79e6b3b0d17b9389ccdc422ae42beb38163c6610 Mon Sep 17 00:00:00 2001 From: Ekaterina Babshukova Date: Sat, 12 Oct 2019 13:39:02 +0300 Subject: make `handle_references` accept refs from other files --- crates/ra_lsp_server/src/main_loop/handlers.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index af3cd04ea..a07aaa9b5 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -481,8 +481,7 @@ pub fn handle_references( params: req::ReferenceParams, ) -> Result>> { let position = params.text_document_position.try_conv_with(&world)?; - let line_index = world.analysis().file_line_index(position.file_id)?; - + let refs = match world.analysis().find_all_refs(position)? { None => return Ok(None), Some(refs) => refs, @@ -490,13 +489,19 @@ pub fn handle_references( let locations = if params.context.include_declaration { refs.into_iter() - .filter_map(|r| to_location(r.file_id, r.range, &world, &line_index).ok()) + .filter_map(|r| { + let line_index = world.analysis().file_line_index(r.file_id).ok()?; + to_location(r.file_id, r.range, &world, &line_index).ok() + }) .collect() } else { // Only iterate over the references if include_declaration was false refs.references() .iter() - .filter_map(|r| to_location(r.file_id, r.range, &world, &line_index).ok()) + .filter_map(|r| { + let line_index = world.analysis().file_line_index(r.file_id).ok()?; + to_location(r.file_id, r.range, &world, &line_index).ok() + }) .collect() }; -- cgit v1.2.3 From d26d0ada50fd0063c03e28bc2673f9f63fd23d95 Mon Sep 17 00:00:00 2001 From: Ekaterina Babshukova Date: Sat, 12 Oct 2019 18:47:17 +0300 Subject: restructure a bit --- crates/ra_lsp_server/src/main_loop/handlers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index a07aaa9b5..e08e0dbae 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -481,7 +481,7 @@ pub fn handle_references( params: req::ReferenceParams, ) -> Result>> { let position = params.text_document_position.try_conv_with(&world)?; - + let refs = match world.analysis().find_all_refs(position)? { None => return Ok(None), Some(refs) => refs, -- cgit v1.2.3 From 93c179531b31786bfd50644b5f0c879afc798f7d Mon Sep 17 00:00:00 2001 From: Ekaterina Babshukova Date: Tue, 15 Oct 2019 19:25:57 +0300 Subject: fix highlighting --- crates/ra_lsp_server/src/main_loop/handlers.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index e08e0dbae..307082865 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -751,6 +751,7 @@ pub fn handle_document_highlight( Ok(Some( refs.into_iter() + .filter(|r| r.file_id == file_id) .map(|r| DocumentHighlight { range: r.range.conv_with(&line_index), kind: None }) .collect(), )) -- cgit v1.2.3