diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index 9478ebfb8..74554f15c 100644 --- a/crates/ra_lsp_server/src/main_loop/handlers.rs +++ b/crates/ra_lsp_server/src/main_loop/handlers.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use gen_lsp_server::ErrorCode; | 1 | use gen_lsp_server::ErrorCode; |
2 | use lsp_types::{ | 2 | use lsp_types::{ |
3 | CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, | 3 | CodeActionResponse, CodeLens, Command, Diagnostic, DiagnosticSeverity, |
4 | DocumentFormattingParams, DocumentHighlight, DocumentSymbol, Documentation, FoldingRange, | 4 | DocumentFormattingParams, DocumentHighlight, DocumentSymbol, FoldingRange, |
5 | FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, | 5 | FoldingRangeKind, FoldingRangeParams, Hover, HoverContents, Location, MarkupContent, |
6 | MarkupKind, ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range, | 6 | MarkupKind, ParameterInformation, ParameterLabel, Position, PrepareRenameResponse, Range, |
7 | RenameParams, SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, | 7 | RenameParams, SignatureInformation, SymbolInformation, TextDocumentIdentifier, TextEdit, |
@@ -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, |
@@ -401,12 +421,9 @@ pub fn handle_signature_help( | |||
401 | documentation: None, | 421 | documentation: None, |
402 | }) | 422 | }) |
403 | .collect(); | 423 | .collect(); |
404 | let documentation = call_info.doc.map(|value| { | 424 | |
405 | Documentation::MarkupContent(MarkupContent { | 425 | let documentation = call_info.doc.map(|it| it.conv()); |
406 | kind: MarkupKind::Markdown, | 426 | |
407 | value, | ||
408 | }) | ||
409 | }); | ||
410 | let sig_info = SignatureInformation { | 427 | let sig_info = SignatureInformation { |
411 | label: call_info.label, | 428 | label: call_info.label, |
412 | documentation, | 429 | documentation, |