Skip to content

Commit 978a52a

Browse files
Include paths in visualize command
1 parent 1ca9d77 commit 978a52a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
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;
13+
use stack_graphs::NoCancellation;
1214
use std::path::Path;
1315
use std::path::PathBuf;
1416

@@ -41,8 +43,18 @@ impl VisualizeArgs {
4143
let source_path = source_path.canonicalize()?;
4244
db.load_graph_for_file_or_directory(&source_path)?;
4345
}
44-
let (graph, partials, db) = db.get();
45-
let html = graph.to_html_string("stack-graph", partials, db, &NoFilter)?;
46+
let (graph, _, _) = db.get();
47+
let starting_nodes = graph
48+
.iter_nodes()
49+
.filter(|n| graph[*n].is_reference())
50+
.collect::<Vec<_>>();
51+
let mut complete_paths_db = Database::new();
52+
db.find_all_complete_partial_paths(starting_nodes, &NoCancellation, |g, ps, p| {
53+
complete_paths_db.add_partial_path(g, ps, p.clone());
54+
})?;
55+
let (graph, partials, _) = db.get();
56+
let html =
57+
graph.to_html_string("stack-graph", partials, &mut complete_paths_db, &NoFilter)?;
4658
if let Some(dir) = self.output.parent() {
4759
std::fs::create_dir_all(dir)?;
4860
}

0 commit comments

Comments
 (0)