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

Method lookup_symbol_end_line

crates/opencode-session/src/prompt.rs:560–593  ·  view source on GitHub ↗
(&self, file_path: &Path, start_line: usize)

Source from the content-addressed store, hash-verified

558 }
559
560 async fn lookup_symbol_end_line(&self, file_path: &Path, start_line: usize) -> Option<usize> {
561 let registry = self.lsp_registry.as_ref()?;
562 let clients = registry.list().await;
563 if clients.is_empty() {
564 return None;
565 }
566
567 let content = tokio::fs::read_to_string(file_path).await.ok();
568 for (_, client) in clients {
569 if let Some(content) = content.as_deref() {
570 let language = opencode_lsp::detect_language(file_path);
571 let _ = client.open_document(file_path, content, language).await;
572 }
573
574 let symbols = match client.document_symbol(file_path).await {
575 Ok(symbols) => symbols,
576 Err(_) => continue,
577 };
578
579 for symbol in symbols {
580 let symbol_start = symbol.location.range.start.line as usize + 1;
581 if symbol_start != start_line {
582 continue;
583 }
584
585 let symbol_end = symbol.location.range.end.line as usize + 1;
586 if symbol_end >= start_line {
587 return Some(symbol_end);
588 }
589 }
590 }
591
592 None
593 }
594
595 fn parse_line_window(file_url: &url::Url) -> Option<(usize, Option<usize>)> {
596 let start = file_url.query_pairs().find_map(|(key, value)| {

Callers 1

Calls 5

detect_languageFunction · 0.85
is_emptyMethod · 0.80
open_documentMethod · 0.80
document_symbolMethod · 0.80
listMethod · 0.45

Tested by

no test coverage detected