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

Method extract_instantiation

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

933 /// extractInstantiation's composite_literal branch: named struct types
934 /// only; the package qualifier is KEPT.
935 fn extract_instantiation(&mut self, node: Node<'t>) {
936 if self.stack.is_empty() {
937 return;
938 }
939 let ctor = node
940 .child_by_field_name("constructor")
941 .or_else(|| node.child_by_field_name("type"))
942 .or_else(|| node.child_by_field_name("name"))
943 .or_else(|| node.named_child(0));
944 let Some(ctor) = ctor else { return };
945 if !matches!(ctor.kind(), "type_identifier" | "qualified_type") {
946 return;
947 }
948 let mut go_type = self.text(ctor).trim().to_string();
949 if let Some(br) = go_type.find('[') {
950 if br > 0 {
951 go_type.truncate(br);
952 go_type = go_type.trim().to_string();
953 }
954 }
955 if !go_type.is_empty() {
956 let from = self.top_row();
957 self.push_ref_at(from, &go_type, edge_kind_index("instantiates").unwrap(), node);
958 }
959 }
960
961 /// goEmbeddedTypeName (languages/go.ts): the name node of the type an
962 /// 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