public abstract class CompilationCustomizer
extends Object
implements CompilationUnitIPrimaryClassNodeOperation
Users wanting to customize the configuration process such as adding imports, restricting the language features or apply AST transformations by default should implement this class, then call the CompilerConfiguration.addCompilationCustomizers method.
A customizer is registered for a particular compilation and is invoked for every primary class node of it. Two consequences are easy to overlook:
SourceUnit passed to
CompilationUnit.IPrimaryClassNodeOperation#call may be
null, for class nodes supplied directly via
CompilationUnit#addClassNode(org.codehaus.groovy.ast.ClassNode) rather than
parsed from source. Guard accordingly; an unguarded dereference surfaces as a
GroovyBugError rather than as your own exception.| Constructor and description |
|---|
CompilationCustomizer(CompilePhase phase)Creates a customizer bound to the supplied compile phase. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public CompilePhase |
getPhase()Returns the compile phase in which this customizer runs. |
Creates a customizer bound to the supplied compile phase.
phase - the phase in which this customizer should runReturns the compile phase in which this customizer runs.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.