(
&self,
path: &Path,
line: u32,
character: u32,
)
| 393 | } |
| 394 | |
| 395 | pub async fn goto_definition( |
| 396 | &self, |
| 397 | path: &Path, |
| 398 | line: u32, |
| 399 | character: u32, |
| 400 | ) -> Result<Option<lsp_types::Location>, LspError> { |
| 401 | let uri = path_to_uri(path)?; |
| 402 | |
| 403 | let params = lsp_types::GotoDefinitionParams { |
| 404 | text_document_position_params: lsp_types::TextDocumentPositionParams { |
| 405 | text_document: TextDocumentIdentifier { uri }, |
| 406 | position: lsp_types::Position { line, character }, |
| 407 | }, |
| 408 | work_done_progress_params: Default::default(), |
| 409 | partial_result_params: Default::default(), |
| 410 | }; |
| 411 | |
| 412 | let result = self |
| 413 | .request("textDocument/definition", serde_json::to_value(params)?) |
| 414 | .await?; |
| 415 | |
| 416 | if result.is_null() { |
| 417 | return Ok(None); |
| 418 | } |
| 419 | |
| 420 | let response: lsp_types::GotoDefinitionResponse = serde_json::from_value(result)?; |
| 421 | match response { |
| 422 | lsp_types::GotoDefinitionResponse::Scalar(loc) => Ok(Some(loc)), |
| 423 | lsp_types::GotoDefinitionResponse::Array(locs) => Ok(locs.into_iter().next()), |
| 424 | lsp_types::GotoDefinitionResponse::Link(links) => { |
| 425 | Ok(links.into_iter().next().map(|l| lsp_types::Location { |
| 426 | uri: l.target_uri, |
| 427 | range: l.target_selection_range, |
| 428 | })) |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | pub async fn completion( |
| 434 | &self, |
no test coverage detected