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

Method extract_method

codegraph-kernel/src/kotlin.rs:812–861  ·  view source on GitHub ↗
(&mut self, node: Node<'t>)

Source from the content-addressed store, hash-verified

810 }
811
812 fn extract_method(&mut self, node: Node<'t>) {
813 let receiver = self.receiver_type_of(node);
814 let name = self.extract_name(node);
815 let qualified_override = receiver.as_ref().map(|r| format!("{r}::{name}"));
816 let extra = Extra {
817 docstring: preceding_docstring(node, self.src),
818 signature: None,
819 visibility: Some(self.visibility_of(node)),
820 is_async: Some(self.is_async(node)),
821 is_static: Some(false),
822 return_type: self.return_type_of(node),
823 qualified_override,
824 };
825 let Some(row) = self.create_node("method", &name, node, extra) else { return };
826 // Owner-contains fallback (1799): receiver present, not class-like →
827 // the FIRST same-file node named like the receiver with kind ∈
828 // {struct, class, enum, trait} (interface EXCLUDED; source-order
829 // dependent — both quirks preserved). Additive to the normal edge.
830 if let Some(recv) = &receiver {
831 if !self.inside_class_like() {
832 let owner = self
833 .nodes_meta
834 .iter()
835 .position(|m| {
836 m.name == *recv && matches!(m.kind, "struct" | "class" | "enum" | "trait")
837 })
838 .map(|i| i as u32);
839 if let Some(owner_row) = owner {
840 self.tables.push_edge(&EdgeRow {
841 source_idx: owner_row,
842 target_idx: row,
843 kind: edge_kind_index("contains").unwrap(),
844 provenance: 0,
845 line: NONE,
846 column: NONE,
847 metadata_json: NONE_STR,
848 source_id_str: NONE_STR,
849 target_id_str: NONE_STR,
850 });
851 }
852 }
853 }
854 // Type annotations: dead. Decorators: live.
855 self.extract_decorators_for(node, row);
856 self.stack.push(Scope { row, kind: "method", name });
857 if let Some(body) = self.resolve_body(node) {
858 self.visit_function_body(body);
859 }
860 self.stack.pop();
861 }
862
863 fn extract_class(&mut self, node: Node<'t>) {
864 let resolved_body = self.resolve_body(node);

Callers 2

visit_nodeMethod · 0.45
extract_functionMethod · 0.45

Calls 14

preceding_docstringFunction · 0.85
edge_kind_indexFunction · 0.85
push_edgeMethod · 0.80
unwrapMethod · 0.60
receiver_type_ofMethod · 0.45
extract_nameMethod · 0.45
visibility_ofMethod · 0.45
is_asyncMethod · 0.45
return_type_ofMethod · 0.45
create_nodeMethod · 0.45
inside_class_likeMethod · 0.45

Tested by

no test coverage detected