Add containing range APIs to query cursor
Co-authored-by: Kirill Bulatov <mail4score@gmail.com> Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: dino <dinojoaocosta@gmail.com> Co-authored-by: John Tur <john-tur@outlook.com> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: dino <dinojoaocosta@gmail.com> Co-authored-by: Will Lillis <will.lillis24@gmail.com>
This commit is contained in:
parent
7d3feeae9a
commit
c0b1710f8a
13 changed files with 420 additions and 34 deletions
|
|
@ -712,6 +712,22 @@ extern "C" {
|
|||
end_point: TSPoint,
|
||||
) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Set the byte range within which all matches must be fully contained.\n\n Set the range of bytes in which matches will be searched for. In contrast to\n `ts_query_cursor_set_byte_range`, this will restrict the query cursor to only return\n matches where _all_ nodes are _fully_ contained within the given range. Both functions\n can be used together, e.g. to search for any matches that intersect line 5000, as\n long as they are fully contained within lines 4500-5500"]
|
||||
pub fn ts_query_cursor_set_containing_byte_range(
|
||||
self_: *mut TSQueryCursor,
|
||||
start_byte: u32,
|
||||
end_byte: u32,
|
||||
) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Set the point range within which all matches must be fully contained.\n\n Set the range of bytes in which matches will be searched for. In contrast to\n `ts_query_cursor_set_point_range`, this will restrict the query cursor to only return\n matches where _all_ nodes are _fully_ contained within the given range. Both functions\n can be used together, e.g. to search for any matches that intersect line 5000, as\n long as they are fully contained within lines 4500-5500"]
|
||||
pub fn ts_query_cursor_set_containing_point_range(
|
||||
self_: *mut TSQueryCursor,
|
||||
start_point: TSPoint,
|
||||
end_point: TSPoint,
|
||||
) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Advance to the next match of the currently running query.\n\n If there is a match, write it to `*match` and return `true`.\n Otherwise, return `false`."]
|
||||
pub fn ts_query_cursor_next_match(self_: *mut TSQueryCursor, match_: *mut TSQueryMatch)
|
||||
|
|
|
|||
|
|
@ -3181,6 +3181,44 @@ impl QueryCursor {
|
|||
self
|
||||
}
|
||||
|
||||
/// Set the byte range within which all matches must be fully contained.
|
||||
///
|
||||
/// Set the range of bytes in which matches will be searched for. In contrast to
|
||||
/// `ts_query_cursor_set_byte_range`, this will restrict the query cursor to only return
|
||||
/// matches where _all_ nodes are _fully_ contained within the given range. Both functions
|
||||
/// can be used together, e.g. to search for any matches that intersect line 5000, as
|
||||
/// long as they are fully contained within lines 4500-5500
|
||||
#[doc(alias = "ts_query_cursor_set_containing_byte_range")]
|
||||
pub fn set_containing_byte_range(&mut self, range: ops::Range<usize>) -> &mut Self {
|
||||
unsafe {
|
||||
ffi::ts_query_cursor_set_containing_byte_range(
|
||||
self.ptr.as_ptr(),
|
||||
range.start as u32,
|
||||
range.end as u32,
|
||||
);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the point range within which all matches must be fully contained.
|
||||
///
|
||||
/// Set the range of bytes in which matches will be searched for. In contrast to
|
||||
/// `ts_query_cursor_set_point_range`, this will restrict the query cursor to only return
|
||||
/// matches where _all_ nodes are _fully_ contained within the given range. Both functions
|
||||
/// can be used together, e.g. to search for any matches that intersect line 5000, as
|
||||
/// long as they are fully contained within lines 4500-5500
|
||||
#[doc(alias = "ts_query_cursor_set_containing_point_range")]
|
||||
pub fn set_containing_point_range(&mut self, range: ops::Range<Point>) -> &mut Self {
|
||||
unsafe {
|
||||
ffi::ts_query_cursor_set_containing_point_range(
|
||||
self.ptr.as_ptr(),
|
||||
range.start.into(),
|
||||
range.end.into(),
|
||||
);
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the maximum start depth for a query cursor.
|
||||
///
|
||||
/// This prevents cursors from exploring children nodes at a certain depth.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue