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

Method extract_method

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

Source from the content-addressed store, hash-verified

1018 }
1019
1020 fn extract_method(&mut self, node: Node<'t>) {
1021 stack_guard!();
1022 let receiver = self.receiver_type_of(node);
1023 let name = self.extract_name(node);
1024 let qualified_override = receiver.as_ref().map(|r| format!("{r}::{name}"));
1025 let extra = Extra {
1026 docstring: preceding_docstring(node, self.src),
1027 signature: self.signature_of(node),
1028 visibility: Some(self.visibility_of(node)),
1029 is_async: Some(self.is_async(node)),
1030 is_static: Some(false),
1031 return_type: self.return_type_of(node),
1032 qualified_override,
1033 };
1034 let Some(row) = self.create_node("method", &name, node, extra) else { return };
1035 // Owner-contains fallback (1799): receiver present, not class-like →
1036 // the FIRST same-file node named like the receiver with kind ∈
1037 // {struct, class, enum, trait} (interface EXCLUDED; source-order
1038 // dependent — both quirks preserved). Additive to the normal edge.
1039 if let Some(recv) = &receiver {
1040 if !self.inside_class_like() {
1041 let owner = self
1042 .nodes_meta
1043 .iter()
1044 .position(|m| {
1045 m.name == *recv && matches!(m.kind, "struct" | "class" | "enum" | "trait")
1046 })
1047 .map(|i| i as u32);
1048 if let Some(owner_row) = owner {
1049 self.tables.push_edge(&EdgeRow {
1050 source_idx: owner_row,
1051 target_idx: row,
1052 kind: edge_kind_index("contains").unwrap(),
1053 provenance: 0,
1054 line: NONE,
1055 column: NONE,
1056 metadata_json: NONE_STR,
1057 source_id_str: NONE_STR,
1058 target_id_str: NONE_STR,
1059 });
1060 }
1061 }
1062 }
1063 // Type annotations: dead. Decorators: live.
1064 self.extract_decorators_for(node, row);
1065 self.stack.push(Scope { row, kind: "method", name });
1066 if let Some(body) = self.resolve_body(node) {
1067 self.visit_function_body(body);
1068 }
1069 self.stack.pop();
1070 }
1071
1072 fn extract_class(&mut self, node: Node<'t>) {
1073 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