Package org.codehaus.groovy.ast.expr

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


        return expr.transformExpression(this);
    }

    @Override
    public void visitClosureExpression(final ClosureExpression expression) {
        ClosureExpression old = currentClosure;
        currentClosure = expression;
        super.visitClosureExpression(expression);
        currentClosure = old;
    }
View Full Code Here


                            pe.setObjectExpression(thisExpression);
                            return pe;
                        }
                    }
                } else if (exp instanceof ClosureExpression) {
                    ClosureExpression ce = (ClosureExpression) exp;
                    ce.getVariableScope().putReferencedLocalVariable((Parameter) parameter.get());
                    Parameter[] params = ce.getParameters();
                    if (params == null) {
                        params = new Parameter[0];
                    } else if (params.length == 0) {
                        params = new Parameter[]{
                                new Parameter(ClassHelper.OBJECT_TYPE, "it")
                        };
                    }
                    addVariablesToStack(params);
                    ce.getCode().visit(this);
                    varStack.removeLast();
                }
                return super.transform(exp);
            }
        };
View Full Code Here

        List<Expression> argList = new ArrayList<Expression>(newParams.length);
        for (int i = 0; i < srcParams.length; i++) {
            argList.add(varX(newParams[i]));
        }

        ClosureExpression expression = new ClosureExpression(
                newParams,
                stmt(callThisX(privateMethod.getName(), args(argList)))
        );
        MethodCallExpression mce;
        if (protectedCacheSize == 0 && maxCacheSize == 0) {
View Full Code Here

        }
        if (exp instanceof MethodCallExpression) {
            return transformMethodCall((MethodCallExpression) exp);
        }
        if (exp instanceof ClosureExpression) {
            ClosureExpression cl = (ClosureExpression) exp;
            cl.getCode().visit(this);
            return cl;
        }
        if (exp instanceof VariableExpression) {
            VariableExpression var = (VariableExpression) exp;
            if (var.getAccessedVariable() instanceof DynamicVariable) {
View Full Code Here

            reformatted.setImplicitThis(exp.isImplicitThis());
            reformatted.setSafe(exp.isSafe());
            reformatted.setSpreadSafe(exp.isSpreadSafe());
            reformatted.setSourcePosition(exp);
            // wrap in a stringOf { ... } closure call
            ClosureExpression clos = new ClosureExpression(Parameter.EMPTY_ARRAY, new ExpressionStatement(reformatted));
            clos.setVariableScope(new VariableScope());
            MethodCallExpression stringOf = new MethodCallExpression(new VariableExpression("this"),
                    "stringOf",
                    clos);
            stringOf.setImplicitThis(true);
            stringOf.setSourcePosition(reformatted);
View Full Code Here

    @Override
    public void visitBlockStatement(BlockStatement block) {
      if (block.isEmpty() || this.xformed) {
        return;
      }
      ClosureExpression closure = beans(block);
      if (closure != null) {
        // Add a marker interface to the current script
        this.classNode.addInterface(ClassHelper.make(SOURCE_INTERFACE));
        // Implement the interface by adding a public read-only property with the
        // same name as the method in the interface (getBeans). Make it return the
View Full Code Here

              ArgumentListExpression arguments = (ArgumentListExpression) call
                  .getArguments();
              if (remove) {
                block.getStatements().remove(statement);
              }
              ClosureExpression closure = (ClosureExpression) arguments
                  .getExpression(0);
              return closure;
            }
          }
        }
View Full Code Here

                    if (expressions.size() == 1 &&
                            expressions.get(0) instanceof ClosureExpression) {
                        String parent = expression.getMethodAsString();
                        String parentParent = getParentParent();
                        if (isInterestingBlock(parent, parentParent)) {
                            ClosureExpression closureExpression =
                                    (ClosureExpression)expressions.get(0);
                            Statement block = closureExpression.getCode();
                            if (block instanceof BlockStatement) {
                                BlockStatement bs = (BlockStatement)block;
                                for (Statement statement : bs.getStatements()) {
                                    if (statement instanceof ExpressionStatement) {
                                        ExpressionStatement e = (ExpressionStatement)statement;
View Full Code Here

    }
  }

  @Override
  public final void visitClosureExpression(ClosureExpression expr) {
    ClosureExpression oldClosure = currClosure;
    currClosure = expr;
    boolean oldConditionFound = conditionFound;
    conditionFound = false; // any closure terminates conditionFound scope
    ISpecialMethodCall oldSpecialMethodCall = currSpecialMethodCall;
    if (!currSpecialMethodCall.isMatch(expr)) {
View Full Code Here

TOP

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

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.