From 209b54b4151958573ab07b80f4a1af30220adeee Mon Sep 17 00:00:00 2001 From: Hendrik van Antwerpen Date: Mon, 9 Dec 2024 15:05:19 +0100 Subject: [PATCH 1/4] Upgrade tree-sitter dependency to v0.24 --- Cargo.toml | 9 +-- src/bin/tree-sitter-graph/main.rs | 6 +- src/checker.rs | 2 +- src/execution.rs | 20 +++--- src/execution/lazy.rs | 8 ++- src/execution/strict.rs | 9 +-- src/parse_error.rs | 2 +- src/parser.rs | 8 +-- tests/it/execution.rs | 6 +- tests/it/functions.rs | 6 +- tests/it/graph.rs | 4 +- tests/it/lazy_execution.rs | 6 +- tests/it/parse_errors.rs | 4 +- tests/it/parser.rs | 103 +++++++++++++++++++----------- 14 files changed, 116 insertions(+), 77 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f6edf7cf..cca628f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,13 +33,14 @@ regex = "1.3.2" serde = "1.0" serde_json = "1.0" smallvec = { version="1.6", features=["union"] } +streaming-iterator = "0.1.9" string-interner = { version = "0.12", default-features = false, features = ["std", "inline-more", "backends"] } thiserror = "1.0.7" -tree-sitter = "0.20.3" -tree-sitter-config = { version = "0.19", optional = true } -tree-sitter-loader = { version = "0.20", optional = true } +tree-sitter = "0.24" +tree-sitter-config = { version = "0.24", optional = true } +tree-sitter-loader = { version = "0.24", optional = true } [dev-dependencies] env_logger = "0.9" indoc = "1.0" -tree-sitter-python = "0.20" +tree-sitter-python = "=0.23.5" diff --git a/src/bin/tree-sitter-graph/main.rs b/src/bin/tree-sitter-graph/main.rs index 9103b528..8ea65470 100644 --- a/src/bin/tree-sitter-graph/main.rs +++ b/src/bin/tree-sitter-graph/main.rs @@ -89,7 +89,7 @@ fn main() -> Result<()> { )?; } - let config = Config::load()?; + let config = Config::load(None)?; let mut loader = Loader::new()?; let loader_config = config.get()?; loader.find_all_languages(&loader_config)?; @@ -98,7 +98,7 @@ fn main() -> Result<()> { let tsg = std::fs::read(tsg_path) .with_context(|| format!("Cannot read TSG file {}", tsg_path.display()))?; let tsg = String::from_utf8(tsg)?; - let file = match File::from_str(language, &tsg) { + let file = match File::from_str(language.clone(), &tsg) { Ok(file) => file, Err(err) => { eprintln!("{}", err.display_pretty(tsg_path, &tsg)); @@ -110,7 +110,7 @@ fn main() -> Result<()> { .with_context(|| format!("Cannot read source file {}", source_path.display()))?; let source = String::from_utf8(source)?; let mut parser = Parser::new(); - parser.set_language(language)?; + parser.set_language(&language)?; let tree = parser .parse(&source, None) .ok_or_else(|| anyhow!("Cannot parse {}", source_path.display()))?; diff --git a/src/checker.rs b/src/checker.rs index a9241a8e..b0a2d287 100644 --- a/src/checker.rs +++ b/src/checker.rs @@ -188,7 +188,7 @@ impl ast::Stanza { .expect("capture should have index") != self.full_match_stanza_capture_index as u32 }) - .map(|cn| Identifier::from(cn.as_str())) + .map(|cn| Identifier::from(*cn)) .collect::>(); let unused_captures = all_captures .difference(&used_captures) diff --git a/src/execution.rs b/src/execution.rs index 033f2400..f5f7a425 100644 --- a/src/execution.rs +++ b/src/execution.rs @@ -119,11 +119,11 @@ impl File { .iter() .map(|name| { let index = file_query - .capture_index_for_name(name) + .capture_index_for_name(*name) .expect("missing index for capture"); let quantifier = file_query.capture_quantifiers(mat.pattern_index)[index as usize]; - (name, quantifier, index) + (*name, quantifier, index) }) .filter(|c| c.2 != stanza.full_match_file_capture_index as u32) .collect(); @@ -143,10 +143,10 @@ impl File { .map(|name| { let index = stanza .query - .capture_index_for_name(name) + .capture_index_for_name(*name) .expect("missing index for capture"); let quantifier = stanza.query.capture_quantifiers(0)[index as usize]; - (name, quantifier, index) + (*name, quantifier, index) }) .filter(|c| c.2 != stanza.full_match_stanza_capture_index as u32) .collect(); @@ -179,10 +179,10 @@ impl Stanza { .map(|name| { let index = self .query - .capture_index_for_name(name) + .capture_index_for_name(*name) .expect("missing index for capture"); let quantifier = self.query.capture_quantifiers(0)[index as usize]; - (name, quantifier, index) + (*name, quantifier, index) }) .filter(|c| c.2 != self.full_match_stanza_capture_index as u32) .collect(); @@ -197,9 +197,9 @@ impl Stanza { } pub struct Match<'a, 'tree> { - mat: QueryMatch<'a, 'tree>, + mat: &'a QueryMatch<'a, 'tree>, full_capture_index: u32, - named_captures: Vec<(&'a String, CaptureQuantifier, u32)>, + named_captures: Vec<(&'a str, CaptureQuantifier, u32)>, query_location: Location, } @@ -217,7 +217,7 @@ impl<'a, 'tree> Match<'a, 'tree> { &'s self, ) -> impl Iterator< Item = ( - &String, + &'a str, CaptureQuantifier, impl Iterator> + 's, ), @@ -239,7 +239,7 @@ impl<'a, 'tree> Match<'a, 'tree> { } /// Return an iterator over all capture names. - pub fn capture_names(&self) -> impl Iterator { + pub fn capture_names(&self) -> impl Iterator { self.named_captures.iter().map(|c| c.0) } diff --git a/src/execution/lazy.rs b/src/execution/lazy.rs index ab97f3db..a2fbb86a 100644 --- a/src/execution/lazy.rs +++ b/src/execution/lazy.rs @@ -18,6 +18,8 @@ use tree_sitter::QueryCursor; use tree_sitter::QueryMatch; use tree_sitter::Tree; +use streaming_iterator::StreamingIterator; + use crate::ast; use crate::execution::error::ExecutionError; use crate::execution::error::ResultWithExecutionError; @@ -116,12 +118,12 @@ impl ast::File { mut visit: F, ) -> Result<(), E> where - F: FnMut(&ast::Stanza, QueryMatch<'_, 'tree>) -> Result<(), E>, + F: FnMut(&ast::Stanza, &QueryMatch<'_, 'tree>) -> Result<(), E>, { let mut cursor = QueryCursor::new(); let query = self.query.as_ref().unwrap(); - let matches = cursor.matches(query, tree.root_node(), source.as_bytes()); - for mat in matches { + let mut matches = cursor.matches(query, tree.root_node(), source.as_bytes()); + while let Some(mat) = matches.next() { let stanza = &self.stanzas[mat.pattern_index]; visit(stanza, mat)?; } diff --git a/src/execution/strict.rs b/src/execution/strict.rs index 86881a26..1812a710 100644 --- a/src/execution/strict.rs +++ b/src/execution/strict.rs @@ -8,6 +8,7 @@ use std::collections::BTreeSet; use std::collections::HashMap; use std::collections::HashSet; +use streaming_iterator::StreamingIterator; use tree_sitter::QueryCursor; use tree_sitter::QueryMatch; use tree_sitter::Tree; @@ -115,7 +116,7 @@ impl File { mut visit: F, ) -> Result<(), E> where - F: FnMut(&Stanza, QueryMatch<'_, 'tree>) -> Result<(), E>, + F: FnMut(&Stanza, &QueryMatch<'_, 'tree>) -> Result<(), E>, { for stanza in &self.stanzas { stanza.try_visit_matches_strict(tree, source, |mat| visit(stanza, mat))?; @@ -214,11 +215,11 @@ impl Stanza { mut visit: F, ) -> Result<(), E> where - F: FnMut(QueryMatch<'_, 'tree>) -> Result<(), E>, + F: FnMut(&QueryMatch<'_, 'tree>) -> Result<(), E>, { let mut cursor = QueryCursor::new(); - let matches = cursor.matches(&self.query, tree.root_node(), source.as_bytes()); - for mat in matches { + let mut matches = cursor.matches(&self.query, tree.root_node(), source.as_bytes()); + while let Some(mat) = matches.next() { visit(mat)?; } Ok(()) diff --git a/src/parse_error.rs b/src/parse_error.rs index 9bcda5b7..5b2ff73e 100644 --- a/src/parse_error.rs +++ b/src/parse_error.rs @@ -39,7 +39,7 @@ impl<'tree> ParseError<'tree> { } /// Return all parse errors in the given tree. - pub fn all(tree: &'tree Tree) -> Vec { + pub fn all(tree: &'tree Tree) -> Vec> { let mut errors = Vec::new(); find_errors(tree, &mut errors, false); errors diff --git a/src/parser.rs b/src/parser.rs index eb68d920..ca660867 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -305,13 +305,13 @@ impl<'a> Parser<'a> { let name = self.parse_identifier("inherit")?; file.inherited_variables.insert(name); } else { - let stanza = self.parse_stanza(file.language)?; + let stanza = self.parse_stanza(&file.language)?; file.stanzas.push(stanza); } self.consume_whitespace(); } // we can unwrap here because all queries have already been parsed before - file.query = Some(Query::new(file.language, &self.query_source).unwrap()); + file.query = Some(Query::new(&file.language, &self.query_source).unwrap()); Ok(()) } @@ -369,7 +369,7 @@ impl<'a> Parser<'a> { Ok(quantifier) } - fn parse_stanza(&mut self, language: Language) -> Result { + fn parse_stanza(&mut self, language: &Language) -> Result { let start = self.location; let (query, full_match_stanza_capture_index) = self.parse_query(language)?; self.consume_whitespace(); @@ -385,7 +385,7 @@ impl<'a> Parser<'a> { }) } - fn parse_query(&mut self, language: Language) -> Result<(Query, usize), ParseError> { + fn parse_query(&mut self, language: &Language) -> Result<(Query, usize), ParseError> { let location = self.location; let query_start = self.offset; self.skip_query()?; diff --git a/tests/it/execution.rs b/tests/it/execution.rs index 7d699073..0bfceec6 100644 --- a/tests/it/execution.rs +++ b/tests/it/execution.rs @@ -27,10 +27,12 @@ fn init_log() { fn execute(python_source: &str, dsl_source: &str) -> Result { init_log(); let mut parser = Parser::new(); - parser.set_language(tree_sitter_python::language()).unwrap(); + parser + .set_language(&tree_sitter_python::LANGUAGE.into()) + .unwrap(); let tree = parser.parse(python_source, None).unwrap(); let file = - File::from_str(tree_sitter_python::language(), dsl_source).expect("Cannot parse file"); + File::from_str(tree_sitter_python::LANGUAGE.into(), dsl_source).expect("Cannot parse file"); let functions = Functions::stdlib(); let mut globals = Variables::new(); globals diff --git a/tests/it/functions.rs b/tests/it/functions.rs index bb5cebbc..40afb0e9 100644 --- a/tests/it/functions.rs +++ b/tests/it/functions.rs @@ -27,10 +27,12 @@ fn init_log() { fn execute(python_source: &str, dsl_source: &str) -> Result { init_log(); let mut parser = Parser::new(); - parser.set_language(tree_sitter_python::language()).unwrap(); + parser + .set_language(&tree_sitter_python::LANGUAGE.into()) + .unwrap(); let tree = parser.parse(python_source, None).unwrap(); let file = - File::from_str(tree_sitter_python::language(), dsl_source).expect("Cannot parse file"); + File::from_str(tree_sitter_python::LANGUAGE.into(), dsl_source).expect("Cannot parse file"); let functions = Functions::stdlib(); let mut globals = Variables::new(); globals diff --git a/tests/it/graph.rs b/tests/it/graph.rs index f5bd9fd7..4ec6de7b 100644 --- a/tests/it/graph.rs +++ b/tests/it/graph.rs @@ -51,7 +51,9 @@ fn can_iterate_graph_edges() { fn can_display_graph() { let python_source = "pass"; let mut parser = Parser::new(); - parser.set_language(tree_sitter_python::language()).unwrap(); + parser + .set_language(&tree_sitter_python::LANGUAGE.into()) + .unwrap(); let tree = parser.parse(python_source, None).unwrap(); let mut graph = Graph::new(); diff --git a/tests/it/lazy_execution.rs b/tests/it/lazy_execution.rs index 3e0395ab..82262207 100644 --- a/tests/it/lazy_execution.rs +++ b/tests/it/lazy_execution.rs @@ -26,10 +26,12 @@ fn init_log() { fn execute(python_source: &str, dsl_source: &str) -> Result { init_log(); let mut parser = Parser::new(); - parser.set_language(tree_sitter_python::language()).unwrap(); + parser + .set_language(&tree_sitter_python::LANGUAGE.into()) + .unwrap(); let tree = parser.parse(python_source, None).unwrap(); let file = - File::from_str(tree_sitter_python::language(), dsl_source).expect("Cannot parse file"); + File::from_str(tree_sitter_python::LANGUAGE.into(), dsl_source).expect("Cannot parse file"); let functions = Functions::stdlib(); let mut globals = Variables::new(); globals diff --git a/tests/it/parse_errors.rs b/tests/it/parse_errors.rs index c7ce73d1..108a76b8 100644 --- a/tests/it/parse_errors.rs +++ b/tests/it/parse_errors.rs @@ -23,7 +23,9 @@ fn init_log() { fn parse(python_source: &str) -> Tree { init_log(); let mut parser = Parser::new(); - parser.set_language(tree_sitter_python::language()).unwrap(); + parser + .set_language(&tree_sitter_python::LANGUAGE.into()) + .unwrap(); parser.parse(python_source, None).unwrap() } diff --git a/tests/it/parser.rs b/tests/it/parser.rs index cc067a18..23d1b83a 100644 --- a/tests/it/parser.rs +++ b/tests/it/parser.rs @@ -27,7 +27,8 @@ fn can_parse_blocks() { set @cap2.var1 = loc1 } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let loc1 = Identifier::from("loc1"); let precedence = Identifier::from("precedence"); @@ -228,7 +229,8 @@ fn can_parse_literals() { let t = #true } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let f = Identifier::from("f"); let n = Identifier::from("n"); @@ -284,7 +286,8 @@ fn can_parse_strings() { let loc1 = "\"abc,\ndef\\" } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let loc1 = Identifier::from("loc1"); @@ -318,7 +321,8 @@ fn can_parse_lists() { let list3 = ["hello", "world",] } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let list1 = Identifier::from("list1"); let list2 = Identifier::from("list2"); @@ -395,7 +399,8 @@ fn can_parse_sets() { let set3 = {"hello", "world",} } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let set1 = Identifier::from("set1"); let set2 = Identifier::from("set2"); @@ -470,7 +475,8 @@ fn can_parse_print() { print "x =", 5 } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let statements = file .stanzas @@ -505,7 +511,7 @@ fn cannot_parse_nullable_regex() { node n } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -518,7 +524,8 @@ fn can_parse_star_capture() { print @stmts } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let stmts = Identifier::from("stmts"); @@ -553,7 +560,8 @@ fn can_parse_star_multiple_capture() { print @stmts } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let stmt = Identifier::from("stmt"); let stmts = Identifier::from("stmts"); @@ -602,7 +610,8 @@ fn can_parse_plus_capture() { print @stmts } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let stmts = Identifier::from("stmts"); @@ -636,7 +645,8 @@ fn can_parse_optional_capture() { print @stmt } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let stmt = Identifier::from("stmt"); @@ -670,7 +680,8 @@ fn can_parse_parent_optional_capture() { print @stmt } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let stmt = Identifier::from("stmt"); @@ -704,7 +715,8 @@ fn can_parse_alternative_capture() { print @stmt } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let stmt = Identifier::from("stmt"); @@ -738,7 +750,8 @@ fn can_parse_nested_plus_and_optional_capture() { print @stmt } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let stmt = Identifier::from("stmt"); @@ -774,7 +787,8 @@ fn can_parse_if() { } } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let x = Identifier::from("x"); @@ -826,7 +840,8 @@ fn can_parse_if_elif() { } } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let x = Identifier::from("x"); @@ -903,7 +918,8 @@ fn can_parse_if_else() { } } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let x = Identifier::from("x"); @@ -967,7 +983,7 @@ fn cannot_parse_if_some_list_capture() { } } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -982,7 +998,8 @@ fn can_parse_for_in() { } } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let xs = Identifier::from("xs"); let x = Identifier::from("x"); @@ -1032,7 +1049,7 @@ fn cannot_parse_for_in_optional_capture() { } } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -1051,7 +1068,7 @@ fn cannot_parse_scan_of_nonlocal_call_expression() { } } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -1071,7 +1088,7 @@ fn cannot_parse_scan_of_nonlocal_variable() { } } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -1084,7 +1101,8 @@ fn can_parse_list_comprehension() { print [ (named-child-index x) for x in @xs ] } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let statements = file .stanzas @@ -1137,7 +1155,8 @@ fn can_parse_set_comprehension() { print { (named-child-index x) for x in @xs } } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let statements = file .stanzas @@ -1192,7 +1211,8 @@ fn can_parse_global() { edge n -> root } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); assert_eq!( file.globals, @@ -1248,7 +1268,8 @@ fn can_parse_global_with_default() { print PKG_NAME } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); assert_eq!( file.globals, @@ -1287,7 +1308,7 @@ fn cannot_parse_undeclared_global() { edge n -> root } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -1304,7 +1325,8 @@ fn can_parse_list_global() { } } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); assert_eq!( file.globals, @@ -1377,7 +1399,8 @@ fn can_parse_optional_global() { } } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); assert_eq!( file.globals, @@ -1448,7 +1471,7 @@ fn cannot_parse_global_with_unknown_quantifier() { node root } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -1462,7 +1485,7 @@ fn cannot_parse_hiding_global() { node root } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -1476,7 +1499,7 @@ fn cannot_parse_set_global() { set root = #null } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -1490,7 +1513,8 @@ fn can_parse_shorthand() { attr (n) sh = @name } "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("Cannot parse file"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("Cannot parse file"); let shorthands = file.shorthands.into_iter().collect::>(); assert_eq!( @@ -1536,7 +1560,7 @@ fn cannot_parse_multiple_patterns() { { } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -1548,7 +1572,7 @@ fn query_parse_errors_have_file_location() { (module (non_existing_node)) {} "#; - let err = match File::from_str(tree_sitter_python::language(), source) { + let err = match File::from_str(tree_sitter_python::LANGUAGE.into(), source) { Ok(_) => panic!("Parse succeeded unexpectedly"), Err(ParseError::QueryError(e)) => e, Err(e) => panic!("Unexpected error: {}", e), @@ -1570,7 +1594,7 @@ fn multiline_query_parse_errors_have_file_location() { ] {} "#; - let err = match File::from_str(tree_sitter_python::language(), source) { + let err = match File::from_str(tree_sitter_python::LANGUAGE.into(), source) { Ok(_) => panic!("Parse succeeded unexpectedly"), Err(ParseError::QueryError(e)) => e, Err(e) => panic!("Unexpected error: {}", e), @@ -1586,7 +1610,7 @@ fn cannot_parse_unused_capture() { (function_definition name: (identifier) @name) { } "#; - if let Ok(_) = File::from_str(tree_sitter_python::language(), source) { + if let Ok(_) = File::from_str(tree_sitter_python::LANGUAGE.into(), source) { panic!("Parse succeeded unexpectedly"); } } @@ -1597,7 +1621,7 @@ fn can_parse_explicitly_unused_capture() { (function_definition name: (identifier) @_name) { } "#; - File::from_str(tree_sitter_python::language(), source).expect("parse to succeed"); + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("parse to succeed"); } #[test] @@ -1605,6 +1629,7 @@ fn can_parse_inherit_directives() { let source = r#" inherit .scope "#; - let file = File::from_str(tree_sitter_python::language(), source).expect("parse to succeed"); + let file = + File::from_str(tree_sitter_python::LANGUAGE.into(), source).expect("parse to succeed"); assert!(file.inherited_variables.contains("scope".into())); } From 45e022a9b0f1e4cc0e835578fa88589885f00d65 Mon Sep 17 00:00:00 2001 From: Hendrik van Antwerpen Date: Mon, 9 Dec 2024 16:11:46 +0100 Subject: [PATCH 2/4] Remove unused dependency --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index cca628f6..0fe616cd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,6 @@ serde = "1.0" serde_json = "1.0" smallvec = { version="1.6", features=["union"] } streaming-iterator = "0.1.9" -string-interner = { version = "0.12", default-features = false, features = ["std", "inline-more", "backends"] } thiserror = "1.0.7" tree-sitter = "0.24" tree-sitter-config = { version = "0.24", optional = true } From 5e6616dcbd508c08e914a539b88bfc765da92d95 Mon Sep 17 00:00:00 2001 From: Hendrik van Antwerpen Date: Mon, 9 Dec 2024 16:25:11 +0100 Subject: [PATCH 3/4] Bump versions and update changelogs --- CHANGELOG.md | 4 ++++ Cargo.toml | 2 +- README.md | 2 +- vscode/CHANGELOG.md | 6 ++++++ vscode/package.json | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db9e8208..7948ab60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## v0.12.0 -- 2024-12-09 + +Upgraded the `tree-sitter` dependency to version 0.24. + ## v0.11.3 -- 2024-05-29 ### Library diff --git a/Cargo.toml b/Cargo.toml index 0fe616cd..2d56b226 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "tree-sitter-graph" -version = "0.11.3" +version = "0.12.0" description = "Construct graphs from parsed source code" homepage = "https://github.com/tree-sitter/tree-sitter-graph/" repository = "https://github.com/tree-sitter/tree-sitter-graph/" diff --git a/README.md b/README.md index 965bdf60..11d0a806 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ To use it as a library, add the following to your `Cargo.toml`: ``` toml [dependencies] -tree-sitter-graph = "0.11" +tree-sitter-graph = "0.12" ``` To use it as a program, install it via `cargo install`: diff --git a/vscode/CHANGELOG.md b/vscode/CHANGELOG.md index 85bc849d..387a6378 100644 --- a/vscode/CHANGELOG.md +++ b/vscode/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.1.2 -- 2023-12-09 + +### Added + +- Add missing `else` keyword + ## 0.1.1 -- 2023-06-01 ### Added diff --git a/vscode/package.json b/vscode/package.json index 36e2faef..2d2bb11d 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -1,6 +1,6 @@ { "name": "tree-sitter-graph", - "version": "0.1.1", + "version": "0.1.2", "publisher": "tree-sitter", "engines": { "vscode": "^1.60.0" From 7e29a92f5e3849ea06a4ddf88057c1063637d2f6 Mon Sep 17 00:00:00 2001 From: Hendrik van Antwerpen Date: Wed, 11 Dec 2024 19:09:52 +0100 Subject: [PATCH 4/4] Update release dates --- CHANGELOG.md | 2 +- vscode/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7948ab60..020f9737 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## v0.12.0 -- 2024-12-09 +## v0.12.0 -- 2024-12-12 Upgraded the `tree-sitter` dependency to version 0.24. diff --git a/vscode/CHANGELOG.md b/vscode/CHANGELOG.md index 387a6378..1a4cdeca 100644 --- a/vscode/CHANGELOG.md +++ b/vscode/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## 0.1.2 -- 2023-12-09 +## 0.1.2 -- 2023-12-12 ### Added