Skip to content

Commit

Permalink
Rename Query::step_is_definite -> is_pattern_guaranteed_at_step
Browse files Browse the repository at this point in the history
  • Loading branch information
maxbrunsfeld committed Nov 21, 2021
1 parent f69c486 commit 142f4b6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli/src/tests/query_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/binding_rust/bindings.rs
Original file line number Diff line number Diff line change
@@ -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];
Expand Down Expand Up @@ -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"]
Expand Down
6 changes: 4 additions & 2 deletions lib/binding_rust/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion lib/include/tree_sitter/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/query.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down

0 comments on commit 142f4b6

Please sign in to comment.