Griffon 1.2.0

org.codehaus.griffon.ast
[Java] Class PropertyListenerASTTransformation

java.lang.Object
  org.codehaus.griffon.ast.AbstractASTTransformation
      org.codehaus.griffon.ast.PropertyListenerASTTransformation

@GroovyASTTransformation(phase= CompilePhase.CANONICALIZATION)
public class PropertyListenerASTTransformation
extends AbstractASTTransformation

Handles generation of code for the @PropertyListener annotation.

Any closures found as the annotation's value will be either transformed into inner classes that implement PropertyChangeListener (when the value is a closue defined in place) or be casted as a proxy of PropertyChangeListener (when the value is a property reference found in the same class).

List of closures are also supported.

Authors:
Andres Almiray


Field Summary
private static String EMPTY_STRING

private static ClassNode PROPERTY_CHANGE_LISTENER_CLASS

private static ClassNode PROPERTY_LISTENER_CLASS

 
Fields inherited from class AbstractASTTransformation
APPLICATION_HOLDER_TYPE, COLLECTIONS_CLASS
 
Constructor Summary
PropertyListenerASTTransformation()

 
Method Summary
private static void addListenerStatement(ClassNode classNode, ArgumentListExpression args)

static void addListenerToClass(SourceUnit source, AnnotationNode annotation, ClassNode classNode)

static void addListenerToProperty(SourceUnit source, AnnotationNode annotation, ClassNode declaringClass, FieldNode field)

private static void addPropertyChangeListener(ClassNode classNode, String propertyName, ClosureExpression closure)

private static void addPropertyChangeListener(ClassNode classNode, String propertyName, VariableExpression variable)

static boolean hasListenerAnnotation(AnnotatedNode node)

Convenience method to see if an annotated node is @PropertyListener.

private static void processExpression(ClassNode classNode, String propertyName, Expression expression)

void visit(ASTNode[] nodes, SourceUnit source)

Handles the bulk of the processing, mostly delegating to other methods.

 
Methods inherited from class AbstractASTTransformation
addError, applicationInstance, checkNodesForAnnotationAndType, emptyMap, makeClassSafe, makeClassSafe, makeClassSafe, newClass
 

Field Detail

EMPTY_STRING

private static final String EMPTY_STRING


PROPERTY_CHANGE_LISTENER_CLASS

private static final ClassNode PROPERTY_CHANGE_LISTENER_CLASS


PROPERTY_LISTENER_CLASS

private static final ClassNode PROPERTY_LISTENER_CLASS


 
Constructor Detail

PropertyListenerASTTransformation

PropertyListenerASTTransformation()


 
Method Detail

addListenerStatement

private static void addListenerStatement(ClassNode classNode, ArgumentListExpression args)


addListenerToClass

public static void addListenerToClass(SourceUnit source, AnnotationNode annotation, ClassNode classNode)


addListenerToProperty

public static void addListenerToProperty(SourceUnit source, AnnotationNode annotation, ClassNode declaringClass, FieldNode field)


addPropertyChangeListener

private static void addPropertyChangeListener(ClassNode classNode, String propertyName, ClosureExpression closure)


addPropertyChangeListener

private static void addPropertyChangeListener(ClassNode classNode, String propertyName, VariableExpression variable)


hasListenerAnnotation

public static boolean hasListenerAnnotation(AnnotatedNode node)
Convenience method to see if an annotated node is @PropertyListener.
Parameters:
node - the node to check
Returns:
true if the node is an event publisher


processExpression

private static void processExpression(ClassNode classNode, String propertyName, Expression expression)


visit

public void visit(ASTNode[] nodes, SourceUnit source)
Handles the bulk of the processing, mostly delegating to other methods.
Parameters:
nodes - the ast nodes
source - the source unit for the nodes


 

Groovy Documentation