(content: &str)
| 527 | }); |
| 528 | |
| 529 | fn extract_ts_js(content: &str) -> Vec<SymbolMatch> { |
| 530 | let mut rows = Vec::new(); |
| 531 | for caps in RE_TS_JS.captures_iter(content) { |
| 532 | let full_match = caps.get(0).unwrap(); |
| 533 | let line_start = line_number_at(content, full_match.start()); |
| 534 | let signature = line_text(content, line_start).trim().to_string(); |
| 535 | let visibility = if caps.get(1).is_some() { |
| 536 | "export".to_string() |
| 537 | } else { |
| 538 | String::new() |
| 539 | }; |
| 540 | let kind = caps.get(4).map(|m| m.as_str()).unwrap_or("unknown"); |
| 541 | let name = caps.get(5).map(|m| m.as_str()).unwrap_or(""); |
| 542 | rows.push(SymbolMatch { |
| 543 | name: name.to_string(), |
| 544 | kind: kind.to_string(), |
| 545 | line_start, |
| 546 | line_end: line_start, |
| 547 | signature, |
| 548 | visibility, |
| 549 | }); |
| 550 | } |
| 551 | rows |
| 552 | } |
| 553 | |
| 554 | static RE_PYTHON: LazyLock<Regex> = |
| 555 | LazyLock::new(|| Regex::new(r"(?m)^[[:space:]]*(class|def)\s+(\w+)").expect("Python regex")); |
no test coverage detected