Groovy Documentation

org.codehaus.groovy.control.customizers.builder
[Java] Class SourceAwareCustomizerFactory

java.lang.Object
  groovy.util.AbstractFactory
      org.codehaus.groovy.control.customizers.builder.SourceAwareCustomizerFactory
All Implemented Interfaces:
PostCompletionFactory

public class SourceAwareCustomizerFactory
extends AbstractFactory

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(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)
     }
 
Authors:
Cedric Champeau


Nested Class Summary
static class SourceAwareCustomizerFactory.SourceOptions

 
Method Summary
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)

 
Methods inherited from class AbstractFactory
isHandlesNodeChildren, isLeaf, onFactoryRegistration, onHandleNodeAttributes, onNodeChildren, onNodeCompleted, setChild, setParent
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

newInstance

public java.lang.Object newInstance(FactoryBuilderSupport builder, java.lang.Object name, java.lang.Object value, java.util.Map attributes)


postCompleteNode

public java.lang.Object postCompleteNode(FactoryBuilderSupport factory, java.lang.Object parent, java.lang.Object node)


setChild

@java.lang.Override
public void setChild(FactoryBuilderSupport builder, java.lang.Object parent, java.lang.Object child)


 

Groovy Documentation