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

Function property_initializers

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

A property's CODE children: the named child right after the `=` token, a `property_delegate` (`by lazy { … }`), an explicit backing field (`field = MutableStateFlow(S())`, Kotlin 2.x), and an accessor the grammar nested under the declaration (`val x: Int get() = compute()` — written on ONE line; an accessor on its own line parses as a SIBLING of the property and is not reachable from here). What s

(node: Node<'t>)

Source from the content-addressed store, hash-verified

121/// for the same reason; this grammar exposes no fields at all, hence the `=`
122/// anchor.)
123fn property_initializers<'t>(node: Node<'t>) -> Vec<Node<'t>> {
124 let mut out: Vec<Node<'t>> = Vec::new();
125 let mut after_eq = false;
126 for c in node.children(&mut node.walk()) {
127 if !c.is_named() {
128 if c.kind() == "=" {
129 after_eq = true;
130 }
131 continue;
132 }
133 if after_eq {
134 out.push(c);
135 after_eq = false;
136 } else if matches!(c.kind(), "property_delegate" | "getter" | "setter" | "backing_field") {
137 out.push(c);
138 }
139 }
140 out
141}
142
143/// Accessors written on their OWN line parse as SIBLINGS of the property, not
144/// as children of it (same-line ones nest — see property_initializers). Walking

Callers 1

try_visit_hookMethod · 0.85

Calls 3

childrenMethod · 0.80
pushMethod · 0.80
walkMethod · 0.45

Tested by

no test coverage detected