Package org.codehaus.groovy.ast.expr

Examples of org.codehaus.groovy.ast.expr.TupleExpression


        }

        // add the super call
        ConstructorCallExpression cce = new ConstructorCallExpression(
                ClassNode.SUPER,
                new TupleExpression(superCallArguments)
        );

        block.addStatement(new ExpressionStatement(cce));

        // we need to add "this" to access unknown methods/properties
View Full Code Here


        if (parent == null) return;

        //add this parameter to node
        Expression argsExp = call.getArguments();
        if (argsExp instanceof TupleExpression) {
            TupleExpression argsListExp = (TupleExpression) argsExp;
            Expression this0 = VariableExpression.THIS_EXPRESSION;
            for (int i = 0; i != level; ++i)
                this0 = new PropertyExpression(this0, "this$0");
            argsListExp.getExpressions().add(0, this0);
        }
    }
View Full Code Here

     */
    public boolean hasPossibleMethod(String name, Expression arguments) {
        int count = 0;

        if (arguments instanceof TupleExpression) {
            TupleExpression tuple = (TupleExpression) arguments;
            // TODO this won't strictly be true when using list expansion in argument calls
            count = tuple.getExpressions().size();
        }
        ClassNode node = this;
        do {
            for (MethodNode method : getMethods(name)) {
                if (method.getParameters().length == count && !method.isStatic()) {
View Full Code Here

    public MethodNode tryFindPossibleMethod(String name, Expression arguments) {
        int count = 0;

        if (arguments instanceof TupleExpression) {
            TupleExpression tuple = (TupleExpression) arguments;
            // TODO this won't strictly be true when using list expansion in argument calls
            count = tuple.getExpressions().size();
        } else
            return null;

        MethodNode res = null;
        ClassNode node = this;
        TupleExpression args = (TupleExpression) arguments;
        do {
            for (MethodNode method : node.getMethods(name)) {
                if (method.getParameters().length == count) {
                    boolean match = true;
                    for (int i = 0; i != count; ++i)
                        if (!args.getType().isDerivedFrom(method.getParameters()[i].getType())) {
                            match = false;
                            break;
                        }

                    if (match) {
View Full Code Here

     */
    public boolean hasPossibleStaticMethod(String name, Expression arguments) {
        int count = 0;

        if (arguments instanceof TupleExpression) {
            TupleExpression tuple = (TupleExpression) arguments;
            // TODO this won't strictly be true when using list expansion in argument calls
            count = tuple.getExpressions().size();
        } else if (arguments instanceof MapExpression) {
            count = 1;
        }
       
        for (MethodNode method : getMethods(name)) {
View Full Code Here

                            }
                        }
                    }
                } else if (arguments instanceof TupleExpression) {
                    if (isInterestingStatement(parent, parentParent)) {
                        TupleExpression te = (TupleExpression) arguments;
                        Map<String, String> namedArguments = Maps.newHashMap();
                        List<String> unnamedArguments = Lists.newArrayList();
                        for (Expression subExpr : te.getExpressions()) {
                            if (subExpr instanceof NamedArgumentListExpression) {
                                NamedArgumentListExpression nale = (NamedArgumentListExpression) subExpr;
                                for (MapEntryExpression mae : nale.getMapEntryExpressions()) {
                                    namedArguments.put(mae.getKeyExpression().getText(),
                                            mae.getValueExpression().getText());
View Full Code Here

     */
    public boolean hasPossibleMethod(String name, Expression arguments) {
        int count = 0;

        if (arguments instanceof TupleExpression) {
            TupleExpression tuple = (TupleExpression) arguments;
            // TODO this won't strictly be true when using list expansion in argument calls
            count = tuple.getExpressions().size();
        }
        ClassNode node = this;
        do {
            for (Iterator iter = getDeclaredMethods(name).iterator(); iter.hasNext();) {
                MethodNode method = (MethodNode) iter.next();
View Full Code Here

     */
    public boolean hasPossibleStaticMethod(String name, Expression arguments) {
        int count = 0;

        if (arguments instanceof TupleExpression) {
            TupleExpression tuple = (TupleExpression) arguments;
            // TODO this won't strictly be true when using list expansion in argument calls
            count = tuple.getExpressions().size();
        }
        for (Iterator iter = getDeclaredMethods(name).iterator(); iter.hasNext();) {
            MethodNode method = (MethodNode) iter.next();
            if (method.getParameters().length == count && method.isStatic()) {
                return true;
View Full Code Here

    @Override public void visitMethodCallExpression(MethodCallExpression call) {
        if (call.getMethod() instanceof ConstantExpression) {
            ConstantExpression name = (ConstantExpression) call.getMethod();
            if("where".equals(name.getValue()) || "and".equals(name.getValue()) || "or".equals(name.getValue()) || "select".equals(name.getValue())){
                if (call.getArguments() instanceof TupleExpression) {
                    TupleExpression args = (TupleExpression) call.getArguments();
                    List<Expression> transformed = new ArrayList<Expression>();
                    for (Expression expression : args.getExpressions()) {
                        transformed.add(ExpressionToMethodCallsTransformer.INSTANCE.transform(expression));
                    }
                    call.setArguments(new ArgumentListExpression(transformed));
                }
            }
View Full Code Here

        ConstantExpression method = (ConstantExpression) call.getMethod();

        if (!isDesiredMethodName(method.getValue())) { return false; }

        if (call.getArguments() instanceof TupleExpression) {
            TupleExpression args = (TupleExpression) call.getArguments();
            return args.getExpression(args.getExpressions().size()-1) instanceof ClosureExpression;
        }
       
        return false;
    }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.ast.expr.TupleExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.