feat: add Supertype API
Introduces a new function that takes in a supertype symbol and returns all associated subtypes. Can be used by query.c to give better errors for invalid subtypes, as well as downstream applications like the query LSP to give better diagnostics.
This commit is contained in:
parent
07c08432ca
commit
19482834bd
11 changed files with 459 additions and 78 deletions
|
|
@ -1166,11 +1166,6 @@ uint32_t ts_language_symbol_count(const TSLanguage *self);
|
|||
*/
|
||||
uint32_t ts_language_state_count(const TSLanguage *self);
|
||||
|
||||
/**
|
||||
* Get a node type string for the given numerical id.
|
||||
*/
|
||||
const char *ts_language_symbol_name(const TSLanguage *self, TSSymbol symbol);
|
||||
|
||||
/**
|
||||
* Get the numerical id for the given node type string.
|
||||
*/
|
||||
|
|
@ -1196,6 +1191,27 @@ const char *ts_language_field_name_for_id(const TSLanguage *self, TSFieldId id);
|
|||
*/
|
||||
TSFieldId ts_language_field_id_for_name(const TSLanguage *self, const char *name, uint32_t name_length);
|
||||
|
||||
/**
|
||||
* Get a list of all supertype symbols for the language.
|
||||
*/
|
||||
const TSSymbol *ts_language_supertypes(const TSLanguage *self, uint32_t *length);
|
||||
|
||||
/**
|
||||
* Get a list of all subtype symbol ids for a given supertype symbol.
|
||||
*
|
||||
* See [`ts_language_supertypes`] for fetching all supertype symbols.
|
||||
*/
|
||||
const TSSymbol *ts_language_subtypes(
|
||||
const TSLanguage *self,
|
||||
TSSymbol supertype,
|
||||
uint32_t *length
|
||||
);
|
||||
|
||||
/**
|
||||
* Get a node type string for the given numerical id.
|
||||
*/
|
||||
const char *ts_language_symbol_name(const TSLanguage *self, TSSymbol symbol);
|
||||
|
||||
/**
|
||||
* Check whether the given node type id belongs to named nodes, anonymous nodes,
|
||||
* or a hidden nodes.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue