One more question. How do I get the new source string? Because if I use #sourceCode I get old code, if I use #printString it also puts extra parenthesis. Uko
On 07 Apr 2015, at 17:39, Thierry Goubier <thierry.goubier@gmail.com> wrote:
Le 07/04/2015 17:24, Marcus Denker a écrit :
On 07 Apr 2015, at 17:20, Yuriy Tymchuk <yuriy.tymchuk@me.com> wrote:
Hi, I need to change source code of a method by for example adding a pragma. Can I just manipulate itâs AST without carrying about source code anchors? Because it seems that I have to set from/to values and it looks painful.
I would do the change, print the code and recompile it⦠not nice, but for now the easiest.
I conccur with Marcus. It's good enough; RB works this way.
Note that you can change the AST without bothering with the from/to stuff, in most cases (except syntax errors messages?).
(this way they old AST gets garbage collected and the new one has all the offsets into the text correct).
It's a lot easier than trying to shift the offsets depending on what you have added/not added.
I would like to explore if we canât build a system where everything we manipulate is ASTsâ¦
You're the compiler guy: everything is an AST :)
Thierry