diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-23 22:16:50 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-04-23 22:16:50 +0100 |
commit | a71d0ecd774008bbfe8cb2215ffa6dedd5024877 (patch) | |
tree | a14b7ac27dad547fd5832d29a785f01cbba2da91 /crates/ra_lsp_server/src/main_loop | |
parent | a094d5c621e44ff78dce953c0cae7cfba4b2840e (diff) | |
parent | 9d25e5dea4a24272bd891c68e02309cc69792a07 (diff) |
Merge #1201
1201: Goto Type Definition for ADTs r=matklad a=kjeremy
Very basic go to type definition
Co-authored-by: kjeremy <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 530081494..23802e5e1 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -288,6 +288,26 @@ pub fn handle_goto_implementation( | |||
288 | Ok(Some(req::GotoDefinitionResponse::Link(res))) | 288 | Ok(Some(req::GotoDefinitionResponse::Link(res))) |
289 | } | 289 | } |
290 | 290 | ||
291 | pub fn handle_goto_type_definition( | ||
292 | world: ServerWorld, | ||
293 | params: req::TextDocumentPositionParams, | ||
294 | ) -> Result<Option<req::GotoTypeDefinitionResponse>> { | ||
295 | let position = params.try_conv_with(&world)?; | ||
296 | let line_index = world.analysis().file_line_index(position.file_id); | ||
297 | let nav_info = match world.analysis().goto_type_definition(position)? { | ||
298 | None => return Ok(None), | ||
299 | Some(it) => it, | ||
300 | }; | ||
301 | let nav_range = nav_info.range; | ||
302 | let res = nav_info | ||
303 | .info | ||
304 | .into_iter() | ||
305 | .map(|nav| RangeInfo::new(nav_range, nav)) | ||
306 | .map(|nav| to_location_link(&nav, &world, &line_index)) | ||
307 | .collect::<Result<Vec<_>>>()?; | ||
308 | Ok(Some(req::GotoDefinitionResponse::Link(res))) | ||
309 | } | ||
310 | |||
291 | pub fn handle_parent_module( | 311 | pub fn handle_parent_module( |
292 | world: ServerWorld, | 312 | world: ServerWorld, |
293 | params: req::TextDocumentPositionParams, | 313 | params: req::TextDocumentPositionParams, |