bug: `statement` node is not selected in TSPlayground
harish-prakash opened this issue · comments
Did you check existing issues?
- I have read all the tree-sitter docs if it relates to using the parser
- I have searched the existing issues of tree-sitter-typescript
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version
)
No response
Describe the bug
I'm trying to capture every kind of statement using the statement
node but it fails.
I'm using the treesitter-playground from https://tree-sitter.github.io/tree-sitter/playground
Steps To Reproduce/Bad Parse Tree
Here is the sample code
import {One} from 'somewhere'
const five: number = 5
Here is the generated tree
program [0, 0] - [3, 0]
import_statement [0, 0] - [0, 29]
import_clause [0, 7] - [0, 12]
named_imports [0, 7] - [0, 12]
import_specifier [0, 8] - [0, 11]
name: identifier [0, 8] - [0, 11]
source: string [0, 18] - [0, 29]
string_fragment [0, 19] - [0, 28]
lexical_declaration [2, 0] - [2, 22]
variable_declarator [2, 6] - [2, 22]
name: identifier [2, 6] - [2, 10]
type: type_annotation [2, 10] - [2, 18]
predefined_type [2, 12] - [2, 18]
value: number [2, 21] - [2, 22]
I'm trying to query it with
(statement) @something
Expected Behavior/Parse Tree
I expect it to highlight the import_statement
and the lexical_declaration
nodes because of the parser definition in tree-sitter-javascript/.../node-types.json (which is imported in typescript parser)
Unfortunately, it does not. However, when I use (declaration) @something
, then it highlights the lexical_declaration
node and when I use (import_statement) @something
then it highlights the import_statement
node.
Repro
No response
It's a supertype, they're hidden just like if you were to prepend a rule name with an underscore: https://tree-sitter.github.io/tree-sitter/creating-parsers#the-grammar-dsl
You're right, I was thinking about inlined rules in the context of a query, since statement is also inlined, which is weird an doesn't make sense. I'll un-inline it and update this grammar as well