From 1ac134a97dfb58df8b9767f5ca9de65d5570630f Mon Sep 17 00:00:00 2001 From: Andrew Hlynskyi Date: Wed, 2 Aug 2023 00:27:19 +0300 Subject: [PATCH] Apply `ts_node_is_error` in Rust binding --- lib/binding_rust/lib.rs | 3 ++- lib/src/node.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index e8d99a87..2e3403b4 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -942,8 +942,9 @@ impl<'tree> Node<'tree> { /// /// Syntax errors represent parts of the code that could not be incorporated into a /// valid syntax tree. + #[doc(alias = "ts_node_is_error")] pub fn is_error(&self) -> bool { - self.kind_id() == u16::MAX + unsafe { ffi::ts_node_is_error(self.0) } } /// Get this node's parse state. diff --git a/lib/src/node.c b/lib/src/node.c index 46028f37..092e96f8 100644 --- a/lib/src/node.c +++ b/lib/src/node.c @@ -473,15 +473,15 @@ bool ts_node_has_error(TSNode self) { return ts_subtree_error_cost(ts_node__subtree(self)) > 0; } -uint32_t ts_node_descendant_count(TSNode self) { - return ts_subtree_visible_descendant_count(ts_node__subtree(self)) + 1; -} - bool ts_node_is_error(TSNode self) { TSSymbol symbol = ts_node_symbol(self); return symbol == ts_builtin_sym_error; } +uint32_t ts_node_descendant_count(TSNode self) { + return ts_subtree_visible_descendant_count(ts_node__subtree(self)) + 1; +} + TSStateId ts_node_parse_state(TSNode self) { return ts_subtree_parse_state(ts_node__subtree(self)); }