From 142f4b6438deeee48a6f3cd787466921869a63ab Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sun, 21 Nov 2021 11:37:52 -0800 Subject: [PATCH] Rename Query::step_is_definite -> is_pattern_guaranteed_at_step --- cli/src/tests/query_test.rs | 2 +- lib/binding_rust/bindings.rs | 4 ++-- lib/binding_rust/lib.rs | 6 ++++-- lib/include/tree_sitter/api.h | 2 +- lib/src/query.c | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cli/src/tests/query_test.rs b/cli/src/tests/query_test.rs index d552d422..44ce3229 100644 --- a/cli/src/tests/query_test.rs +++ b/cli/src/tests/query_test.rs @@ -3786,7 +3786,7 @@ fn test_query_is_pattern_guaranteed_at_step() { for (substring, is_definite) in row.results_by_substring { let offset = row.pattern.find(substring).unwrap(); assert_eq!( - query.step_is_definite(offset), + query.is_pattern_guaranteed_at_step(offset), *is_definite, "Description: {}, Pattern: {:?}, substring: {:?}, expected is_definite to be {}", row.description, diff --git a/lib/binding_rust/bindings.rs b/lib/binding_rust/bindings.rs index 91b55708..171b9a52 100644 --- a/lib/binding_rust/bindings.rs +++ b/lib/binding_rust/bindings.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.58.1 */ +/* automatically generated by rust-bindgen 0.59.1 */ pub type __darwin_size_t = ::std::os::raw::c_ulong; pub type FILE = [u64; 19usize]; @@ -659,7 +659,7 @@ extern "C" { ) -> *const TSQueryPredicateStep; } extern "C" { - pub fn ts_query_step_is_definite(self_: *const TSQuery, byte_offset: u32) -> bool; + pub fn ts_query_is_pattern_guaranteed_at_step(self_: *const TSQuery, byte_offset: u32) -> bool; } extern "C" { #[doc = " Get the name and length of one of the query's captures, or one of the"] diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index 92ba4d1b..366959c8 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -1586,8 +1586,10 @@ impl Query { /// /// A query step is 'definite' if its parent pattern will be guaranteed to match /// successfully once it reaches the step. - pub fn step_is_definite(&self, byte_offset: usize) -> bool { - unsafe { ffi::ts_query_step_is_definite(self.ptr.as_ptr(), byte_offset as u32) } + pub fn is_pattern_guaranteed_at_step(&self, byte_offset: usize) -> bool { + unsafe { + ffi::ts_query_is_pattern_guaranteed_at_step(self.ptr.as_ptr(), byte_offset as u32) + } } fn parse_property( diff --git a/lib/include/tree_sitter/api.h b/lib/include/tree_sitter/api.h index 7168faec..66ceaea1 100644 --- a/lib/include/tree_sitter/api.h +++ b/lib/include/tree_sitter/api.h @@ -725,7 +725,7 @@ const TSQueryPredicateStep *ts_query_predicates_for_pattern( uint32_t *length ); -bool ts_query_step_is_definite( +bool ts_query_is_pattern_guaranteed_at_step( const TSQuery *self, uint32_t byte_offset ); diff --git a/lib/src/query.c b/lib/src/query.c index 66d377de..b573143c 100644 --- a/lib/src/query.c +++ b/lib/src/query.c @@ -2269,7 +2269,7 @@ uint32_t ts_query_start_byte_for_pattern( return self->patterns.contents[pattern_index].start_byte; } -bool ts_query_step_is_definite( +bool ts_query_is_pattern_guaranteed_at_step( const TSQuery *self, uint32_t byte_offset ) {