Search in sources :

Example 66 with AnnotatedNode

use of org.codehaus.groovy.ast.AnnotatedNode in project groovy by apache.

the class SingletonASTTransformation method visit.

public void visit(ASTNode[] nodes, SourceUnit source) {
    init(nodes, source);
    AnnotatedNode parent = (AnnotatedNode) nodes[1];
    AnnotationNode node = (AnnotationNode) nodes[0];
    if (parent instanceof ClassNode) {
        ClassNode classNode = (ClassNode) parent;
        String propertyName = getMemberStringValue(node, "property", "instance");
        boolean isLazy = memberHasValue(node, "lazy", true);
        boolean isStrict = !memberHasValue(node, "strict", false);
        createField(classNode, propertyName, isLazy, isStrict);
    }
}
Also used : ClassNode(org.codehaus.groovy.ast.ClassNode) AnnotationNode(org.codehaus.groovy.ast.AnnotationNode) AnnotatedNode(org.codehaus.groovy.ast.AnnotatedNode)

Example 67 with AnnotatedNode

use of org.codehaus.groovy.ast.AnnotatedNode in project groovy by apache.

the class SortableASTTransformation method visit.

public void visit(ASTNode[] nodes, SourceUnit source) {
    init(nodes, source);
    AnnotationNode annotation = (AnnotationNode) nodes[0];
    AnnotatedNode parent = (AnnotatedNode) nodes[1];
    if (parent instanceof ClassNode) {
        createSortable(annotation, (ClassNode) parent);
    }
}
Also used : ClassNode(org.codehaus.groovy.ast.ClassNode) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) AnnotationNode(org.codehaus.groovy.ast.AnnotationNode) AnnotatedNode(org.codehaus.groovy.ast.AnnotatedNode)

Aggregations

AnnotatedNode (org.codehaus.groovy.ast.AnnotatedNode)67 AnnotationNode (org.codehaus.groovy.ast.AnnotationNode)67 ClassNode (org.codehaus.groovy.ast.ClassNode)59 FieldNode (org.codehaus.groovy.ast.FieldNode)31 MethodNode (org.codehaus.groovy.ast.MethodNode)18 Expression (org.codehaus.groovy.ast.expr.Expression)17 ConstantExpression (org.codehaus.groovy.ast.expr.ConstantExpression)10 ListExpression (org.codehaus.groovy.ast.expr.ListExpression)10 VariableExpression (org.codehaus.groovy.ast.expr.VariableExpression)10 DeclarationExpression (org.codehaus.groovy.ast.expr.DeclarationExpression)9 GroovyBugError (org.codehaus.groovy.GroovyBugError)8 ClassExpression (org.codehaus.groovy.ast.expr.ClassExpression)7 ClosureExpression (org.codehaus.groovy.ast.expr.ClosureExpression)7 MethodCallExpression (org.codehaus.groovy.ast.expr.MethodCallExpression)7 VariableScopeVisitor (org.codehaus.groovy.classgen.VariableScopeVisitor)6 ArrayList (java.util.ArrayList)5 Statement (org.codehaus.groovy.ast.stmt.Statement)5 GroovyClassLoader (groovy.lang.GroovyClassLoader)4 InnerClassNode (org.codehaus.groovy.ast.InnerClassNode)4 PropertyNode (org.codehaus.groovy.ast.PropertyNode)4