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

Function extract_rust

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

Source from the content-addressed store, hash-verified

484});
485
486fn extract_rust(content: &str) -> Vec<SymbolMatch> {
487 let mut rows = Vec::new();
488 for caps in RE_RUST.captures_iter(content) {
489 let full_match = caps.get(0).unwrap();
490 let line_start = line_number_at(content, full_match.start());
491 let signature = line_text(content, line_start).trim().to_string();
492
493 let visibility = if caps.get(1).is_some() {
494 if caps.get(2).is_some() {
495 "pub(crate)".to_string()
496 } else {
497 "pub".to_string()
498 }
499 } else {
500 "private".to_string()
501 };
502
503 let kind = caps.get(4).map(|m| m.as_str()).unwrap_or("unknown");
504 if kind == "impl" {
505 continue;
506 }
507 let kind_str = if kind == "macro_rules!" { "macro" } else { kind };
508 let name = caps.get(5).map(|m| m.as_str()).unwrap_or("");
509
510 rows.push(SymbolMatch {
511 name: name.to_string(),
512 kind: kind_str.to_string(),
513 line_start,
514 line_end: line_start,
515 signature,
516 visibility: visibility.to_string(),
517 });
518 }
519 rows
520}
521
522static RE_TS_JS: LazyLock<Regex> = LazyLock::new(|| {
523 Regex::new(

Callers 1

extract_symbolsFunction · 0.85

Calls 2

line_number_atFunction · 0.85
line_textFunction · 0.85

Tested by

no test coverage detected