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

Commit 9baa6a6

Browse files
author
Hendrik van Antwerpen
committed
Use iterator and pass globals to file analyzer
1 parent 6ff22f4 commit 9baa6a6

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Please see the LICENSE-APACHE or LICENSE-MIT files in this distribution for license details.
66
// ------------------------------------------------------------------------------------------------
77

8+
use std::collections::HashMap;
89
use std::path::Path;
910

1011
use stack_graphs::arena::Handle;
@@ -16,13 +17,14 @@ pub struct TsConfigAnalyzer {}
1617

1718
impl FileAnalyzer for TsConfigAnalyzer {
1819
fn build_stack_graph_into<'a>(
19-
&'a self,
20-
_stack_graph: &'a mut StackGraph,
20+
&self,
21+
_graph: &mut StackGraph,
2122
_file: Handle<File>,
2223
_path: &Path,
23-
_source: &'a str,
24-
_paths: Vec<&Path>,
25-
_cancellation_flag: &'a dyn tree_sitter_stack_graphs::CancellationFlag,
24+
_source: &str,
25+
_all_paths: &mut dyn Iterator<Item = &'a Path>,
26+
_globals: &HashMap<String, String>,
27+
_cancellation_flag: &dyn tree_sitter_stack_graphs::CancellationFlag,
2628
) -> Result<(), tree_sitter_stack_graphs::LoadError> {
2729
todo!()
2830
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ 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 all_paths = test.fragments.iter().map(|f| f.path.as_path()).collect();
212+
let mut all_paths = test.fragments.iter().map(|f| f.path.as_path());
213213
if let Some(fa) = test_fragment
214214
.path
215215
.file_name()
@@ -220,7 +220,8 @@ impl TestArgs {
220220
test_fragment.file,
221221
&test_fragment.path,
222222
&test_fragment.source,
223-
all_paths,
223+
&mut all_paths,
224+
&test_fragment.globals,
224225
&NoCancellation,
225226
)?;
226227
} else if lc.matches_file(&test_fragment.path, Some(&test_fragment.source)) {

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -940,12 +940,13 @@ impl<'a> Builder<'a> {
940940

941941
pub trait FileAnalyzer {
942942
fn build_stack_graph_into<'a>(
943-
&'a self,
944-
stack_graph: &'a mut StackGraph,
943+
&self,
944+
stack_graph: &mut StackGraph,
945945
file: Handle<File>,
946946
path: &Path,
947-
source: &'a str,
948-
paths: Vec<&Path>,
949-
cancellation_flag: &'a dyn CancellationFlag,
947+
source: &str,
948+
all_paths: &mut dyn Iterator<Item = &'a Path>,
949+
globals: &HashMap<String, String>,
950+
cancellation_flag: &dyn CancellationFlag,
950951
) -> Result<(), LoadError>;
951952
}

0 commit comments

Comments
 (0)