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

Method extract_instantiation

codegraph-kernel/src/go.rs:820–844  ·  view source on GitHub ↗

extractInstantiation's composite_literal branch: named struct types only; the package qualifier is KEPT.

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

Source from the content-addressed store, hash-verified

818 /// extractInstantiation's composite_literal branch: named struct types
819 /// only; the package qualifier is KEPT.
820 fn extract_instantiation(&mut self, node: Node<'t>) {
821 if self.stack.is_empty() {
822 return;
823 }
824 let ctor = node
825 .child_by_field_name("constructor")
826 .or_else(|| node.child_by_field_name("type"))
827 .or_else(|| node.child_by_field_name("name"))
828 .or_else(|| node.named_child(0));
829 let Some(ctor) = ctor else { return };
830 if !matches!(ctor.kind(), "type_identifier" | "qualified_type") {
831 return;
832 }
833 let mut go_type = self.text(ctor).trim().to_string();
834 if let Some(br) = go_type.find('[') {
835 if br > 0 {
836 go_type.truncate(br);
837 go_type = go_type.trim().to_string();
838 }
839 }
840 if !go_type.is_empty() {
841 let from = self.top_row();
842 self.push_ref_at(from, &go_type, edge_kind_index("instantiates").unwrap(), node);
843 }
844 }
845
846 /// extractInheritance — the Go branches: interface embedding
847 /// (constraint_elem) and struct embedding (field_declaration without a

Callers 2

visit_nodeMethod · 0.45

Calls 5

edge_kind_indexFunction · 0.85
textMethod · 0.65
unwrapMethod · 0.60
top_rowMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected