helix-mods/runtime/queries/ecma
woojiq 7cda5b8592
build(tree-sitter): update javascript, typescript and tsx (#7852)
* build(tree-sitter): update javascript, typescript and tsx

* update revision of tree-sitter parsers for these languages.
* rename `?.` to `optional_chain`, introduced in tree-sitter/tree-sitter-javascript@186f2adbf7.

* fix(highlight): change jsx queries to match latest tree-sitter

Latest tree-sitter/tree-sitter-javascript@bb1f97b643 added some breaking changes that broke highlighting.
* Remove some queries with `nested_identifier`.
* Remove deprecated `jsx_fragment` from indent query.
* Count `</` and `/>` as a single token.
2023-08-07 14:07:56 -05:00
..
highlights.scm build(tree-sitter): update javascript, typescript and tsx (#7852) 2023-08-07 14:07:56 -05:00
indents.scm Add switch_statement to ecma indents (#6369) 2023-03-21 17:13:32 -05:00
injections.scm Inherit javascript/typescript from common 'ecma' queries (#3301) 2022-08-03 14:09:44 +09:00
locals.scm Refactor queries for ecma based languages (#7207) 2023-07-09 18:35:32 +02:00
README.md Refactor queries for ecma based languages (#7207) 2023-07-09 18:35:32 +02:00
textobjects.scm Inherit javascript/typescript from common 'ecma' queries (#3301) 2022-08-03 14:09:44 +09:00

Inheritance model for ecma-based languages

Ecma-based languages share many traits. Because of this we want to share as many queries as possible while avoiding nested inheritance that can make query behaviour unpredictable due to unexpected precedence.

To achieve that, there are "public" and "private" versions for javascript, jsx, and typescript query files, that share the same name, but the "private" version name starts with an underscore (with the exception of ecma, that already exists as a sort of base "private" language). This allows the "private" versions to host the specific queries of the language excluding any ; inherits statement, in order to make them safe to be inherited by the "public" version of the same language and other languages as well. The tsx language doesn't have a "private" version given that currently it doesn't need to be inherited by other languages.

Language Inherits from
javascript _javascript, ecma
jsx _jsx, _javascript, ecma
typescript _typescript, ecma
tsx _jsx, _typescript, ecma

If you intend to add queries to any of the ecma-based languages above, make sure you add them to the correct private language they belong to, so that other languages down the line can benefit from them.