public class SourceAwareCustomizerFactory extends AbstractFactory implements PostCompletionFactory
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(basenames: { 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)
}
Modifier and Type | Class and Description |
---|---|
static class |
SourceAwareCustomizerFactory.SourceOptions |
Constructor and Description |
---|
SourceAwareCustomizerFactory() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
newInstance(FactoryBuilderSupport builder,
java.lang.Object name,
java.lang.Object value,
java.util.Map attributes) |
java.lang.Object |
postCompleteNode(FactoryBuilderSupport factory,
java.lang.Object parent,
java.lang.Object node) |
void |
setChild(FactoryBuilderSupport builder,
java.lang.Object parent,
java.lang.Object child) |
isHandlesNodeChildren, isLeaf, onFactoryRegistration, onHandleNodeAttributes, onNodeChildren, onNodeCompleted, setParent
public java.lang.Object newInstance(FactoryBuilderSupport builder, java.lang.Object name, java.lang.Object value, java.util.Map attributes) throws java.lang.InstantiationException, java.lang.IllegalAccessException
newInstance
in interface Factory
builder
- the FactoryBuildername
- the name of the node being builtvalue
- the 'value' argument in the build nodeattributes
- the attributes of the build argjava.lang.InstantiationException
- if attempting to instantiate an interface or abstract classjava.lang.IllegalAccessException
- if the instance can't be created due to a security violationpublic void setChild(FactoryBuilderSupport builder, java.lang.Object parent, java.lang.Object child)
setChild
in interface Factory
setChild
in class AbstractFactory
public java.lang.Object postCompleteNode(FactoryBuilderSupport factory, java.lang.Object parent, java.lang.Object node)
postCompleteNode
in interface PostCompletionFactory