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

Method extract_method

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

Source from the content-addressed store, hash-verified

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