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

Function property_initializers

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

A property's CODE children: the named child right after the `=` token, a `property_delegate` (`by lazy { … }`), 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 stays unwalked is the declaration itself — modifiers, the `val`/`var` keyw

(node: Node<'t>)

Source from the content-addressed store, hash-verified

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