Handle rename symbols in ts_language APIs
This commit is contained in:
parent
20b664969e
commit
afb499bf2e
6 changed files with 84 additions and 11 deletions
|
|
@ -32,7 +32,7 @@ void ts_language_table_entry(const TSLanguage *self, TSStateId state,
|
|||
}
|
||||
|
||||
uint32_t ts_language_symbol_count(const TSLanguage *language) {
|
||||
return language->symbol_count;
|
||||
return language->symbol_count + language->rename_symbol_count;
|
||||
}
|
||||
|
||||
uint32_t ts_language_version(const TSLanguage *language) {
|
||||
|
|
@ -41,19 +41,21 @@ uint32_t ts_language_version(const TSLanguage *language) {
|
|||
|
||||
TSSymbolMetadata ts_language_symbol_metadata(const TSLanguage *language,
|
||||
TSSymbol symbol) {
|
||||
if (symbol == ts_builtin_sym_error)
|
||||
if (symbol == ts_builtin_sym_error) {
|
||||
return (TSSymbolMetadata){
|
||||
.visible = true, .named = true, .extra = false, .structural = true,
|
||||
};
|
||||
else
|
||||
} else {
|
||||
return language->symbol_metadata[symbol];
|
||||
}
|
||||
}
|
||||
|
||||
const char *ts_language_symbol_name(const TSLanguage *language, TSSymbol symbol) {
|
||||
if (symbol == ts_builtin_sym_error)
|
||||
if (symbol == ts_builtin_sym_error) {
|
||||
return "ERROR";
|
||||
else
|
||||
} else {
|
||||
return language->symbol_names[symbol];
|
||||
}
|
||||
}
|
||||
|
||||
TSSymbolType ts_language_symbol_type(const TSLanguage *language, TSSymbol symbol) {
|
||||
|
|
|
|||
|
|
@ -264,7 +264,8 @@ TSPoint ts_node_end_point(TSNode self) {
|
|||
}
|
||||
|
||||
TSSymbol ts_node_symbol(TSNode self) {
|
||||
return ts_node__tree(self)->symbol;
|
||||
const Tree *tree = ts_node__tree(self);
|
||||
return tree->context.rename_symbol ? tree->context.rename_symbol : tree->symbol;
|
||||
}
|
||||
|
||||
TSSymbolIterator ts_node_symbols(TSNode self) {
|
||||
|
|
@ -288,9 +289,7 @@ void ts_symbol_iterator_next(TSSymbolIterator *self) {
|
|||
}
|
||||
|
||||
const char *ts_node_type(TSNode self, const TSDocument *document) {
|
||||
const Tree *tree = ts_node__tree(self);
|
||||
TSSymbol symbol = tree->context.rename_symbol ? tree->context.rename_symbol : tree->symbol;
|
||||
return ts_language_symbol_name(document->parser.language, symbol);
|
||||
return ts_language_symbol_name(document->parser.language, ts_node_symbol(self));
|
||||
}
|
||||
|
||||
char *ts_node_string(TSNode self, const TSDocument *document) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue