MCPcopy Create free account
hub / github.com/douglance/devsql / extract_go

Function extract_go

crates/devsql/src/providers/symbols.rs:580–602  ·  view source on GitHub ↗
(content: &str)

Source from the content-addressed store, hash-verified

578 LazyLock::new(|| Regex::new(r"(?m)^func\s+(\([^)]*\)\s+)?(\w+)").expect("Go regex"));
579
580fn extract_go(content: &str) -> Vec<SymbolMatch> {
581 let mut rows = Vec::new();
582 for caps in RE_GO.captures_iter(content) {
583 let full_match = caps.get(0).unwrap();
584 let line_start = line_number_at(content, full_match.start());
585 let signature = line_text(content, line_start).trim().to_string();
586 let name = caps.get(2).map(|m| m.as_str()).unwrap_or("");
587 let visibility = if name.chars().next().map(|c| c.is_uppercase()).unwrap_or(false) {
588 "export"
589 } else {
590 ""
591 };
592 rows.push(SymbolMatch {
593 name: name.to_string(),
594 kind: "function".to_string(),
595 line_start,
596 line_end: line_start,
597 signature,
598 visibility: visibility.to_string(),
599 });
600 }
601 rows
602}

Callers 1

extract_symbolsFunction · 0.85

Calls 2

line_number_atFunction · 0.85
line_textFunction · 0.85

Tested by

no test coverage detected