Search code examples
xtend

How can I statically import methods in code generated by Xtend active annotations?


I would like to use a statically imported method in code generated with Xtend's active annotations. As an example, I want to get this output:

import static java.util.Collections.emptyList;

@MyActiveAnnotation
public class MyTest {

    public void foo() {
        emptyList();
    }
}

My compilation participant looks like this:

override doTransform(MutableClassDeclaration clazz, extension TransformationContext context) {
clazz.addMethod("foo", [
    body = '''
        «Collections».emptyList();
])

While this code works and imports Collections, it doesn't statically import the emptyList method.

How can I statically import methods using Xtend's active annotations?


Solution

  • According to Xtend developers, this doesn't seem possible.