-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query (_ . (name) @firstChild)
captures every name
node
#2869
Comments
(_ . (name) @firstChild)
captures every name
node(_ . (name) @firstChild)
captures every name
node
this isn't actionable without a grammar to go along with your query reproducer |
go to https://tree-sitter.github.io/tree-sitter/playground change |
fixing tree-sitter#2869 by restricting pattern_map optimization in ts_query_new() i.e. do not select a second step which is immediate
fixing tree-sitter#2869 by restricting pattern_map optimization in ts_query_new() i.e. do not select a second step which is immediate
Fixed by #3440 |
The query
(_ . (_) @firstChild)
will correctly capture the first child of every named nodereturns:
function_definition
and the firstidentifier
✅however if you specify a node name inside of
(_)
, the query will instead capture every single node of that nameregardless of if its the first named node or not
(_ . (identifier) @everyChild)
returns:
function_definition
and every singleidentifier
❌specifying the parent name does work correctly:
(function_definition . (identifier) @firstChild)
returns: the first
identifier
✅https://github.com/tree-sitter/tree-sitter/blob/master/docs/section-2-using-parsers.md#anchors
https://github.com/tree-sitter/tree-sitter/blob/master/docs/section-2-using-parsers.md#wildcard-node
The text was updated successfully, but these errors were encountered: