aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_analysis/src/lib.rs7
-rw-r--r--crates/ra_lsp_server/src/main_loop/handlers.rs5
2 files changed, 9 insertions, 3 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs
index b068119d2..70ee448fc 100644
--- a/crates/ra_analysis/src/lib.rs
+++ b/crates/ra_analysis/src/lib.rs
@@ -392,6 +392,13 @@ impl Analysis {
392 .collect(); 392 .collect();
393 Ok(res) 393 Ok(res)
394 } 394 }
395 pub fn goto_defenition(
396 &self,
397 position: FilePosition,
398 ) -> Cancelable<Option<Vec<NavigationTarget>>> {
399 let r = self.approximately_resolve_symbol(position)?;
400 Ok(r.map(|it| it.resolves_to))
401 }
395 /// Resolves reference to definition, but does not gurantee correctness. 402 /// Resolves reference to definition, but does not gurantee correctness.
396 pub fn approximately_resolve_symbol( 403 pub fn approximately_resolve_symbol(
397 &self, 404 &self,
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs
index ffca3f51c..1baed73ad 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(
207 params: req::TextDocumentPositionParams, 207 params: req::TextDocumentPositionParams,
208) -> Result<Option<req::GotoDefinitionResponse>> { 208) -> Result<Option<req::GotoDefinitionResponse>> {
209 let position = params.try_conv_with(&world)?; 209 let position = params.try_conv_with(&world)?;
210 let rr = match world.analysis().approximately_resolve_symbol(position)? { 210 let navs = match world.analysis().goto_defenition(position)? {
211 None => return Ok(None), 211 None => return Ok(None),
212 Some(it) => it, 212 Some(it) => it,
213 }; 213 };
214 let res = rr 214 let res = navs
215 .resolves_to
216 .into_iter() 215 .into_iter()
217 .map(|nav| nav.try_conv_with(&world)) 216 .map(|nav| nav.try_conv_with(&world))
218 .collect::<Result<Vec<_>>>()?; 217 .collect::<Result<Vec<_>>>()?;