(
&self,
path: &Path,
)
| 524 | } |
| 525 | |
| 526 | pub async fn document_symbol( |
| 527 | &self, |
| 528 | path: &Path, |
| 529 | ) -> Result<Vec<lsp_types::SymbolInformation>, LspError> { |
| 530 | let uri = path_to_uri(path)?; |
| 531 | |
| 532 | let params = lsp_types::DocumentSymbolParams { |
| 533 | text_document: TextDocumentIdentifier { uri }, |
| 534 | work_done_progress_params: Default::default(), |
| 535 | partial_result_params: Default::default(), |
| 536 | }; |
| 537 | |
| 538 | let result = self |
| 539 | .request("textDocument/documentSymbol", serde_json::to_value(params)?) |
| 540 | .await?; |
| 541 | |
| 542 | if result.is_null() { |
| 543 | return Ok(vec![]); |
| 544 | } |
| 545 | |
| 546 | let symbols: lsp_types::DocumentSymbolResponse = serde_json::from_value(result)?; |
| 547 | Ok(match symbols { |
| 548 | lsp_types::DocumentSymbolResponse::Flat(symbols) => symbols, |
| 549 | lsp_types::DocumentSymbolResponse::Nested(nested) => nested |
| 550 | .into_iter() |
| 551 | .flat_map(|s| flatten_document_symbol(&s)) |
| 552 | .collect(), |
| 553 | }) |
| 554 | } |
| 555 | |
| 556 | pub async fn workspace_symbol( |
| 557 | &self, |
no test coverage detected