[STAL-2005] Update the javascript grammar #343
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem are you trying to solve?
Being able to query for supertypes in the JS grammar, namely the statement node, so that we don't have to write an alternation of several possible child nodes of the statement node. This will help with the ESLint rule implementations
What is your solution?
In tree-sitter-javascript, the
statement
node was inlined as well as being a supertype, which doesn't make a lot of sense since inlining it will make it unqueryable. Supertyping a node has a similar effect that inlining does where a node is not present in the syntax tree, but it can still be queried for. This is especially useful in cases where the supertype contains a choice of children, such as thestatement
node,expression
node, and others. Removingstatement
from the inline list in the grammar allows us to query for it again.Alternatives considered
Hacky workaround with alternations (not fun)
What the reviewer should know
This just updates the JS grammar, however, I will update the TS/TSX grammar later today for this change as well. I also removed the cpp field since upstream has deprecated c++ scanners and no maintained grammar uses them anymore