(content: &str)
| 555 | LazyLock::new(|| Regex::new(r"(?m)^[[:space:]]*(class|def)\s+(\w+)").expect("Python regex")); |
| 556 | |
| 557 | fn extract_python(content: &str) -> Vec<SymbolMatch> { |
| 558 | let mut rows = Vec::new(); |
| 559 | for caps in RE_PYTHON.captures_iter(content) { |
| 560 | let full_match = caps.get(0).unwrap(); |
| 561 | let line_start = line_number_at(content, full_match.start()); |
| 562 | let signature = line_text(content, line_start).trim().to_string(); |
| 563 | let kind = caps.get(1).map(|m| m.as_str()).unwrap_or("unknown"); |
| 564 | let name = caps.get(2).map(|m| m.as_str()).unwrap_or(""); |
| 565 | rows.push(SymbolMatch { |
| 566 | name: name.to_string(), |
| 567 | kind: kind.to_string(), |
| 568 | line_start, |
| 569 | line_end: line_start, |
| 570 | signature, |
| 571 | visibility: String::new(), |
| 572 | }); |
| 573 | } |
| 574 | rows |
| 575 | } |
| 576 | |
| 577 | static RE_GO: LazyLock<Regex> = |
| 578 | LazyLock::new(|| Regex::new(r"(?m)^func\s+(\([^)]*\)\s+)?(\w+)").expect("Go regex")); |
no test coverage detected