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

Method extract_go_interface_methods

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

extractGoInterfaceMethods: method_elem/method_spec → method nodes, each referencing the types its signature names (`decl` declares the interface).

(&mut self, interface_type: Node<'t>, iface_row: u32, iface_name: &str, decl: Node<'t>)

Source from the content-addressed store, hash-verified

650 /// referencing the types its signature names (`decl` declares the
651 /// interface).
652 fn extract_go_interface_methods(&mut self, interface_type: Node<'t>, iface_row: u32, iface_name: &str, decl: Node<'t>) {
653 self.stack.push(Scope { row: iface_row, kind: "interface", name: iface_name.to_string() });
654 let references = edge_kind_index("references").unwrap();
655 for i in 0..interface_type.named_child_count() {
656 let Some(m) = interface_type.named_child(i) else { continue };
657 if !matches!(m.kind(), "method_elem" | "method_spec") {
658 continue;
659 }
660 let name_node = m.child_by_field_name("name").or_else(|| m.named_child(0));
661 let Some(name_node) = name_node else { continue };
662 let mname = self.text(name_node).to_string();
663 if !mname.is_empty() {
664 let signature = self.signature_of(m);
665 let Some(row) = self.create_node("method", &mname, m, Extra { signature, ..Extra::default() }) else { continue };
666 for ty in self.interface_method_type_names(m, decl) {
667 let text = self.text(ty).to_string();
668 self.push_ref_at(row, &text, references, ty);
669 }
670 }
671 }
672 self.stack.pop();
673 }
674
675 /// goInterfaceMethodTypeNames (languages/go.ts): the name nodes of the
676 /// types an interface method's parameters and results name, but the

Callers 1

extract_type_aliasMethod · 0.80

Calls 8

edge_kind_indexFunction · 0.85
pushMethod · 0.80
textMethod · 0.65
unwrapMethod · 0.60
signature_ofMethod · 0.45
create_nodeMethod · 0.45
push_ref_atMethod · 0.45

Tested by

no test coverage detected