use of org.codehaus.groovy.control.ASTTransformationsContext in project groovy by apache.
the class ASTTransformationVisitor method addPhaseOperations.
public static void addPhaseOperations(final CompilationUnit compilationUnit) {
ASTTransformationsContext context = compilationUnit.getASTTransformationsContext();
addGlobalTransforms(context);
compilationUnit.addPhaseOperation((final SourceUnit source, final GeneratorContext ignore, final ClassNode classNode) -> {
GroovyClassVisitor visitor = new ASTTransformationCollectorCodeVisitor(source, compilationUnit.getTransformLoader());
visitor.visitClass(classNode);
}, Phases.SEMANTIC_ANALYSIS);
for (CompilePhase phase : CompilePhase.values()) {
switch(phase) {
case INITIALIZATION:
case PARSING:
case CONVERSION:
// with transform detection alone these phases are inaccessible, so don't add it
break;
default:
compilationUnit.addPhaseOperation((final SourceUnit source, final GeneratorContext ignore, final ClassNode classNode) -> {
ASTTransformationVisitor visitor = new ASTTransformationVisitor(phase, context);
visitor.source = source;
visitor.visitClass(classNode);
}, phase.getPhaseNumber());
break;
}
}
}
Aggregations