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 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/req.rs | 2 |
4 files changed, 24 insertions, 3 deletions
diff --git a/crates/ra_lsp_server/src/caps.rs b/crates/ra_lsp_server/src/caps.rs index bca079d65..254624487 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, | 5 | TextDocumentSyncOptions, ImplementationProviderCapability, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | pub fn server_capabilities() -> ServerCapabilities { | 8 | pub fn server_capabilities() -> ServerCapabilities { |
@@ -26,7 +26,7 @@ pub fn server_capabilities() -> ServerCapabilities { | |||
26 | }), | 26 | }), |
27 | definition_provider: Some(true), | 27 | definition_provider: Some(true), |
28 | type_definition_provider: None, | 28 | type_definition_provider: None, |
29 | implementation_provider: None, | 29 | implementation_provider: Some(ImplementationProviderCapability::Simple(true)), |
30 | references_provider: Some(true), | 30 | references_provider: Some(true), |
31 | document_highlight_provider: Some(true), | 31 | document_highlight_provider: Some(true), |
32 | document_symbol_provider: Some(true), | 32 | document_symbol_provider: Some(true), |
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index e430ac6de..df390c19e 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -305,6 +305,7 @@ fn on_request( | |||
305 | .on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)? | 305 | .on::<req::DocumentSymbolRequest>(handlers::handle_document_symbol)? |
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::ParentModule>(handlers::handle_parent_module)? | 309 | .on::<req::ParentModule>(handlers::handle_parent_module)? |
309 | .on::<req::Runnables>(handlers::handle_runnables)? | 310 | .on::<req::Runnables>(handlers::handle_runnables)? |
310 | .on::<req::DecorationsRequest>(handlers::handle_decorations)? | 311 | .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 4f75f9a22..74554f15c 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -229,6 +229,26 @@ pub fn handle_goto_definition( | |||
229 | Ok(Some(req::GotoDefinitionResponse::Link(res))) | 229 | Ok(Some(req::GotoDefinitionResponse::Link(res))) |
230 | } | 230 | } |
231 | 231 | ||
232 | pub fn handle_goto_implementation( | ||
233 | world: ServerWorld, | ||
234 | params: req::TextDocumentPositionParams, | ||
235 | ) -> Result<Option<req::GotoImplementationResponse>> { | ||
236 | let position = params.try_conv_with(&world)?; | ||
237 | let line_index = world.analysis().file_line_index(position.file_id); | ||
238 | let nav_info = match world.analysis().goto_implementation(position)? { | ||
239 | None => return Ok(None), | ||
240 | Some(it) => it, | ||
241 | }; | ||
242 | let nav_range = nav_info.range; | ||
243 | let res = nav_info | ||
244 | .info | ||
245 | .into_iter() | ||
246 | .map(|nav| RangeInfo::new(nav_range, nav)) | ||
247 | .map(|nav| to_location_link(&nav, &world, &line_index)) | ||
248 | .collect::<Result<Vec<_>>>()?; | ||
249 | Ok(Some(req::GotoDefinitionResponse::Link(res))) | ||
250 | } | ||
251 | |||
232 | pub fn handle_parent_module( | 252 | pub fn handle_parent_module( |
233 | world: ServerWorld, | 253 | world: ServerWorld, |
234 | params: req::TextDocumentPositionParams, | 254 | params: req::TextDocumentPositionParams, |
diff --git a/crates/ra_lsp_server/src/req.rs b/crates/ra_lsp_server/src/req.rs index a4d890755..e224ede80 100644 --- a/crates/ra_lsp_server/src/req.rs +++ b/crates/ra_lsp_server/src/req.rs | |||
@@ -8,7 +8,7 @@ pub use lsp_types::{ | |||
8 | CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, DocumentSymbolParams, | 8 | CompletionParams, CompletionResponse, DocumentOnTypeFormattingParams, DocumentSymbolParams, |
9 | DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult, | 9 | DocumentSymbolResponse, ExecuteCommandParams, Hover, InitializeResult, |
10 | PublishDiagnosticsParams, ReferenceParams, SignatureHelp, TextDocumentEdit, | 10 | PublishDiagnosticsParams, ReferenceParams, SignatureHelp, TextDocumentEdit, |
11 | TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams, | 11 | TextDocumentPositionParams, TextEdit, WorkspaceEdit, WorkspaceSymbolParams |
12 | }; | 12 | }; |
13 | 13 | ||
14 | pub enum AnalyzerStatus {} | 14 | pub enum AnalyzerStatus {} |