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

Function class_header_code

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

The code a class, object or enum header holds, in source order (TS `kotlinClassHeaderCode`): each constructor parameter's default value (`c: Clock = SystemClock()`), the arguments of the superclass constructor it calls (`: Base(load())`), and the expression after `by` it delegates an interface to (`I by Impl()`). A class with a body walks it as its own code before the body; the types and annotatio

(node: Node<'t>)

Source from the content-addressed store, hash-verified

180/// interface to (`I by Impl()`). A class with a body walks it as its own code
181/// before the body; the types and annotations around it are left alone.
182fn class_header_code<'t>(node: Node<'t>) -> Vec<Node<'t>> {
183 let mut out: Vec<Node<'t>> = Vec::new();
184 for child in node.named_children(&mut node.walk()) {
185 match child.kind() {
186 "primary_constructor" => {
187 for param in child.named_children(&mut child.walk()) {
188 if param.kind() != "class_parameter" {
189 continue;
190 }
191 if let Some(value) = named_child_after(param, "=") {
192 out.push(value);
193 }
194 }
195 }
196 "delegation_specifier" => match child.named_child(0) {
197 Some(spec) if spec.kind() == "constructor_invocation" => {
198 if let Some(args) = (0..spec.named_child_count())
199 .filter_map(|j| spec.named_child(j))
200 .find(|c| c.kind() == "value_arguments")
201 {
202 out.push(args);
203 }
204 }
205 Some(spec) if spec.kind() == "explicit_delegation" => {
206 if let Some(delegate) = named_child_after(spec, "by") {
207 out.push(delegate);
208 }
209 }
210 _ => {}
211 },
212 _ => {}
213 }
214 }
215 out
216}
217
218/// The sibling accessors that follow a property declaration, in source order.
219fn following_accessors<'t>(node: Node<'t>) -> Vec<Node<'t>> {

Callers 2

extract_classMethod · 0.85
extract_enumMethod · 0.85

Calls 3

named_child_afterFunction · 0.85
pushMethod · 0.80
walkMethod · 0.45

Tested by

no test coverage detected