fix: deprecate child_containing_descendant and add child_with_descendant instead
This commit is contained in:
parent
2e3504a422
commit
934a2814fd
5 changed files with 91 additions and 30 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* automatically generated by rust-bindgen 0.70.0 */
|
||||
/* automatically generated by rust-bindgen 0.70.1 */
|
||||
|
||||
pub const TREE_SITTER_LANGUAGE_VERSION: u32 = 14;
|
||||
pub const TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION: u32 = 13;
|
||||
|
|
@ -359,9 +359,13 @@ extern "C" {
|
|||
pub fn ts_node_parent(self_: TSNode) -> TSNode;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the node's child that contains `descendant`."]
|
||||
#[doc = " @deprecated use [`ts_node_contains_descendant`] instead, this will be removed in 0.25\n\n Get the node's child containing `descendant`. This will not return\n the descendant if it is a direct child of `self`, for that use\n `ts_node_contains_descendant`."]
|
||||
pub fn ts_node_child_containing_descendant(self_: TSNode, descendant: TSNode) -> TSNode;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the node that contains `descendant`.\n\n Note that this can return `descendant` itself, unlike the deprecated function\n [`ts_node_child_containing_descendant`]."]
|
||||
pub fn ts_node_child_with_descendant(self_: TSNode, descendant: TSNode) -> TSNode;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the node's child at the given index, where zero represents the first\n child."]
|
||||
pub fn ts_node_child(self_: TSNode, child_index: u32) -> TSNode;
|
||||
|
|
|
|||
|
|
@ -1359,13 +1359,26 @@ impl<'tree> Node<'tree> {
|
|||
Self::new(unsafe { ffi::ts_node_parent(self.0) })
|
||||
}
|
||||
|
||||
/// Get this node's child that contains `descendant`.
|
||||
/// Get this node's child containing `descendant`. This will not return
|
||||
/// the descendant if it is a direct child of `self`, for that use
|
||||
/// [`Node::child_contains_descendant`].
|
||||
#[doc(alias = "ts_node_child_containing_descendant")]
|
||||
#[must_use]
|
||||
#[deprecated(since = "0.24.0", note = "Prefer child_with_descendant instead")]
|
||||
pub fn child_containing_descendant(&self, descendant: Self) -> Option<Self> {
|
||||
Self::new(unsafe { ffi::ts_node_child_containing_descendant(self.0, descendant.0) })
|
||||
}
|
||||
|
||||
/// Get the node that contains `descendant`.
|
||||
///
|
||||
/// Note that this can return `descendant` itself, unlike the deprecated function
|
||||
/// [`Node::child_containing_descendant`].
|
||||
#[doc(alias = "ts_node_child_with_descendant")]
|
||||
#[must_use]
|
||||
pub fn child_with_descendant(&self, descendant: Self) -> Option<Self> {
|
||||
Self::new(unsafe { ffi::ts_node_child_with_descendant(self.0, descendant.0) })
|
||||
}
|
||||
|
||||
/// Get this node's next sibling.
|
||||
#[doc(alias = "ts_node_next_sibling")]
|
||||
#[must_use]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue