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)
}
| Modifiers | Name | Description |
|---|---|---|
static class |
SourceAwareCustomizerFactory.SourceOptions |
Collected builder options used to create a SourceAwareCustomizer. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public Object |
newInstance(FactoryBuilderSupport builder, Object name, Object value, Map attributes)Creates the mutable source options collected from the builder node. |
|
public Object |
postCompleteNode(FactoryBuilderSupport factory, Object parent, Object node)Converts the collected source options into a configured SourceAwareCustomizer. |
|
public void |
setChild(FactoryBuilderSupport builder, Object parent, Object child)Captures the nested compilation customizer selected for the source-aware wrapper. |
| Methods inherited from class | Name |
|---|---|
class AbstractFactory |
isHandlesNodeChildren, isLeaf, onFactoryRegistration, onHandleNodeAttributes, onNodeChildren, onNodeCompleted, setChild, setParent |
Creates the mutable source options collected from the builder node.
builder - the active buildername - the node namevalue - the supplied node valueattributes - the node attributesConverts the collected source options into a configured SourceAwareCustomizer.
factory - the active builderparent - the parent nodenode - the completed nodeCaptures the nested compilation customizer selected for the source-aware wrapper.
builder - the active builderparent - the parent nodechild - the child node