Is there a way to update the trivia of the first token of an arbitrary (non-const) syntax node ? #898
-
Hi everyone ! In my effort of making a slang-based formatter, I stumble quite frequently on an issue that seems easy to handle but cause me quite a lot of trouble. I do have a function, let's call it The result is that I virtually need to handle the specificity of each available kind of syntax node to set the new token appropriately. As far as I know, the only way to access this first token on a generic Therefore, my question is: Is there a generic way to change(/update) the trivia of the first token of an arbitrary |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
There is not currently, but it's doable to add a childToken() overload (and perhaps corresponding overloads for getFirst / getLast) that returns a mutable reference for non-const syntax nodes. In general I don't add methods until there's a use for them, so the fact that they're missing doesn't necessarily mean it was a design intention. I'm happy to accept a PR if you want to add it, or you can wait until I get around to it. |
Beta Was this translation helpful? Give feedback.
There is not currently, but it's doable to add a childToken() overload (and perhaps corresponding overloads for getFirst / getLast) that returns a mutable reference for non-const syntax nodes. In general I don't add methods until there's a use for them, so the fact that they're missing doesn't necessarily mean it was a design intention. I'm happy to accept a PR if you want to add it, or you can wait until I get around to it.