[Java] Class SourceAwareCustomizerFactory
- org.codehaus.groovy.control.customizers.builder.SourceAwareCustomizerFactory
- All Implemented Interfaces and Traits:
- PostCompletionFactory
public class SourceAwareCustomizerFactory extends AbstractFactory implements 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
Modifiers | Name | Description |
---|---|---|
static class | SourceAwareCustomizerFactory.SourceOptions |
Methods Summary
Type Params | Return Type | Name and description |
---|---|---|
public void |
call(SourceUnit source, GeneratorContext context, ClassNode classNode) | |
public Boolean |
call(Object arguments) | |
public Boolean |
call(Object arguments) | |
public Object |
newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes) | |
public Object |
postCompleteNode(FactoryBuilderSupport factory, Object parent, Object node) | |
public void |
setChild(FactoryBuilderSupport builder, Object parent, Object child) |
Inherited Methods Summary
Methods inherited from class | Name |
---|---|
class AbstractFactory | setParent, isLeaf, onFactoryRegistration, onHandleNodeAttributes, isHandlesNodeChildren, setChild, onNodeChildren, onNodeCompleted, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll, newInstance |
Method Detail
@Override public void call(SourceUnit source, GeneratorContext context, ClassNode classNode)
@Override public Boolean call(Object arguments)
@Override public Boolean call(Object arguments)
public Object newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes)
public Object postCompleteNode(FactoryBuilderSupport factory, Object parent, Object node)
@Override public void setChild(FactoryBuilderSupport builder, Object parent, Object child)
© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/org/codehaus/groovy/control/customizers/builder/SourceAwareCustomizerFactory.html