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

Function kotlin_receiver_chain

codegraph-kernel/src/kotlin.rs:94–111  ·  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

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

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