MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / strip_generic_and_qualifier

Function strip_generic_and_qualifier

codegraph-kernel/src/swift.rs:1577–1596  ·  view source on GitHub ↗

The shared decorator-name normalization: strip `<...` from the first `<` (index > 0), keep the segment after the last `.`/`::`, strip ONE leading `:` or `.`, trim.

(raw: &str)

Source from the content-addressed store, hash-verified

1575/// (index > 0), keep the segment after the last `.`/`::`, strip ONE leading
1576/// `:` or `.`, trim.
1577fn strip_generic_and_qualifier(raw: &str) -> String {
1578 let mut name = raw.to_string();
1579 if let Some(lt) = name.find('<') {
1580 if lt > 0 {
1581 name.truncate(lt);
1582 }
1583 }
1584 let last_dot = name
1585 .rfind('.')
1586 .map(|i| i as isize)
1587 .unwrap_or(-1)
1588 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
1589 if last_dot >= 0 {
1590 name = name[(last_dot as usize + 1)..].to_string();
1591 if name.starts_with(':') || name.starts_with('.') {
1592 name.remove(0);
1593 }
1594 }
1595 name.trim().to_string()
1596}
1597
1598fn opt_str(arena: &mut Arena, s: Option<&str>) -> StrRef {
1599 match s {

Callers 1

consider_decoratorMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected