more rust relationships

This commit is contained in:
2025-11-14 01:04:11 +00:00
parent de6bbfc097
commit 6e903bc35f
+38 -2
View File
@@ -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