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

Method extract_method

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

Source from the content-addressed store, hash-verified

1058 }
1059
1060 fn extract_method(&mut self, node: Node<'t>) {
1061 stack_guard!();
1062 let receiver = self.receiver_type_of(node);
1063 let name = self.extract_name(node);
1064 let qualified_override = receiver.as_ref().map(|r| format!("{r}::{name}"));
1065 let extra = Extra {
1066 docstring: preceding_docstring(node, self.src),
1067 signature: self.signature_of(node),
1068 visibility: Some(self.visibility_of(node)),
1069 is_async: Some(self.is_async(node)),
1070 is_static: Some(false),
1071 return_type: self.return_type_of(node),
1072 qualified_override,
1073 };
1074 let Some(row) = self.create_node("method", &name, node, extra) else { return };
1075 // Owner-contains fallback (1799): receiver present, not class-like →
1076 // the FIRST same-file node named like the receiver with kind ∈
1077 // {struct, class, enum, trait} (interface EXCLUDED; source-order
1078 // dependent — both quirks preserved). Additive to the normal edge.
1079 if let Some(recv) = &receiver {
1080 if !self.inside_class_like() {
1081 let owner = self
1082 .nodes_meta
1083 .iter()
1084 .position(|m| {
1085 m.name == *recv && matches!(m.kind, "struct" | "class" | "enum" | "trait")
1086 })
1087 .map(|i| i as u32);
1088 if let Some(owner_row) = owner {
1089 self.tables.push_edge(&EdgeRow {
1090 source_idx: owner_row,
1091 target_idx: row,
1092 kind: edge_kind_index("contains").unwrap(),
1093 provenance: 0,
1094 line: NONE,
1095 column: NONE,
1096 metadata_json: NONE_STR,
1097 source_id_str: NONE_STR,
1098 target_id_str: NONE_STR,
1099 });
1100 }
1101 }
1102 }
1103 // Type annotations: dead. Decorators: live.
1104 self.extract_decorators_for(node, row);
1105 self.stack.push(Scope { row, kind: "method", name });
1106 if let Some(body) = self.resolve_body(node) {
1107 self.visit_function_body(body);
1108 }
1109 self.stack.pop();
1110 }
1111
1112 fn extract_class(&mut self, node: Node<'t>) {
1113 stack_guard!();

Callers 2

visit_nodeMethod · 0.45
extract_functionMethod · 0.45

Calls 15

preceding_docstringFunction · 0.85
edge_kind_indexFunction · 0.85
mapMethod · 0.80
positionMethod · 0.80
push_edgeMethod · 0.80
pushMethod · 0.80
unwrapMethod · 0.60
receiver_type_ofMethod · 0.45
extract_nameMethod · 0.45
signature_ofMethod · 0.45
visibility_ofMethod · 0.45
is_asyncMethod · 0.45

Tested by

no test coverage detected