Replies: 3 comments 3 replies
-
Since the root node was |
Beta Was this translation helpful? Give feedback.
-
According to the python grammar, |
Beta Was this translation helpful? Give feedback.
-
This is an interesting use case that I hand't thought of, and I think it would be possible to add support for it. What I would probably do, is add a new concept of a "max depth" for a query cursor. Currently, you can already place bounds on the query by setting a byte range or a row/column range on the query cursor. This would extend that so you could bound the depth. At the C API level, we'd add a method I'm not sure about the WASM API. I think we'd need to add an additional optional argument to |
Beta Was this translation helpful? Give feedback.
-
I'm having a hard time figuring out how to do this with the query language. For example if I want to only match top level imports in a python file, I would like to match all the nodes that are
future_import_statement
,import_statement
orimport_from_statement
but only the ones that are direct children of the root node. So that when I doqueryObj.matches(rootNode)
I am able to get those directly without filtering it out later.Is there an easy way to do that? For example I saw that there is an
#eq?
and tried:((import_statement) @import) (#eq? @import.parent.parent null)
(which should capture the done calling it an@import
and I tried to get only the root node direct children by checking for.parent.parent
but that didn't work.Beta Was this translation helpful? Give feedback.
All reactions