Am 08.03.2012 um 17:08 schrieb Sean P. DeNigris:

> 
> Marcus Denker-4 wrote
>> 
>> -> Compile the code to an RB AST, this then has all the interfaces needed
>> to replace nodes or add nodes.
>> You can then pretty print it back to source.
>> 
> 
> Thanks Marcus. That's what I was trying to do. I got the AST and created the
> node:
>    body := (AbstractSound>>#initialize) parseTree body.
>    body addNode: (RBParser parseExpression: 'envelopes := nil').
> 
> But then I couldn't figure out how to get the source back...
> 
> "These both returned the statements without the header"
> body formattedCode.
> body newSource.
> 
> "This returned the full method, but without the added node"
> body source
> 
Sean,

you extracted the body first and operate on it. So you only have the body. Try

method := (AbstractSound>>#initialize) parseTree.
method body addNode: (RBParser parseExpression: 'envelopes := nil').
method formattedCode

Norbert

Reply via email to