Groovy script AST transforms

Hello

I have my own AST transformations in groovy. I use intellij and want the compiler to pick up my AST transformations as part of compiling/validating the groovy script

One example is this. I have an annotation @NoCode which I will use to ensure that a function has no code in it. so

@NoCode
def func1() {} // is valid

@NoCode
def func2() {func1();} // must be invalid, therefore expecting to see red squiggly lines

My AST transforms work and I am able to get the compile error I use when I see code. How do I now integrate this with intellij? I tried using a config.groovy with this transformation in it and setting this config.groovy file in the configscript option for the groovy compiler. That did not work.

Any help is appreciated

My config.groovy is this

import com.me.runtime.NoCode

def analysis = new ASTTransformationCustomizer(NoCode)
configuration.addCompilationCustomizers(analysis)
configuration.setScriptBaseClass("com.mybase.RuntimeScript")

Please sign in to leave a comment.