From 6e903bc35fc63c28f8e6698a5ea52a832b903c87 Mon Sep 17 00:00:00 2001 From: Stephen Adamson Date: Fri, 14 Nov 2025 01:04:11 +0000 Subject: [PATCH] more rust relationships --- mcp_codebase.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/mcp_codebase.py b/mcp_codebase.py index b6bebf3..561c224 100644 --- a/mcp_codebase.py +++ b/mcp_codebase.py @@ -2130,9 +2130,24 @@ def build_indexes(): # Connect return type if available return_type = m.get("return_type") - if return_type and return_type != "void": + if return_type and return_type not in ['void', '()', 'Result', '']: for type_id, type_data in graph.find_nodes(name=return_type): graph.add_edge(node_id, type_id, "returns") + + # Connect parameter types + parameters = m.get("parameters", []) + for param in parameters: + if ':' in param: + param_parts = param.split(':') + if len(param_parts) >= 2: + param_type = param_parts[-1].strip() + param_type = param_type.replace('&', '').replace('mut ', '').strip() + if (param_type and + param_type not in ['self', '&self', '&mut self', 'mut self'] and + not param_type.startswith('&') and + param_type not in ['i32', 'i64', 'f32', 'f64', 'bool', 'String', 'str']): + for type_id, type_data in graph.find_nodes(name=param_type): + graph.add_edge(node_id, type_id, "uses_parameter") else: # Regular function graph.add_node(node_id, **base_attrs, type=node_type, @@ -2140,11 +2155,32 @@ def build_indexes(): parameters=m.get("parameters", [])) graph.add_edge(file_node_id, node_id, "contains") + # Connect return type if available + return_type = m.get("return_type") + if return_type and return_type not in ['void', '()', 'Result', '']: + for type_id, type_data in graph.find_nodes(name=return_type): + graph.add_edge(node_id, type_id, "returns") + + # Connect parameter types + parameters = m.get("parameters", []) + for param in parameters: + if ':' in param: + param_parts = param.split(':') + if len(param_parts) >= 2: + param_type = param_parts[-1].strip() + param_type = param_type.replace('&', '').replace('mut ', '').strip() + if (param_type and + param_type not in ['self', '&self', '&mut self', 'mut self'] and + not param_type.startswith('&') and + param_type not in ['i32', 'i64', 'f32', 'f64', 'bool', 'String', 'str']): + for type_id, type_data in graph.find_nodes(name=param_type): + graph.add_edge(node_id, type_id, "uses_parameter") + elif node_type in ["class", "struct", "interface", "enum"]: # Type definitions graph.add_node(node_id, **base_attrs, type=node_type, extends=m.get("extends"), - implements=m.get("implements", []), + implements=m.get("implements", []),¬ fields=m.get("fields", []), # Store fields as metadata, not separate nodes variants=m.get("variants", [])) # For enums