feat: add the semantic version to TSLanguage, and expose an API for retrieving it
This commit is contained in:
parent
f0222107b8
commit
8bb1448a6f
24 changed files with 371 additions and 77 deletions
|
|
@ -180,6 +180,14 @@ pub struct TSQueryCursorOptions {
|
|||
pub progress_callback:
|
||||
::core::option::Option<unsafe extern "C" fn(state: *mut TSQueryCursorState) -> bool>,
|
||||
}
|
||||
#[doc = " The metadata associated with a language.\n\n Currently, this metadata can be used to check the [Semantic Version](https://semver.org/)\n of the language. This version information should be used to signal if a given parser might\n be incompatible with existing queries when upgrading between major versions, or minor versions\n if it's in zerover."]
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct TSLanguageMetadata {
|
||||
pub major_version: u8,
|
||||
pub minor_version: u8,
|
||||
pub patch_version: u8,
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Create a new parser."]
|
||||
pub fn ts_parser_new() -> *mut TSParser;
|
||||
|
|
@ -193,7 +201,7 @@ extern "C" {
|
|||
pub fn ts_parser_language(self_: *const TSParser) -> *const TSLanguage;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Set the language that the parser should use for parsing.\n\n Returns a boolean indicating whether or not the language was successfully\n assigned. True means assignment succeeded. False means there was a version\n mismatch: the language was generated with an incompatible version of the\n Tree-sitter CLI. Check the language's version using [`ts_language_version`]\n and compare it to this library's [`TREE_SITTER_LANGUAGE_VERSION`] and\n [`TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION`] constants."]
|
||||
#[doc = " Set the language that the parser should use for parsing.\n\n Returns a boolean indicating whether or not the language was successfully\n assigned. True means assignment succeeded. False means there was a version\n mismatch: the language was generated with an incompatible version of the\n Tree-sitter CLI. Check the language's ABI version using [`ts_language_abi_version`]\n and compare it to this library's [`TREE_SITTER_LANGUAGE_VERSION`] and\n [`TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION`] constants."]
|
||||
pub fn ts_parser_set_language(self_: *mut TSParser, language: *const TSLanguage) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
|
|
@ -807,9 +815,17 @@ extern "C" {
|
|||
pub fn ts_language_symbol_type(self_: *const TSLanguage, symbol: TSSymbol) -> TSSymbolType;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the ABI version number for this language. This version number is used\n to ensure that languages were generated by a compatible version of\n Tree-sitter.\n\n See also [`ts_parser_set_language`]."]
|
||||
#[doc = " @deprecated use [`ts_language_abi_version`] instead, this will be removed in 0.26.\n\n Get the ABI version number for this language. This version number is used\n to ensure that languages were generated by a compatible version of\n Tree-sitter.\n\n See also [`ts_parser_set_language`]."]
|
||||
pub fn ts_language_version(self_: *const TSLanguage) -> u32;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the ABI version number for this language. This version number is used\n to ensure that languages were generated by a compatible version of\n Tree-sitter.\n\n See also [`ts_parser_set_language`]."]
|
||||
pub fn ts_language_abi_version(self_: *const TSLanguage) -> u32;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the metadata for this language. This information is generated by the\n CLI, and relies on the language author providing the correct metadata in\n the language's `tree-sitter.json` file.\n\n See also [`TSMetadata`]."]
|
||||
pub fn ts_language_metadata(self_: *const TSLanguage) -> *const TSLanguageMetadata;
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Get the next parse state. Combine this with lookahead iterators to generate\n completion suggestions or valid symbols in error nodes. Use\n [`ts_node_grammar_symbol`] for valid symbols."]
|
||||
pub fn ts_language_next_state(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue