Files
graphify/tests/fixtures/sample.rs
T
SynvoyaandClaude Opus 4.8 674184d462 fix(rust): emit references edges for enum variant field types
Enum variant payload types were silently dropped — `struct_item` and
`trait_item` had type-reference handlers but `enum_item` had none, so the
variant field types were never traversed.

Add an `enum_item` branch that walks
`enum_variant_list -> enum_variant -> ordered_field_declaration_list`
(tuple variants, `Click(Logger)`) and `field_declaration_list` (struct
variants, `Resize { size: Dim }`), emitting a `references` edge from the enum
to each field type. Reuses the same type collection as the struct path. Adds
an enum to the fixture and a regression test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 11:58:39 +01:00

59 lines
990 B
Rust

use std::collections::HashMap;
struct Graph {
nodes: HashMap<String, Vec<String>>,
}
impl Graph {
fn new() -> Self {
Graph { nodes: HashMap::new() }
}
fn add_node(&mut self, id: String) {
self.nodes.insert(id, vec![]);
}
fn add_edge(&mut self, src: String, tgt: String) {
self.nodes.entry(src).or_default().push(tgt);
}
}
fn build_graph(edges: Vec<(String, String)>) -> Graph {
let mut g = Graph::new();
for (src, tgt) in edges {
g.add_edge(src, tgt);
}
g
}
trait Processor {
fn run(&self);
}
trait Logger: Processor {
fn log(&self);
}
struct Result<T> {
value: T,
}
struct DataProcessor {
current: Result<DataProcessor>,
}
impl Processor for DataProcessor {
fn run(&self) {}
}
impl DataProcessor {
fn build(input: DataProcessor) -> Result<DataProcessor> {
Result { value: input }
}
}
enum GraphEvent {
NodeAdded(Graph),
Processed { proc: DataProcessor },
}