From 64996976f4838b1a0a50d3e3ff368a929bbb6fc8 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 29 Jan 2020 16:48:08 -0800 Subject: [PATCH] rust: Add Language::id_for_node_kind method --- lib/binding_rust/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index fb7af075..daa3b45b 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -182,6 +182,18 @@ impl Language { .unwrap() } + /// Get the numeric id for the given node kind. + pub fn id_for_node_kind(&self, kind: &str, named: bool) -> u16 { + unsafe { + ffi::ts_language_symbol_for_name( + self.0, + kind.as_bytes().as_ptr() as *const c_char, + kind.len() as u32, + named, + ) + } + } + /// Check if the node type for the given numerical id is named (as opposed /// to an anonymous node type). pub fn node_kind_is_named(&self, id: u16) -> bool {