diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop/handlers.rs | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/crates/ra_lsp_server/src/main_loop/handlers.rs b/crates/ra_lsp_server/src/main_loop/handlers.rs index ace3da020..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, |
@@ -581,7 +598,7 @@ pub fn handle_code_action( | |||
581 | let edit = source_edit.try_conv_with(&world)?; | 598 | let edit = source_edit.try_conv_with(&world)?; |
582 | let cmd = Command { | 599 | let cmd = Command { |
583 | title, | 600 | title, |
584 | command: "ra-lsp.applySourceChange".to_string(), | 601 | command: "rust-analyzer.applySourceChange".to_string(), |
585 | arguments: Some(vec![to_value(edit).unwrap()]), | 602 | arguments: Some(vec![to_value(edit).unwrap()]), |
586 | }; | 603 | }; |
587 | res.push(cmd); | 604 | res.push(cmd); |
@@ -623,7 +640,7 @@ pub fn handle_code_lens( | |||
623 | range, | 640 | range, |
624 | command: Some(Command { | 641 | command: Some(Command { |
625 | title: title.into(), | 642 | title: title.into(), |
626 | command: "ra-lsp.run-single".into(), | 643 | command: "rust-analyzer.runSingle".into(), |
627 | arguments: Some(vec![to_value(r).unwrap()]), | 644 | arguments: Some(vec![to_value(r).unwrap()]), |
628 | }), | 645 | }), |
629 | data: None, | 646 | data: None, |