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

Function kotlin_receiver_chain

codegraph-kernel/src/kotlin.rs:93–110  ·  view source on GitHub ↗

A receiver chain the resolver can type (TS `KOTLIN_RECEIVER_CHAIN`): whitespace stripped, `?.` read as `.`, then `this` or an identifier followed by one to three `.identifier` segments.

(text: &str)

Source from the content-addressed store, hash-verified

91/// whitespace stripped, `?.` read as `.`, then `this` or an identifier
92/// followed by one to three `.identifier` segments.
93fn kotlin_receiver_chain(text: &str) -> Option<String> {
94 let chain = strip_js_ws(text).replace("?.", ".");
95 let segments: Vec<&str> = chain.split('.').collect();
96 if segments.len() < 2 || segments.len() > 4 {
97 return None;
98 }
99 let ident = |s: &str| {
100 let b = s.as_bytes();
101 !b.is_empty()
102 && (b[0].is_ascii_alphabetic() || b[0] == b'_')
103 && b.iter().all(|c| c.is_ascii_alphanumeric() || *c == b'_')
104 };
105 if segments.iter().all(|s| ident(s)) {
106 Some(chain)
107 } else {
108 None
109 }
110}
111
112/// A property's CODE children: the named child right after the `=` token, a
113/// `property_delegate` (`by lazy { … }`), and an accessor the grammar nested

Callers 1

extract_callMethod · 0.85

Calls 4

lenMethod · 0.80
strip_js_wsFunction · 0.70
allMethod · 0.65
collectMethod · 0.45

Tested by

no test coverage detected