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
|
|
@ -42,6 +42,7 @@ typedef uint16_t TSStateId;
|
|||
typedef uint16_t TSSymbol;
|
||||
typedef uint16_t TSFieldId;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
typedef struct TSLanguageMetadata TSLanguageMetadata;
|
||||
typedef struct TSParser TSParser;
|
||||
typedef struct TSTree TSTree;
|
||||
typedef struct TSQuery TSQuery;
|
||||
|
|
@ -182,6 +183,20 @@ typedef struct TSQueryCursorOptions {
|
|||
bool (*progress_callback)(TSQueryCursorState *state);
|
||||
} TSQueryCursorOptions;
|
||||
|
||||
/**
|
||||
* The metadata associated with a language.
|
||||
*
|
||||
* Currently, this metadata can be used to check the [Semantic Version](https://semver.org/)
|
||||
* of the language. This version information should be used to signal if a given parser might
|
||||
* be incompatible with existing queries when upgrading between major versions, or minor versions
|
||||
* if it's in zerover.
|
||||
*/
|
||||
typedef struct TSLanguageMetadata {
|
||||
uint8_t major_version;
|
||||
uint8_t minor_version;
|
||||
uint8_t patch_version;
|
||||
} TSLanguageMetadata;
|
||||
|
||||
/********************/
|
||||
/* Section - Parser */
|
||||
/********************/
|
||||
|
|
@ -207,7 +222,7 @@ const TSLanguage *ts_parser_language(const TSParser *self);
|
|||
* Returns a boolean indicating whether or not the language was successfully
|
||||
* assigned. True means assignment succeeded. False means there was a version
|
||||
* mismatch: the language was generated with an incompatible version of the
|
||||
* Tree-sitter CLI. Check the language's version using [`ts_language_version`]
|
||||
* Tree-sitter CLI. Check the language's ABI version using [`ts_language_abi_version`]
|
||||
* and compare it to this library's [`TREE_SITTER_LANGUAGE_VERSION`] and
|
||||
* [`TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION`] constants.
|
||||
*/
|
||||
|
|
@ -1247,6 +1262,8 @@ const char *ts_language_symbol_name(const TSLanguage *self, TSSymbol symbol);
|
|||
TSSymbolType ts_language_symbol_type(const TSLanguage *self, TSSymbol symbol);
|
||||
|
||||
/**
|
||||
* @deprecated use [`ts_language_abi_version`] instead, this will be removed in 0.26.
|
||||
*
|
||||
* Get the ABI version number for this language. This version number is used
|
||||
* to ensure that languages were generated by a compatible version of
|
||||
* Tree-sitter.
|
||||
|
|
@ -1255,6 +1272,24 @@ TSSymbolType ts_language_symbol_type(const TSLanguage *self, TSSymbol symbol);
|
|||
*/
|
||||
uint32_t ts_language_version(const TSLanguage *self);
|
||||
|
||||
/**
|
||||
* Get the ABI version number for this language. This version number is used
|
||||
* to ensure that languages were generated by a compatible version of
|
||||
* Tree-sitter.
|
||||
*
|
||||
* See also [`ts_parser_set_language`].
|
||||
*/
|
||||
uint32_t ts_language_abi_version(const TSLanguage *self);
|
||||
|
||||
/**
|
||||
* Get the metadata for this language. This information is generated by the
|
||||
* CLI, and relies on the language author providing the correct metadata in
|
||||
* the language's `tree-sitter.json` file.
|
||||
*
|
||||
* See also [`TSMetadata`].
|
||||
*/
|
||||
const TSLanguageMetadata *ts_language_metadata(const TSLanguage *self);
|
||||
|
||||
/**
|
||||
* Get the next parse state. Combine this with lookahead iterators to generate
|
||||
* completion suggestions or valid symbols in error nodes. Use
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue