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

Method extract_instantiation

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

945 /// extractInstantiation's composite_literal branch: named struct types
946 /// only; the package qualifier is KEPT.
947 fn extract_instantiation(&mut self, node: Node<'t>) {
948 if self.stack.is_empty() {
949 return;
950 }
951 let ctor = node
952 .child_by_field_name("constructor")
953 .or_else(|| node.child_by_field_name("type"))
954 .or_else(|| node.child_by_field_name("name"))
955 .or_else(|| node.named_child(0));
956 let Some(ctor) = ctor else { return };
957 if !matches!(ctor.kind(), "type_identifier" | "qualified_type") {
958 return;
959 }
960 let mut go_type = self.text(ctor).trim().to_string();
961 if let Some(br) = go_type.find('[') {
962 if br > 0 {
963 go_type.truncate(br);
964 go_type = go_type.trim().to_string();
965 }
966 }
967 if !go_type.is_empty() {
968 let from = self.top_row();
969 self.push_ref_at(from, &go_type, edge_kind_index("instantiates").unwrap(), node);
970 }
971 }
972
973 /// goEmbeddedTypeName (languages/go.ts): the name node of the type an
974 /// embedding names — `T`, `*T` (the `*` is a sibling token), `pkg.T` and

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