Skip to content

Commit db1ddc9

Browse files
Include paths in visualize command
1 parent 235ffa2 commit db1ddc9

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tree-sitter-stack-graphs/src/cli/visualize.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use clap::Args;
99
use clap::ValueHint;
1010
use stack_graphs::serde::NoFilter;
11+
use stack_graphs::stitching::Database;
1112
use stack_graphs::storage::SQLiteReader;
1213
use stack_graphs::NoCancellation;
1314
use std::path::Path;
@@ -41,8 +42,18 @@ impl VisualizeArgs {
4142
let source_path = source_path.canonicalize()?;
4243
db.load_graph_for_file_or_directory(&source_path, cancellation_flag)?;
4344
}
44-
let (graph, partials, db) = db.get();
45-
let html = graph.to_html_string("stack-graph", partials, db, &NoFilter)?;
45+
let (graph, _, _) = db.get();
46+
let starting_nodes = graph
47+
.iter_nodes()
48+
.filter(|n| graph[*n].is_reference())
49+
.collect::<Vec<_>>();
50+
let mut complete_paths_db = Database::new();
51+
db.find_all_complete_partial_paths(starting_nodes, cancellation_flag, |g, ps, p| {
52+
complete_paths_db.add_partial_path(g, ps, p.clone());
53+
})?;
54+
let (graph, partials, _) = db.get();
55+
let html =
56+
graph.to_html_string("stack-graph", partials, &mut complete_paths_db, &NoFilter)?;
4657
if let Some(dir) = self.output.parent() {
4758
std::fs::create_dir_all(dir)?;
4859
}

0 commit comments

Comments
 (0)