In my parser grammar, I have declared the following tokens: BeginHandlebarsExpression[closedBy="EndHandlebarsExpression"] { "{{" } EndHandlebarsExpression { "}}" }
I’m wondering if there’s any way that I can traverse quickly between the Begin and End syntax nodes that correspond to those tokens. Something like node.openedBy, much like how I use node.parent or node.prevSibling.
I can see a reference to the desired node’s name on node.type.props[0], but no direct handle for the node itself. Am I barking up the wrong tree?
Open/close relations are not directly tracked by the tree, and there are no accessors for them. The general approach would be to scan sibling nodes for a node of that type, possibly optimizing by only checking the first/last sibling if you know the structure of the parent node puts the delimiters at the start/end.