Re: AST nodeMetaData

2018-02-08 Thread Paolo Di Tommaso
Well, actually that would be my use case. I'm trying to capture a closure source code (string) when parsing a groovy config file with a (custom) ConfigSlurper. I'm able to read the source code from the closure BlockStatement using and AST xform. Then the idea was to inject it into the nodeMetaDat

Re: AST nodeMetaData

2018-02-08 Thread Cédric Champeau
In general `metaClass.classNode` is unsafe: you never know if there's going to be something there. It only works for scripts compiled "on the fly" for which you keep a reference. Not precompiled classes, typically. 2018-02-08 14:44 GMT+01:00 Paolo Di Tommaso : > I see. Actually my idea was to pop

Re: AST nodeMetaData

2018-02-08 Thread Paolo Di Tommaso
I see. Actually my idea was to populate the nodeMetaData map and access it via `class.metaClass.classNode.nodeMetaData`, but it seems not possible. But the the use of annotation sounds a nice idea. Thanks. p On Thu, Feb 8, 2018 at 2:35 PM, Cédric Champeau wrote: > Unless you have an AST xform

Re: AST nodeMetaData

2018-02-08 Thread Cédric Champeau
Unless you have an AST xform that takes that node metadata and injects it into bytecode in a way that it's available at runtime (say, within an annotation), no, it's not possible. 2018-02-08 14:30 GMT+01:00 Paolo Di Tommaso : > Dear all, > > Is it possible to inject some values in a nodeMetaData

AST nodeMetaData

2018-02-08 Thread Paolo Di Tommaso
Dear all, Is it possible to inject some values in a nodeMetaData during AST transformation and access such values at runtime ? p