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

Function strip_generic_and_qualifier

codegraph-kernel/src/php.rs:1807–1826  ·  view source on GitHub ↗

The shared `new ns.Foo ()` normalization: strip `<...` from the first `<` (index > 0), keep the segment after the last `.`/`::`, strip ONE leading `:` or `.`, trim. Backslashes are NOT handled — php qualified names pass through whole.

(raw: &str)

Source from the content-addressed store, hash-verified

1805/// leading `:` or `.`, trim. Backslashes are NOT handled — php qualified
1806/// names pass through whole.
1807fn strip_generic_and_qualifier(raw: &str) -> String {
1808 let mut name = raw.to_string();
1809 if let Some(lt) = name.find('<') {
1810 if lt > 0 {
1811 name.truncate(lt);
1812 }
1813 }
1814 let last_dot = name
1815 .rfind('.')
1816 .map(|i| i as isize)
1817 .unwrap_or(-1)
1818 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
1819 if last_dot >= 0 {
1820 name = name[(last_dot as usize + 1)..].to_string();
1821 if name.starts_with(':') || name.starts_with('.') {
1822 name.remove(0);
1823 }
1824 }
1825 name.trim().to_string()
1826}
1827
1828fn opt_str(arena: &mut Arena, s: Option<&str>) -> StrRef {
1829 match s {

Callers 2

extract_instantiationMethod · 0.70

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected