(
&self,
path: &Path,
line: u32,
character: u32,
)
| 576 | } |
| 577 | |
| 578 | pub async fn goto_implementation( |
| 579 | &self, |
| 580 | path: &Path, |
| 581 | line: u32, |
| 582 | character: u32, |
| 583 | ) -> Result<Vec<lsp_types::Location>, LspError> { |
| 584 | let uri = path_to_uri(path)?; |
| 585 | |
| 586 | let params = lsp_types::request::GotoImplementationParams { |
| 587 | text_document_position_params: lsp_types::TextDocumentPositionParams { |
| 588 | text_document: TextDocumentIdentifier { uri }, |
| 589 | position: lsp_types::Position { line, character }, |
| 590 | }, |
| 591 | work_done_progress_params: Default::default(), |
| 592 | partial_result_params: Default::default(), |
| 593 | }; |
| 594 | |
| 595 | let result = self |
| 596 | .request("textDocument/implementation", serde_json::to_value(params)?) |
| 597 | .await?; |
| 598 | |
| 599 | if result.is_null() { |
| 600 | return Ok(vec![]); |
| 601 | } |
| 602 | |
| 603 | let response: lsp_types::GotoDefinitionResponse = serde_json::from_value(result)?; |
| 604 | Ok(match response { |
| 605 | lsp_types::GotoDefinitionResponse::Scalar(loc) => vec![loc], |
| 606 | lsp_types::GotoDefinitionResponse::Array(locs) => locs, |
| 607 | lsp_types::GotoDefinitionResponse::Link(links) => links |
| 608 | .into_iter() |
| 609 | .map(|l| lsp_types::Location { |
| 610 | uri: l.target_uri, |
| 611 | range: l.target_selection_range, |
| 612 | }) |
| 613 | .collect(), |
| 614 | }) |
| 615 | } |
| 616 | |
| 617 | pub async fn type_definition( |
| 618 | &self, |
no test coverage detected