Search in sources :

Example 51 with ListExpression

use of org.codehaus.groovy.ast.expr.ListExpression in project groovy by apache.

the class AbstractASTTransformation method getClassList.

@Deprecated
public List<ClassNode> getClassList(AnnotationNode anno, String name) {
    List<ClassNode> list = new ArrayList<ClassNode>();
    Expression expr = anno.getMember(name);
    if (expr != null && expr instanceof ListExpression) {
        final ListExpression listExpression = (ListExpression) expr;
        for (Expression itemExpr : listExpression.getExpressions()) {
            if (itemExpr != null && itemExpr instanceof ClassExpression) {
                ClassNode cn = itemExpr.getType();
                if (cn != null)
                    list.add(cn);
            }
        }
    } else if (expr != null && expr instanceof ClassExpression) {
        ClassNode cn = expr.getType();
        if (cn != null)
            list.add(cn);
    }
    return list;
}
Also used : ClassNode(org.codehaus.groovy.ast.ClassNode) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) Expression(org.codehaus.groovy.ast.expr.Expression) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) ArrayList(java.util.ArrayList) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression)

Example 52 with ListExpression

use of org.codehaus.groovy.ast.expr.ListExpression in project groovy by apache.

the class AbstractASTTransformation method getMemberClassList.

public List<ClassNode> getMemberClassList(AnnotationNode anno, String name) {
    List<ClassNode> list = new ArrayList<ClassNode>();
    Expression expr = anno.getMember(name);
    if (expr == null) {
        return null;
    }
    if (expr instanceof ListExpression) {
        final ListExpression listExpression = (ListExpression) expr;
        if (isUndefinedMarkerList(listExpression)) {
            return null;
        }
        for (Expression itemExpr : listExpression.getExpressions()) {
            if (itemExpr != null && itemExpr instanceof ClassExpression) {
                ClassNode cn = itemExpr.getType();
                if (cn != null)
                    list.add(cn);
            }
        }
    } else if (expr instanceof ClassExpression) {
        ClassNode cn = expr.getType();
        if (isUndefined(cn))
            return null;
        if (cn != null)
            list.add(cn);
    }
    return list;
}
Also used : ClassNode(org.codehaus.groovy.ast.ClassNode) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) Expression(org.codehaus.groovy.ast.expr.Expression) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) ArrayList(java.util.ArrayList) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression)

Example 53 with ListExpression

use of org.codehaus.groovy.ast.expr.ListExpression in project groovy by apache.

the class NewifyASTTransformation method newifyMethodOrField.

private void newifyMethodOrField(AnnotatedNode parent, boolean autoFlag, ListExpression list) {
    final ListExpression oldClassesToNewify = classesToNewify;
    final boolean oldAuto = auto;
    checkClassLevelClashes(list);
    checkAutoClash(autoFlag, parent);
    classesToNewify = list;
    auto = autoFlag;
    if (parent instanceof FieldNode) {
        super.visitField((FieldNode) parent);
    } else {
        super.visitMethod((MethodNode) parent);
    }
    classesToNewify = oldClassesToNewify;
    auto = oldAuto;
}
Also used : FieldNode(org.codehaus.groovy.ast.FieldNode) ListExpression(org.codehaus.groovy.ast.expr.ListExpression)

Example 54 with ListExpression

use of org.codehaus.groovy.ast.expr.ListExpression in project groovy by apache.

the class NewifyASTTransformation method newifyDeclaration.

private void newifyDeclaration(DeclarationExpression de, boolean autoFlag, ListExpression list) {
    ClassNode cNode = de.getDeclaringClass();
    candidate = de;
    final ListExpression oldClassesToNewify = classesToNewify;
    final boolean oldAuto = auto;
    classesToNewify = list;
    auto = autoFlag;
    super.visitClass(cNode);
    classesToNewify = oldClassesToNewify;
    auto = oldAuto;
}
Also used : ClassNode(org.codehaus.groovy.ast.ClassNode) ListExpression(org.codehaus.groovy.ast.expr.ListExpression)

Example 55 with ListExpression

use of org.codehaus.groovy.ast.expr.ListExpression in project groovy by apache.

the class AbstractASTTransformation method getMemberList.

@Deprecated
public List<String> getMemberList(AnnotationNode anno, String name) {
    List<String> list;
    Expression expr = anno.getMember(name);
    if (expr != null && expr instanceof ListExpression) {
        list = new ArrayList<String>();
        final ListExpression listExpression = (ListExpression) expr;
        for (Expression itemExpr : listExpression.getExpressions()) {
            if (itemExpr != null && itemExpr instanceof ConstantExpression) {
                Object value = ((ConstantExpression) itemExpr).getValue();
                if (value != null)
                    list.add(value.toString());
            }
        }
    } else {
        list = tokenize(getMemberStringValue(anno, name));
    }
    return list;
}
Also used : ListExpression(org.codehaus.groovy.ast.expr.ListExpression) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) Expression(org.codehaus.groovy.ast.expr.Expression) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression)

Aggregations

ListExpression (org.codehaus.groovy.ast.expr.ListExpression)60 Expression (org.codehaus.groovy.ast.expr.Expression)44 ConstantExpression (org.codehaus.groovy.ast.expr.ConstantExpression)41 ClassExpression (org.codehaus.groovy.ast.expr.ClassExpression)37 VariableExpression (org.codehaus.groovy.ast.expr.VariableExpression)27 ClassNode (org.codehaus.groovy.ast.ClassNode)25 ArgumentListExpression (org.codehaus.groovy.ast.expr.ArgumentListExpression)19 ArrayList (java.util.ArrayList)16 MethodCallExpression (org.codehaus.groovy.ast.expr.MethodCallExpression)15 PropertyExpression (org.codehaus.groovy.ast.expr.PropertyExpression)15 ConstructorCallExpression (org.codehaus.groovy.ast.expr.ConstructorCallExpression)14 ArrayExpression (org.codehaus.groovy.ast.expr.ArrayExpression)12 MapExpression (org.codehaus.groovy.ast.expr.MapExpression)12 ClosureExpression (org.codehaus.groovy.ast.expr.ClosureExpression)11 FieldNode (org.codehaus.groovy.ast.FieldNode)7 BinaryExpression (org.codehaus.groovy.ast.expr.BinaryExpression)7 AnnotationNode (org.codehaus.groovy.ast.AnnotationNode)6 DeclarationExpression (org.codehaus.groovy.ast.expr.DeclarationExpression)6 AnnotationConstantExpression (org.codehaus.groovy.ast.expr.AnnotationConstantExpression)5 MapEntryExpression (org.codehaus.groovy.ast.expr.MapEntryExpression)5