Skip to content

Access node location in visitor #1706

Answered by bd82
medihack asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @medihack

The CST Visitor APIs need rework: #1039

You could try overriding the visit method and save a reference to the current cstNode before it's visitor
get executed.

visit: function (cstNode: CstNode | CstNode[], param: any) {
// enables writing more concise visitor methods when CstNode has only a single child
if (isArray(cstNode)) {
// A CST Node's children dictionary can never have empty arrays as values
// If a key is defined there will be at least one element in the corresponding value array.
cstNode = cstNode[0]
}
// enables passing optio…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@medihack
Comment options

Answer selected by medihack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants