[Pharo-project] Adding a statement programmatically

Sean P. DeNigris sean at clipperadams.com
Thu Mar 8 11:08:19 EST 2012


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

--
View this message in context: http://forum.world.st/Adding-a-statement-programmatically-tp4454447p4456824.html
Sent from the Pharo Smalltalk mailing list archive at Nabble.com.




More information about the Pharo-dev mailing list