Search code examples
javaxtextxbase

Xbase - How to add tags on top on inferrer generated methods


I have figured out how to create methods and add to the bodies of the method. What I need to also do is add annotations to the generated method such as @Test etc, how would I accomplish this?


Solution

  • if you want to infer annotatations inside the inferrer you could do something like

    members += greeting.toMethod("testHello" + greeting.name, typeRef(Void.TYPE)) [
        annotations += "org.junit.Test".annotationRef()
        body = '''
            // TODO
        '''
    ]