Skip to content

Commit ddc2909

Browse files
authored
bindings: Add Node::is_extra (#19)
Co-authored-by: Rafael Oliveira <[email protected]>
1 parent 470b507 commit ddc2909

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

bindings/src/node.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ impl<'tree> Node<'tree> {
112112
unsafe { ts_node_is_missing(self.as_raw()) }
113113
}
114114

115+
/// Check if this node is *extra*.
116+
///
117+
/// Extra nodes represent things like comments, which are not required by the
118+
/// grammar, but can appear anywhere.
119+
#[inline]
120+
pub fn is_extra(&self) -> bool {
121+
unsafe { ts_node_is_extra(self.as_raw()) }
122+
}
123+
115124
/// Get the byte offsets where this node starts.
116125
#[inline(always)]
117126
pub fn start_byte(&self) -> u32 {
@@ -285,6 +294,12 @@ extern "C" {
285294
/// in order to recover from certain kinds of syntax errors
286295
fn ts_node_is_missing(node: NodeRaw) -> bool;
287296

297+
/// Check if this node is *extra*.
298+
///
299+
/// Extra nodes represent things like comments, which are not required by the
300+
/// grammar, but can appear anywhere.
301+
fn ts_node_is_extra(node: NodeRaw) -> bool;
302+
288303
/// Get the node's immediate parent
289304
fn ts_node_parent(node: NodeRaw) -> NodeRaw;
290305

0 commit comments

Comments
 (0)