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

Method extract_go_interface_methods

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

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

Callers 1

extract_type_aliasMethod · 0.80

Calls 9

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

Tested by

no test coverage detected