Syntax Tree manipulation #128
-
Hi how would I go about manipulating the syntax tree to add say: local x = 42 to local x = 42; and vice-versa? Note the only addition was a redundant I have tried var tree = LuaSyntaxTree.ParseText("local x = 42");
var root = tree.GetRoot();
var newToken = SyntaxFactory.Token(SyntaxKind.SemicolonToken);
var lastToken = root.GetLastToken();
var updatedRoot = root.InsertTokensAfter(lastToken, [newToken]); But the following stack trace is thrown
|
Beta Was this translation helpful? Give feedback.
Answered by
GGG-KILLER
Dec 23, 2024
Replies: 1 comment 2 replies
-
You'd have to get the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, the thing is, you can only add a token if it's part of the node's structure, you can't just generically add any token you want.