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

Function strip_generic_and_qualifier

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

1590/// (index > 0), keep the segment after the last `.`/`::`, strip ONE leading
1591/// `:` or `.`, trim.
1592fn strip_generic_and_qualifier(raw: &str) -> String {
1593 let mut name = raw.to_string();
1594 if let Some(lt) = name.find('<') {
1595 if lt > 0 {
1596 name.truncate(lt);
1597 }
1598 }
1599 let last_dot = name
1600 .rfind('.')
1601 .map(|i| i as isize)
1602 .unwrap_or(-1)
1603 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
1604 if last_dot >= 0 {
1605 name = name[(last_dot as usize + 1)..].to_string();
1606 if name.starts_with(':') || name.starts_with('.') {
1607 name.remove(0);
1608 }
1609 }
1610 name.trim().to_string()
1611}
1612
1613fn opt_str(arena: &mut Arena, s: Option<&str>) -> StrRef {
1614 match s {

Callers 1

consider_decoratorMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected