Created
July 22, 2014 12:47
-
-
Save melix/628b2f04f83f7f9721b8 to your computer and use it in GitHub Desktop.
Dump AST transformations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import groovy.transform.ASTTest | |
import groovy.transform.CompileStatic | |
import groovy.transform.Immutable | |
import org.codehaus.groovy.ast.ClassNode | |
import org.codehaus.groovy.control.CompilePhase | |
@ASTTest(phase=CompilePhase.INSTRUCTION_SELECTION,value={ | |
ClassNode cn = node | |
def config = cn.compileUnit.config | |
def cu = cn.compileUnit.classLoader.createCompilationUnit(config, null) | |
System.err.println "Global AST xforms: ${cu.getASTTransformationsContext().globalTransformNames}" | |
CompilePhase.values().each { | |
def transforms = cn.getTransforms(it) | |
if (transforms) { | |
System.err.println "Ast xforms for phase $it:" | |
transforms.each { map -> | |
System.err.println(map) | |
} | |
} | |
} | |
}) | |
@CompileStatic | |
@Immutable | |
class Foo { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of output: