Generating classes on the fly
Saravanan Palanichamy <[email protected]> Thu, 11 Jul 2024 11:29:42 +0530
| Newsgroups | gmane.comp.lang.groovy.user |
|---|---|
| Message-ID | <CAG3fL7=uueuKM61aDUhRYkvbWpTOTfGEouU3-P-wfqHWiO16yw@mail.gmail.com> |
Hello folks I am generating groovy classes (ClassNode objects) on the fly. I do this by adding an AST transformation that will add these classes as inner classes to other classes (that were fed to the compiler as source files). This works. However, I want to generate classes on the fly without attaching them to existing class nodes as inner classes. How do I achieve this? when I use the method addClassNode in compilation unit, I get sourceUnit null pointer exceptions (I need the sourceunit to lookup other AST customizers) What is the right way to build a source unit that can be used for these class nodes that I generate on the fly? regards Saravanan