Skip to content
This repository was archived by the owner on Sep 9, 2025. It is now read-only.

Commit 6ff22f4

Browse files
author
Hendrik van Antwerpen
committed
Pass all paths to file analyzer
1 parent a8f70c6 commit 6ff22f4

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

languages/tree-sitter-stack-graphs-typescript/rust/tsconfig.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ impl FileAnalyzer for TsConfigAnalyzer {
2121
_file: Handle<File>,
2222
_path: &Path,
2323
_source: &'a str,
24+
_paths: Vec<&Path>,
2425
_cancellation_flag: &'a dyn tree_sitter_stack_graphs::CancellationFlag,
2526
) -> Result<(), tree_sitter_stack_graphs::LoadError> {
2627
todo!()

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,25 @@ impl TestArgs {
209209
.with_context(|| format!("Loading builtins into {}", test_path.display()))?;
210210
let mut globals = Variables::new();
211211
for test_fragment in &test.fragments {
212-
let fragment_path = Path::new(test.graph[test_fragment.file].name()).to_path_buf();
213-
if let Some(fa) = fragment_path
212+
let all_paths = test.fragments.iter().map(|f| f.path.as_path()).collect();
213+
if let Some(fa) = test_fragment
214+
.path
214215
.file_name()
215216
.and_then(|f| lc.special_files.get(&f.to_string_lossy()))
216217
{
217218
fa.build_stack_graph_into(
218219
&mut test.graph,
219220
test_fragment.file,
220-
&fragment_path,
221+
&test_fragment.path,
221222
&test_fragment.source,
223+
all_paths,
222224
&NoCancellation,
223225
)?;
224-
} else if lc.matches_file(&fragment_path, Some(&test_fragment.source)) {
226+
} else if lc.matches_file(&test_fragment.path, Some(&test_fragment.source)) {
225227
globals.clear();
226228
test_fragment.add_globals_to(&mut globals);
227229
self.build_fragment_stack_graph_into(
228-
&fragment_path,
230+
&test_fragment.path,
229231
&lc.sgl,
230232
test_fragment.file,
231233
&test_fragment.source,
@@ -235,8 +237,8 @@ impl TestArgs {
235237
} else {
236238
return Err(anyhow!(
237239
"Test fragment {} not supported by language of test file {}",
238-
fragment_path.display(),
239-
test_path.display()
240+
test_fragment.path.display(),
241+
test.path.display()
240242
));
241243
}
242244
}

tree-sitter-stack-graphs/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ pub trait FileAnalyzer {
945945
file: Handle<File>,
946946
path: &Path,
947947
source: &'a str,
948+
paths: Vec<&Path>,
948949
cancellation_flag: &'a dyn CancellationFlag,
949950
) -> Result<(), LoadError>;
950951
}

tree-sitter-stack-graphs/src/test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ pub struct Test {
126126
#[derive(Debug, Clone)]
127127
pub struct TestFragment {
128128
pub file: Handle<File>,
129+
pub path: PathBuf,
129130
pub source: String,
130131
pub assertions: Vec<Assertion>,
131132
pub globals: HashMap<String, String>,
@@ -167,6 +168,7 @@ impl Test {
167168
.for_each(|_| line_files.push(Some(file)));
168169
fragments.push(TestFragment {
169170
file,
171+
path: current_path,
170172
source: current_source,
171173
assertions: Vec::new(),
172174
globals: current_globals,
@@ -206,6 +208,7 @@ impl Test {
206208
(line_files.len()..line_count).for_each(|_| line_files.push(Some(file)));
207209
fragments.push(TestFragment {
208210
file,
211+
path: current_path,
209212
source: current_source,
210213
assertions: Vec::new(),
211214
globals: current_globals,

0 commit comments

Comments
 (0)