Search in sources :

Example 1 with NamedArgumentListExpression

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

the class StaticImportVisitor method transformConstructorCallExpression.

protected Expression transformConstructorCallExpression(ConstructorCallExpression cce) {
    inSpecialConstructorCall = cce.isSpecialCall();
    Expression expression = cce.getArguments();
    if (expression instanceof TupleExpression) {
        TupleExpression tuple = (TupleExpression) expression;
        if (tuple.getExpressions().size() == 1) {
            expression = tuple.getExpression(0);
            if (expression instanceof NamedArgumentListExpression) {
                NamedArgumentListExpression namedArgs = (NamedArgumentListExpression) expression;
                List<MapEntryExpression> entryExpressions = namedArgs.getMapEntryExpressions();
                for (int i = 0; i < entryExpressions.size(); i++) {
                    entryExpressions.set(i, (MapEntryExpression) transformMapEntryExpression(entryExpressions.get(i), cce.getType()));
                }
            }
        }
    }
    Expression ret = cce.transformExpression(this);
    inSpecialConstructorCall = false;
    return ret;
}
Also used : MapEntryExpression(org.codehaus.groovy.ast.expr.MapEntryExpression) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) PropertyExpression(org.codehaus.groovy.ast.expr.PropertyExpression) StaticMethodCallExpression(org.codehaus.groovy.ast.expr.StaticMethodCallExpression) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) NamedArgumentListExpression(org.codehaus.groovy.ast.expr.NamedArgumentListExpression) MethodCallExpression(org.codehaus.groovy.ast.expr.MethodCallExpression) EmptyExpression(org.codehaus.groovy.ast.expr.EmptyExpression) Expression(org.codehaus.groovy.ast.expr.Expression) ConstructorCallExpression(org.codehaus.groovy.ast.expr.ConstructorCallExpression) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) ArgumentListExpression(org.codehaus.groovy.ast.expr.ArgumentListExpression) AnnotationConstantExpression(org.codehaus.groovy.ast.expr.AnnotationConstantExpression) ClosureExpression(org.codehaus.groovy.ast.expr.ClosureExpression) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression) TupleExpression(org.codehaus.groovy.ast.expr.TupleExpression) BinaryExpression(org.codehaus.groovy.ast.expr.BinaryExpression) MapEntryExpression(org.codehaus.groovy.ast.expr.MapEntryExpression) TupleExpression(org.codehaus.groovy.ast.expr.TupleExpression) NamedArgumentListExpression(org.codehaus.groovy.ast.expr.NamedArgumentListExpression)

Aggregations

AnnotationConstantExpression (org.codehaus.groovy.ast.expr.AnnotationConstantExpression)1 ArgumentListExpression (org.codehaus.groovy.ast.expr.ArgumentListExpression)1 BinaryExpression (org.codehaus.groovy.ast.expr.BinaryExpression)1 ClassExpression (org.codehaus.groovy.ast.expr.ClassExpression)1 ClosureExpression (org.codehaus.groovy.ast.expr.ClosureExpression)1 ConstantExpression (org.codehaus.groovy.ast.expr.ConstantExpression)1 ConstructorCallExpression (org.codehaus.groovy.ast.expr.ConstructorCallExpression)1 EmptyExpression (org.codehaus.groovy.ast.expr.EmptyExpression)1 Expression (org.codehaus.groovy.ast.expr.Expression)1 ListExpression (org.codehaus.groovy.ast.expr.ListExpression)1 MapEntryExpression (org.codehaus.groovy.ast.expr.MapEntryExpression)1 MethodCallExpression (org.codehaus.groovy.ast.expr.MethodCallExpression)1 NamedArgumentListExpression (org.codehaus.groovy.ast.expr.NamedArgumentListExpression)1 PropertyExpression (org.codehaus.groovy.ast.expr.PropertyExpression)1 StaticMethodCallExpression (org.codehaus.groovy.ast.expr.StaticMethodCallExpression)1 TupleExpression (org.codehaus.groovy.ast.expr.TupleExpression)1 VariableExpression (org.codehaus.groovy.ast.expr.VariableExpression)1