Skip to content

Commit a8c4557

Browse files
fix(drawio): resolve 'No call graph data' by generating classes from methods in enriched call graph converter
1 parent 9df6cb2 commit a8c4557

1 file changed

Lines changed: 29 additions & 4 deletions

File tree

‎langgraph_engine/diagrams/drawio/drawio_converter_enriched.py‎

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,39 @@ def _convert_call_graph_rich(self, analysis_data, style_config=None):
614614
nid = _IDGen(start=100)
615615

616616
classes = analysis_data.get("classes") or []
617-
edges_data = analysis_data.get("edges") or []
617+
edges_data = (
618+
analysis_data.get("edges")
619+
or analysis_data.get("links")
620+
or analysis_data.get("calls")
621+
or analysis_data.get("relationships")
622+
or []
623+
)
624+
625+
if not classes and analysis_data.get("methods"):
626+
methods = analysis_data.get("methods", [])
627+
by_class = {}
628+
standalone = []
629+
for m in methods:
630+
fqn = m.get("fqn", "")
631+
if not fqn:
632+
continue
633+
parent = m.get("parent_class")
634+
if parent:
635+
cls_name = parent.split("::")[-1] if "::" in parent else parent
636+
by_class.setdefault(cls_name, []).append(m)
637+
else:
638+
standalone.append(m)
639+
for cls_name, cls_meths in sorted(by_class.items()):
640+
classes.append({"name": cls_name, "methods": cls_meths})
641+
if standalone:
642+
classes.append({"name": "Functions", "methods": standalone})
618643

619644
total_nodes = sum(len(c.get("methods", [])) for c in classes)
620645
apply_coloring = len(classes) <= max_nodes and total_nodes <= max_nodes
621646

622647
all_callees = [] # type: List[str]
623648
for e in edges_data:
624-
callee = e.get("callee", "")
649+
callee = e.get("callee", e.get("to", e.get("target", "")))
625650
if callee:
626651
all_callees.append(callee)
627652
callee_set = set(all_callees)
@@ -681,8 +706,8 @@ def _convert_call_graph_rich(self, analysis_data, style_config=None):
681706
)
682707

683708
for edge in edges_data[:50]:
684-
caller_fqn = edge.get("caller", "")
685-
callee_fqn = edge.get("callee", "")
709+
caller_fqn = edge.get("caller", edge.get("from", edge.get("source", "")))
710+
callee_fqn = edge.get("callee", edge.get("to", edge.get("target", "")))
686711
freq = edge.get("frequency", 1)
687712
label = "x%d" % freq if isinstance(freq, int) and freq > 1 else ""
688713

0 commit comments

Comments
 (0)