build: regenerate bindings.rs & add Language::name

This commit is contained in:
Amaan Qureshi 2024-10-29 16:31:50 -04:00
parent ab306f543f
commit 55bda0a968
2 changed files with 12 additions and 0 deletions

View file

@ -760,6 +760,10 @@ extern "C" {
symbol: TSSymbol,
) -> TSStateId;
}
extern "C" {
#[doc = " Get the name of this language. This returns `NULL` in older parsers."]
pub fn ts_language_name(self_: *const TSLanguage) -> *const ::core::ffi::c_char;
}
extern "C" {
#[doc = " Create a new lookahead iterator for the given language and parse state.\n\n This returns `NULL` if state is invalid for the language.\n\n Repeatedly using [`ts_lookahead_iterator_next`] and\n [`ts_lookahead_iterator_current_symbol`] will generate valid symbols in the\n given parse state. Newly created lookahead iterators will contain the `ERROR`\n symbol.\n\n Lookahead iterators can be useful to generate suggestions and improve syntax\n error diagnostics. To get symbols valid in an ERROR node, use the lookahead\n iterator on its first leaf node state. For `MISSING` nodes, a lookahead\n iterator created on the previous non-extra leaf node may be appropriate."]
pub fn ts_lookahead_iterator_new(

View file

@ -301,6 +301,14 @@ impl Language {
Self(unsafe { builder.into_raw()().cast() })
}
/// Get the name of this language. This returns `None` in older parsers.
#[doc(alias = "ts_language_version")]
#[must_use]
pub fn name(&self) -> Option<&'static str> {
let ptr = unsafe { ffi::ts_language_name(self.0) };
(!ptr.is_null()).then(|| unsafe { CStr::from_ptr(ptr) }.to_str().unwrap())
}
/// Get the ABI version number that indicates which version of the
/// Tree-sitter CLI that was used to generate this [`Language`].
#[doc(alias = "ts_language_version")]