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

Function strip_generic_and_qualifier

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

1685/// (index > 0), keep the segment after the last `.`/`::`, strip ONE leading
1686/// `:` or `.`, trim.
1687fn strip_generic_and_qualifier(raw: &str) -> String {
1688 let mut name = raw.to_string();
1689 if let Some(lt) = name.find('<') {
1690 if lt > 0 {
1691 name.truncate(lt);
1692 }
1693 }
1694 let last_dot = name
1695 .rfind('.')
1696 .map(|i| i as isize)
1697 .unwrap_or(-1)
1698 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
1699 if last_dot >= 0 {
1700 name = name[(last_dot as usize + 1)..].to_string();
1701 if name.starts_with(':') || name.starts_with('.') {
1702 name.remove(0);
1703 }
1704 }
1705 name.trim().to_string()
1706}
1707
1708fn opt_str(arena: &mut Arena, s: Option<&str>) -> StrRef {
1709 match s {

Callers 1

consider_decoratorMethod · 0.70

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected