MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / document_symbol

Method document_symbol

crates/opencode-lsp/src/lib.rs:526–554  ·  view source on GitHub ↗
(
        &self,
        path: &Path,
    )

Source from the content-addressed store, hash-verified

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,

Callers 3

handle_debug_commandFunction · 0.80
execute_with_lspFunction · 0.80

Calls 3

path_to_uriFunction · 0.85
flatten_document_symbolFunction · 0.85
requestMethod · 0.80

Tested by

no test coverage detected