This PR introduces changes that make it easier to process the resulting syntax tree when writing queries.
Changes
Introduce named fields in many places. Most of the changes involve introducing field names. As much as possible existing naming conventions were followed.
Introduce separate productions for class and interface extension. The single production for extends tried to capture extension syntax for both classes and interfaces. However, these are quite different. Class extension takes expressions, possibly with added type arguments, while interface extension takes type references. This could result in confusing syntax trees when in class extension on a name (class A extends B), the name B was treated as a type reference, but had to be interpreted as an expression reference. The extends_clause for classes kept its original name, and now accepts arbitrary expressions, while a new extends_type_clause is used for interfaces. This is a breaking change.
Alias this to this_type when used in type positions. The this production was used both in expression and type positions, making it hard to write a general query for it without having to include the possible contexts where that query is relevant. This is a breaking change.
Use npm run to run tree-sitter in build, instead of relying on local install. The build steps in package.json would run the local tree-sitter command, even though it depends on a specific version that is installed by npm. This change uses the version from the dependencies instead.
Checklist
[ ] All tests pass in CI.
[ ] There are sufficient tests for the new fix/feature.
[ ] Grammar rules have not been renamed unless absolutely necessary.
[ ] The conflicts section hasn't grown too much.
[ ] The parser size hasn't grown too much (check the value of STATE_COUNT in src/parser.c).
This PR introduces changes that make it easier to process the resulting syntax tree when writing queries.
Changes
Introduce named fields in many places. Most of the changes involve introducing field names. As much as possible existing naming conventions were followed.
Introduce separate productions for class and interface extension. The single production for
extends
tried to capture extension syntax for both classes and interfaces. However, these are quite different. Class extension takes expressions, possibly with added type arguments, while interface extension takes type references. This could result in confusing syntax trees when in class extension on a name (class A extends B
), the nameB
was treated as a type reference, but had to be interpreted as an expression reference. Theextends_clause
for classes kept its original name, and now accepts arbitrary expressions, while a newextends_type_clause
is used for interfaces. This is a breaking change.Alias
this
tothis_type
when used in type positions. Thethis
production was used both in expression and type positions, making it hard to write a general query for it without having to include the possible contexts where that query is relevant. This is a breaking change.Use
npm run
to run tree-sitter in build, instead of relying on local install. The build steps inpackage.json
would run the localtree-sitter
command, even though it depends on a specific version that is installed bynpm
. This change uses the version from the dependencies instead.Checklist