MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / dot_parser

Function dot_parser

src/analysis/callgraph.rs:40–62  ·  view source on GitHub ↗
(dot_file: &Path)

Source from the content-addressed store, hash-verified

38}
39
40fn dot_parser(dot_file: &Path) -> eyre::Result<(Vec<DotNode>, Vec<DotEdge>)> {
41 let content =
42 std::fs::read_to_string(dot_file).context(format!("dot file open error: {dot_file:?}"))?;
43 let node_re =
44 Regex::new(r###"Node(0x[0-9a-fA-F]+) \[shape=record,label="\{(.+?)\}"];"###).unwrap();
45 let mut nodes = Vec::new();
46 for captures in node_re.captures_iter(&content) {
47 let id = &captures[1];
48 let label = &captures[2];
49 let node = DotNode::new(id, label);
50 nodes.push(node);
51 }
52
53 let mut edges: Vec<DotEdge> = Vec::new();
54 let edge_re = Regex::new(r###"Node(0x[0-9a-fA-F]+) -> Node(0x[0-9a-fA-F]+);"###).unwrap();
55 for captures in edge_re.captures_iter(&content) {
56 let src = &captures[1];
57 let dst = &captures[2];
58 let edge = DotEdge::new(src, dst);
59 edges.push(edge)
60 }
61 Ok((nodes, edges))
62}
63
64pub struct CallGraph {
65 graph: Graph<String, u8, Directed>,

Callers 1

get_lib_call_graphFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected