diff options
Diffstat (limited to 'crates/ra_lsp_server')
-rw-r--r-- | crates/ra_lsp_server/src/caps.rs | 4 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 1 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 20 |
3 files changed, 23 insertions, 2 deletions
diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index f6d2b75e7..9095bee89 100644 --- a/crates/ra_lsp_server/src/caps.rs +++ b/crates/ra_lsp_server/src/caps.rs | |||
@@ -2,7 +2,7 @@ use lsp_types::{ | |||
2 | CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions, | 2 | CodeActionProviderCapability, CodeLensOptions, CompletionOptions, DocumentOnTypeFormattingOptions, |
3 | ExecuteCommandOptions, FoldingRangeProviderCapability, RenameOptions, RenameProviderCapability, | 3 | ExecuteCommandOptions, FoldingRangeProviderCapability, RenameOptions, RenameProviderCapability, |
4 | ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, | 4 | ServerCapabilities, SignatureHelpOptions, TextDocumentSyncCapability, TextDocumentSyncKind, |
5 | TextDocumentSyncOptions, ImplementationProviderCapability, GenericCapability, | 5 | TextDocumentSyncOptions, ImplementationProviderCapability, GenericCapability, TypeDefinitionProviderCapability |
6 | }; | 6 | }; |
7 | 7 | ||
8 | pub fn server_capabilities() -> ServerCapabilities { | 8 | pub fn server_capabilities() -> ServerCapabilities { |
@@ -23,7 +23,7 @@ pub fn server_capabilities() -> ServerCapabilities { | |||
23 | trigger_characters: Some(vec!["(".to_string(), ",".to_string(), ")".to_string()]), | 23 | trigger_characters: Some(vec!["(".to_string(), ",".to_string(), ")".to_string()]), |
24 | }), | 24 | }), |
25 | definition_provider: Some(true), | 25 | definition_provider: Some(true), |
26 | type_definition_provider: None, | 26 | type_definition_provider: Some(TypeDefinitionProviderCapability::Simple(true)), |
27 | implementation_provider: Some(ImplementationProviderCapability::Simple(true)), | 27 | implementation_provider: Some(ImplementationProviderCapability::Simple(true)), |
28 | references_provider: Some(true), | 28 | references_provider: Some(true), |
29 | document_highlight_provider: Some(true), | 29 | document_highlight_provider: Some(true), |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index dc1f8f3f7..87b4e3ac2 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -306,6 +306,7 @@ fn on_request( | |||
306 | .on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)? | 306 | .on::<req::WorkspaceSymbol>(handlers::handle_workspace_symbol)? |
307 | .on::<req::GotoDefinition>(handlers::handle_goto_definition)? | 307 | .on::<req::GotoDefinition>(handlers::handle_goto_definition)? |
308 | .on::<req::GotoImplementation>(handlers::handle_goto_implementation)? | 308 | .on::<req::GotoImplementation>(handlers::handle_goto_implementation)? |
309 | .on::<req::GotoTypeDefinition>(handlers::handle_goto_type_definition)? | ||
309 | .on::<req::ParentModule>(handlers::handle_parent_module)? | 310 | .on::<req::ParentModule>(handlers::handle_parent_module)? |
310 | .on::<req::Runnables>(handlers::handle_runnables)? | 311 | .on::<req::Runnables>(handlers::handle_runnables)? |
311 | .on::<req::DecorationsRequest>(handlers::handle_decorations)? | 312 | .on::<req::DecorationsRequest>(handlers::handle_decorations)? |
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, |