Hello to everybody!

I'm writing AST transformation that creates new classes, and I have a problem 
with annotations.
I'm using Groovy 2.5.4 (with Gradle).

Code of AST transformation class is here (WIP): 

Basically, user puts an annotation on interface.
Then AST transformation:
1) adds inner class to this interface
2) adds to this inner class method implementations, fields, constructor and so 
Some of these should be annotated.

I've already seen post in desmontandojava blog on adding inner classes:
And figured out that if I don't use CompilationUnit for inner class, it doesn't 
get methodMissing, propertyMissing etc. methods.
So, I guess, I need it.

I'm using CompilationUnit this way:

    new CompilationUnit(sourceUnit.AST.unit.config).with {

Whenever members of implClass have annotations I got NPE at 
I debugged and figured out that:
1) CompilationUnit#addClassNode adds new ModuleNode constructed with 
CompileUnit, and SourceUnit is null in this case.
2) Then null source gets passed to other objects.
3) ExtendedVerifier#isAnnotationCompatible needs source to get configuration.
Without source I got NPE.

Note that code in desmontandojava blog doesn't create annotations.

I also tried to add my new class into existing module but then I got another 
error, saying that line numbers are null.

I've looked at Groovy 3.0 sources too, but couldn't see any changes that would 
fix or change this.

Could somebody help me?
Am I doing something wrong, or it is a bug?

Best regards,
Basil Peace

Reply via email to