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

Method extract_aggregate

codegraph-kernel/src/rustlang.rs:653–675  ·  view source on GitHub ↗

Extract a Rust struct or union — the body field is OPTIONAL. A unit struct (`struct U;`) has no body and is still a complete definition, so it mints a node with no members; tuple structs' ordered_field_declaration_list is a body. Mirrors the TS reference's `allowBodilessStruct`.

(&mut self, node: Node<'t>, kind: &'static str)

Source from the content-addressed store, hash-verified

651 /// so it mints a node with no members; tuple structs' ordered_field_declaration_list
652 /// is a body. Mirrors the TS reference's `allowBodilessStruct`.
653 fn extract_aggregate(&mut self, node: Node<'t>, kind: &'static str) {
654 stack_guard!();
655 let name = self.extract_name(node);
656 let extra = Extra {
657 docstring: preceding_docstring(node, self.src),
658 visibility: Some(self.visibility_of(node)),
659 ..Extra::default()
660 };
661 let Some(row) = self.create_node(kind, &name, node, extra) else { return };
662 self.extract_inheritance(node, row);
663
664 // Unit structs have no body to walk — the node itself is the whole
665 // definition.
666 let Some(body) = node.child_by_field_name("body") else { return };
667
668 self.stack.push(Scope { row, kind, name });
669 for i in 0..body.named_child_count() {
670 if let Some(c) = body.named_child(i) {
671 self.visit_node(c);
672 }
673 }
674 self.stack.pop();
675 }
676
677 /// extractEnum — body required; enum_variant children → enum_member nodes
678 /// (name field only, payloads never walked); other children re-dispatched.

Callers 2

visit_nodeMethod · 0.45

Calls 7

preceding_docstringFunction · 0.85
pushMethod · 0.80
extract_nameMethod · 0.45
visibility_ofMethod · 0.45
create_nodeMethod · 0.45
extract_inheritanceMethod · 0.45
visit_nodeMethod · 0.45

Tested by

no test coverage detected