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

Method extract_instantiation

codegraph-kernel/src/go.rs:815–839  ·  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

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

Callers 2

visit_nodeMethod · 0.45

Calls 5

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

Tested by

no test coverage detected