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

Function strip_generic_and_qualifier

codegraph-kernel/src/swift.rs:1633–1652  ·  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

1631/// (index > 0), keep the segment after the last `.`/`::`, strip ONE leading
1632/// `:` or `.`, trim.
1633fn strip_generic_and_qualifier(raw: &str) -> String {
1634 let mut name = raw.to_string();
1635 if let Some(lt) = name.find('<') {
1636 if lt > 0 {
1637 name.truncate(lt);
1638 }
1639 }
1640 let last_dot = name
1641 .rfind('.')
1642 .map(|i| i as isize)
1643 .unwrap_or(-1)
1644 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
1645 if last_dot >= 0 {
1646 name = name[(last_dot as usize + 1)..].to_string();
1647 if name.starts_with(':') || name.starts_with('.') {
1648 name.remove(0);
1649 }
1650 }
1651 name.trim().to_string()
1652}
1653
1654fn opt_str(arena: &mut Arena, s: Option<&str>) -> StrRef {
1655 match s {

Callers 1

consider_decoratorMethod · 0.70

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected