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

Function property_initializers

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

120/// for the same reason; this grammar exposes no fields at all, hence the `=`
121/// anchor.)
122fn property_initializers<'t>(node: Node<'t>) -> Vec<Node<'t>> {
123 let mut out: Vec<Node<'t>> = Vec::new();
124 let mut after_eq = false;
125 for i in 0..node.child_count() {
126 let Some(c) = node.child(i) else { continue };
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 1

pushMethod · 0.80

Tested by

no test coverage detected