Search code examples
javaxtend

Xtend: Removing Active Annotation during code generation


I've created an active annotation @Module, but I don't want the generated Java class to be annotated with @Module.

When I try to remove the annotation during the transformation phase, it instead comments out the annotation (which would be fine), but leaves the import in.

Code that is supposed to remove the annotation:

override doTransform(MutableClassDeclaration annotatedClass, extension TransformationContext context) {
    annotatedClass.removeAnnotation(annotatedClass.annotations.findFirst[annotationTypeDeclaration == Module.newTypeReference.type])
}

Generated class:

import my.package.Module;

/* @Module */@SuppressWarnings("all")
public class MyClass {}

Xtend version: 2.11

xbase lib gwt version: 2.9.2

Xtend eclipse plugin version: 2.11


Solution

  • I upgraded to Java 8 and now the annotation removal code works.