Class SourceAwareCustomizerFactory
java.lang.Object
groovy.util.AbstractFactory
org.codehaus.groovy.control.customizers.builder.SourceAwareCustomizerFactory
- All Implemented Interfaces:
Factory,PostCompletionFactory
Factory for use with
CompilerCustomizationBuilder. Allows the construction of source aware customizers. Syntax:
// apply CompileStatic AST annotation on .sgroovy files
builder.source(extension: 'sgroovy') {
ast(CompileStatic)
}
// apply CompileStatic AST annotation on .sgroovy or .sg files
builder.source(extensions: ['sgroovy','sg']) {
ast(CompileStatic)
}
// apply CompileStatic AST annotation on .sgroovy or .sg files
builder.source(extensionValidator: { it.name in ['sgroovy','sg']}) {
ast(CompileStatic)
}
// apply CompileStatic AST annotation on files whose name is 'foo'
builder.source(basename: 'foo') {
ast(CompileStatic)
}
// apply CompileStatic AST annotation on files whose name is 'foo' or 'bar'
builder.source(basenames: ['foo', 'bar']) {
ast(CompileStatic)
}
// apply CompileStatic AST annotation on files whose name is 'foo' or 'bar'
builder.source(basenameValidator: { it in ['foo', 'bar'] }) {
ast(CompileStatic)
}
// apply CompileStatic AST annotation on files that do not contain a class named 'Baz'
builder.source(unitValidator: { unit -> !unit.AST.classes.any { it.name == 'Baz' } }) {
ast(CompileStatic)
}
// apply CompileStatic AST annotation on class nodes that end with 'CS'
builder.source(classValidator: { cn -> cn.name.endsWith('CS') }) {
ast(CompileStatic)
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCollected builder options used to create aSourceAwareCustomizer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnewInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) Creates the mutable source options collected from the builder node.postCompleteNode(FactoryBuilderSupport factory, Object parent, Object node) Converts the collected source options into a configuredSourceAwareCustomizer.voidsetChild(FactoryBuilderSupport builder, Object parent, Object child) Captures the nested compilation customizer selected for the source-aware wrapper.Methods inherited from class groovy.util.AbstractFactory
isHandlesNodeChildren, isLeaf, onFactoryRegistration, onHandleNodeAttributes, onNodeChildren, onNodeCompleted, setParent
-
Constructor Details
-
SourceAwareCustomizerFactory
public SourceAwareCustomizerFactory()
-
-
Method Details
-
newInstance
public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) throws InstantiationException, IllegalAccessException Creates the mutable source options collected from the builder node.- Specified by:
newInstancein interfaceFactory- Parameters:
builder- the active buildername- the node namevalue- the supplied node valueattributes- the node attributes- Returns:
- the collected source options
- Throws:
InstantiationException- if instantiation failsIllegalAccessException- if access fails
-
setChild
Captures the nested compilation customizer selected for the source-aware wrapper.- Specified by:
setChildin interfaceFactory- Overrides:
setChildin classAbstractFactory- Parameters:
builder- the active builderparent- the parent nodechild- the child node
-
postCompleteNode
Converts the collected source options into a configuredSourceAwareCustomizer.- Specified by:
postCompleteNodein interfacePostCompletionFactory- Parameters:
factory- the active builderparent- the parent nodenode- the completed node- Returns:
- the configured source-aware customizer
-