From 4551155073d8e12dd7aa467f6cd90e8705a115b3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 5 Jan 2019 13:23:34 +0300 Subject: [PATCH] introduce separate goto_defenition --- crates/ra_analysis/src/lib.rs | 7 +++++++ crates/ra_lsp_server/src/main_loop/handlers.rs | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index b068119d2b2..70ee448fc7f 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs @@ -392,6 +392,13 @@ impl Analysis { .collect(); Ok(res) } + pub fn goto_defenition( + &self, + position: FilePosition, + ) -> Cancelable>> { + let r = self.approximately_resolve_symbol(position)?; + Ok(r.map(|it| it.resolves_to)) + } /// Resolves reference to definition, but does not gurantee correctness. pub fn approximately_resolve_symbol( &self, diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index ffca3f51cbe..1baed73ade8 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs @@ -207,12 +207,11 @@ pub fn handle_goto_definition( params: req::TextDocumentPositionParams, ) -> Result> { let position = params.try_conv_with(&world)?; - let rr = match world.analysis().approximately_resolve_symbol(position)? { + let navs = match world.analysis().goto_defenition(position)? { None => return Ok(None), Some(it) => it, }; - let res = rr - .resolves_to + let res = navs .into_iter() .map(|nav| nav.try_conv_with(&world)) .collect::>>()?;