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

Function strip_generic_and_qualifier

codegraph-kernel/src/java.rs:1737–1756  ·  view source on GitHub ↗

The `new ns.Foo ()` name normalization shared by instantiation / anonymous-class / decorator extraction: 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

1735/// (index > 0), keep the segment after the last `.`/`::`, strip ONE leading
1736/// `:` or `.`, trim.
1737fn strip_generic_and_qualifier(raw: &str) -> String {
1738 let mut name = raw.to_string();
1739 if let Some(lt) = name.find('<') {
1740 if lt > 0 {
1741 name.truncate(lt);
1742 }
1743 }
1744 let last_dot = name
1745 .rfind('.')
1746 .map(|i| i as isize)
1747 .unwrap_or(-1)
1748 .max(name.rfind("::").map(|i| i as isize).unwrap_or(-1));
1749 if last_dot >= 0 {
1750 name = name[(last_dot as usize + 1)..].to_string();
1751 if name.starts_with(':') || name.starts_with('.') {
1752 name.remove(0);
1753 }
1754 }
1755 name.trim().to_string()
1756}
1757
1758fn capitalize(name: &str) -> String {
1759 let mut chars = name.chars();

Callers 3

extract_instantiationMethod · 0.70
consider_decoratorMethod · 0.70

Calls 1

mapMethod · 0.80

Tested by

no test coverage detected