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

Method extract_instantiation

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

917 /// extractInstantiation's composite_literal branch: named struct types
918 /// only; the package qualifier is KEPT.
919 fn extract_instantiation(&mut self, node: Node<'t>) {
920 if self.stack.is_empty() {
921 return;
922 }
923 let ctor = node
924 .child_by_field_name("constructor")
925 .or_else(|| node.child_by_field_name("type"))
926 .or_else(|| node.child_by_field_name("name"))
927 .or_else(|| node.named_child(0));
928 let Some(ctor) = ctor else { return };
929 if !matches!(ctor.kind(), "type_identifier" | "qualified_type") {
930 return;
931 }
932 let mut go_type = self.text(ctor).trim().to_string();
933 if let Some(br) = go_type.find('[') {
934 if br > 0 {
935 go_type.truncate(br);
936 go_type = go_type.trim().to_string();
937 }
938 }
939 if !go_type.is_empty() {
940 let from = self.top_row();
941 self.push_ref_at(from, &go_type, edge_kind_index("instantiates").unwrap(), node);
942 }
943 }
944
945 /// goEmbeddedTypeName (languages/go.ts): the name node of the type an
946 /// 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