Package org.codehaus.groovy.ast.stmt

Examples of org.codehaus.groovy.ast.stmt.Statement


        if (parent instanceof MethodNode) {
            MethodNode mNode = (MethodNode) parent;
            ClassNode cNode = mNode.getDeclaringClass();
            String lockExpr = determineLock(value, cNode, mNode.isStatic());
            Statement origCode = mNode.getCode();
            Statement newCode = new SynchronizedStatement(new VariableExpression(lockExpr), origCode);
            mNode.setCode(newCode);
        }
    }
View Full Code Here


    }
   
    public void addStaticInitializerStatements(List<Statement> staticStatements, boolean fieldInit) {
        MethodNode method = getOrAddStaticConstructorNode();
        BlockStatement block = null;
        Statement statement = method.getCode();
        if (statement == null) {
            block = new BlockStatement();
        }
        else if (statement instanceof BlockStatement) {
            block = (BlockStatement) statement;
View Full Code Here

        }
    }

    public void positionStmtsAfterEnumInitStmts(List<Statement> staticFieldStatements) {
        MethodNode method = getOrAddStaticConstructorNode();
        Statement statement = method.getCode();
        if (statement instanceof BlockStatement) {
            BlockStatement block = (BlockStatement) statement;
            // add given statements for explicitly declared static fields just after enum-special fields
            // are found - the $VALUES binary expression marks the end of such fields.
            List<Statement> blockStatements = block.getStatements();
            ListIterator<Statement> litr = blockStatements.listIterator();
            while (litr.hasNext()) {
                Statement stmt = litr.next();
                if (stmt instanceof ExpressionStatement &&
                        ((ExpressionStatement) stmt).getExpression() instanceof BinaryExpression) {
                    BinaryExpression bExp = (BinaryExpression) ((ExpressionStatement) stmt).getExpression();
                    if (bExp.getLeftExpression() instanceof FieldExpression) {
                        FieldExpression fExp = (FieldExpression) bExp.getLeftExpression();
View Full Code Here

        if (init != null) init.visit(this);
    }

    public void visitProperty(PropertyNode node) {
        visitAnnotations(node);
        Statement statement = node.getGetterBlock();
        visitClassCodeContainer(statement);

        statement = node.getSetterBlock();
        visitClassCodeContainer(statement);
View Full Code Here

        }
        this.setVariableScope(scope);
    }
   
    public boolean firstStatementIsSpecialConstructorCall() {
        Statement code = getFirstStatement();
        if (code == null || !(code instanceof ExpressionStatement)) return false;

        Expression expression = ((ExpressionStatement) code).getExpression();
        if (!(expression instanceof ConstructorCallExpression)) return false;
        ConstructorCallExpression cce = (ConstructorCallExpression) expression;
View Full Code Here

                            expressions.get(0) instanceof ClosureExpression) {
                        if (isInterestingBlock(parent, parentParent)) {
                            checkBlock(context, parent, parentParent, expression);
                            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

            }
            List methods = classNode.getDeclaredMethods("doCall");
            if (!methods.isEmpty()) {
                MethodNode method = (MethodNode) methods.get(0);
                if (method != null) {
                    Statement statement = method.getCode();
                    if (statement != null) {
                        statement.visit(visitor);
                    }
                }
            }
        }
    }
View Full Code Here

    }

    private void addTenantProperty(ClassNode node) {
        ClassNode integerType = new ClassNode(Integer.class);
        ConstantExpression defaultValue = new ConstantExpression(NO_TENANT_VALUE);
        Statement getterBlock = null;
        Statement setterBlock = null;
        node.addProperty(TENANT_ID_FIELD_NAME, Modifier.PUBLIC,
                integerType, defaultValue, getterBlock, setterBlock);
    }
View Full Code Here

    public void visitClass(ClassNode node) {
        visitAnnotations(node);
        node.visitContents(this);
        List list = node.getObjectInitializerStatements();
        for (Iterator iter = list.iterator(); iter.hasNext();) {
            Statement element = (Statement) iter.next();
            element.visit(this);
        }
    }
View Full Code Here

        if (code != null) code.visit(this);
    }

    protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor) {
        visitAnnotations(node);
        Statement code = node.getCode();
       
        visitClassCodeContainer(code);
    }
View Full Code Here

TOP

Related Classes of org.codehaus.groovy.ast.stmt.Statement

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.