当前位置: 首页>>代码示例>>Java>>正文


Java BlockStatement.getStatements方法代码示例

本文整理汇总了Java中org.codehaus.groovy.ast.stmt.BlockStatement.getStatements方法的典型用法代码示例。如果您正苦于以下问题:Java BlockStatement.getStatements方法的具体用法?Java BlockStatement.getStatements怎么用?Java BlockStatement.getStatements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.groovy.ast.stmt.BlockStatement的用法示例。


在下文中一共展示了BlockStatement.getStatements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
@Override
public void call(SourceUnit source) throws CompilationFailedException {
    BlockStatement statementBlock = source.getAST().getStatementBlock();
    List<Statement> statements = statementBlock.getStatements();
    for (Statement statement : statements) {
        if (!AstUtils.mayHaveAnEffect(statement)) {
            continue;
        }
        ScriptBlock scriptBlock = AstUtils.detectScriptBlock(statement);
        if (scriptBlock != null && scriptBlock.getName().equals(ModelBlockTransformer.MODEL)) {
            continue;
        }
        imperativeStatementDetected = true;
        break;
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:ImperativeStatementDetectingTransformer.java

示例2: visitClosureExpression

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
@Override
public void visitClosureExpression(final ClosureExpression expression) {
    super.visitClosureExpression(expression);
    if (inBuilderMethod) {
        Statement oldCode = expression.getCode();
        BlockStatement block = oldCode instanceof BlockStatement?
                ((BlockStatement)oldCode):
                new BlockStatement(Arrays.asList(oldCode), new VariableScope());
        List<Statement> statements = block.getStatements();
        if (!statements.isEmpty()) {
            Statement first = statements.get(0);
            Statement last = statements.get(statements.size()-1);
            if (expression.getLineNumber()<first.getLineNumber()) {
                // there's a new line between { -> ... and the first statement
                statements.add(0,createNewLine(expression));
            }
            if (expression.getLastLineNumber()>last.getLastLineNumber()) {
                // there's a new line between { -> ... and the first statement
                statements.add(createNewLine(expression));
            }
        }
        expression.setCode(block);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:25,代码来源:AutoNewLineTransformer.java

示例3: checkThisAndSuperConstructorCall

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
private ConstructorCallExpression checkThisAndSuperConstructorCall(Statement statement) {
    if (!(statement instanceof BlockStatement)) { // method code must be a BlockStatement
        return null;
    }

    BlockStatement blockStatement = (BlockStatement) statement;
    List<Statement> statementList = blockStatement.getStatements();

    for (int i = 0, n = statementList.size(); i < n; i++) {
        Statement s = statementList.get(i);
        if (s instanceof ExpressionStatement) {
            Expression expression = ((ExpressionStatement) s).getExpression();
            if ((expression instanceof ConstructorCallExpression) && 0 != i) {
                return (ConstructorCallExpression) expression;
            }
        }
    }

    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:AstBuilder.java

示例4: positionStmtsAfterEnumInitStmts

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
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();
                    if (fExp.getFieldName().equals("$VALUES")) {
                        for (Statement tmpStmt : staticFieldStatements) {
                            litr.add(tmpStmt);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:ClassNode.java

示例5: copyStatementsWithSuperAdjustment

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
public static boolean copyStatementsWithSuperAdjustment(ClosureExpression pre, BlockStatement body) {
    Statement preCode = pre.getCode();
    boolean changed = false;
    if (preCode instanceof BlockStatement) {
        BlockStatement block = (BlockStatement) preCode;
        List<Statement> statements = block.getStatements();
        for (int i = 0; i < statements.size(); i++) {
            Statement statement = statements.get(i);
            // adjust the first statement if it's a super call
            if (i == 0 && statement instanceof ExpressionStatement) {
                ExpressionStatement es = (ExpressionStatement) statement;
                Expression preExp = es.getExpression();
                if (preExp instanceof MethodCallExpression) {
                    MethodCallExpression mce = (MethodCallExpression) preExp;
                    String name = mce.getMethodAsString();
                    if ("super".equals(name)) {
                        es.setExpression(new ConstructorCallExpression(ClassNode.SUPER, mce.getArguments()));
                        changed = true;
                    }
                }
            }
            body.addStatement(statement);
        }
    }
    return changed;
}
 
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:GeneralUtils.java

示例6: visitBlockStatement

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
@Override
public void visitBlockStatement(BlockStatement block) {
    opt.push();
    boolean optAll = true;
    for (Statement statement : block.getStatements()) {
        opt.push();
        statement.visit(this);
        optAll = optAll && opt.canOptimize();
        opt.pop(true);
    }
    if (block.isEmpty()) {
        opt.chainCanOptimize(true);
        opt.pop(true);
    } else {
        opt.chainShouldOptimize(optAll);
        if (optAll) addMeta(block,opt);
        opt.pop(optAll);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:OptimizingStatementWriter.java

示例7: getConstructorCallExpression

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
private static ConstructorCallExpression getConstructorCallExpression(ConstructorNode constructorNode) {
    Statement code = constructorNode.getCode();
    if (!(code instanceof BlockStatement))
        return null;

    BlockStatement block = (BlockStatement) code;
    List stats = block.getStatements();
    if (stats == null || stats.isEmpty())
        return null;

    Statement stat = (Statement) stats.get(0);
    if (!(stat instanceof ExpressionStatement))
        return null;

    Expression expr = ((ExpressionStatement) stat).getExpression();
    if (!(expr instanceof ConstructorCallExpression))
        return null;

    return (ConstructorCallExpression) expr;
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:JavaStubGenerator.java

示例8: visitBlockStatement

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
@Override
public void visitBlockStatement(BlockStatement block) {
    block.setNodeMetaData(AST_NODE_METADATA_KEY, true);

    for (Statement statement : block.getStatements()) {
        statement.visit(this);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:9,代码来源:RulesVisitor.java

示例9: completeFutureByResults

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
protected void completeFutureByResults(CompletableFuture<EGradleBuildscriptResult> future, List<ASTNode> result) {
	for (ASTNode node : result) {
		BlockStatement bs = (BlockStatement) node;
		for (org.codehaus.groovy.ast.stmt.Statement st : bs.getStatements()) {
			if (st instanceof ReturnStatement) {
				ReturnStatement rs = (ReturnStatement) st;
				Expression expression = rs.getExpression();
				if (expression instanceof DeclarationExpression) {
					DeclarationExpression de = (DeclarationExpression) expression;
					String name = de.getVariableExpression().getName();
					if (! "buildscript".equals(name)){
						continue;
					}
					Expression right = de.getRightExpression();
					if (right instanceof ClosureExpression) {
						ClosureExpression ce = (ClosureExpression) right;
						Statement buildCode = ce.getCode();
						
						future.complete(new EGradleBuildscriptResult(buildCode));
						return;
					}else{
						future.complete(new EGradleBuildscriptResult(new EGradleBuildScriptException("Did not found expected buildscript closure ,but:"+right)));
						return;
					}
				}
			}
		}
	}
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:30,代码来源:GradleBuildScriptResultBuilder.java

示例10: getExpressionStatements

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
private static List<ExpressionStatement> getExpressionStatements(
		BlockStatement block) {
	ArrayList<ExpressionStatement> statements = new ArrayList<ExpressionStatement>();
	for (Statement statement : block.getStatements()) {
		if (statement instanceof ExpressionStatement) {
			statements.add((ExpressionStatement) statement);
		}
	}
	return statements;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:AstUtils.java

示例11: extractModelTypesFromStatement

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
private void extractModelTypesFromStatement(final Statement code, final Map<String, ClassNode> model) {
    if (code instanceof BlockStatement) {
        BlockStatement block = (BlockStatement) code;
        for (Statement statement : block.getStatements()) {
            extractModelTypesFromStatement(statement, model);
        }
    } else if (code instanceof ExpressionStatement) {
        Expression expression = ((ExpressionStatement) code).getExpression();
        if (expression instanceof DeclarationExpression) {
            VariableExpression var = ((DeclarationExpression) expression).getVariableExpression();
            model.put(var.getName(), var.getOriginType());
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:15,代码来源:MarkupBuilderCodeTransformer.java

示例12: getFirstIfSpecialConstructorCall

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
private static ConstructorCallExpression getFirstIfSpecialConstructorCall(BlockStatement code) {
    if (code == null) return null;

    final List<Statement> statementList = code.getStatements();
    if (statementList.isEmpty()) return null;

    final Statement statement = statementList.get(0);
    if (!(statement instanceof ExpressionStatement)) return null;

    Expression expression = ((ExpressionStatement) statement).getExpression();
    if (!(expression instanceof ConstructorCallExpression)) return null;
    ConstructorCallExpression cce = (ConstructorCallExpression) expression;
    if (cce.isSpecialCall()) return cce;
    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:InnerClassCompletionVisitor.java

示例13: writeBlockStatement

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
public void writeBlockStatement(BlockStatement block) {
    CompileStack compileStack = controller.getCompileStack();

    //GROOVY-4505 use no line number information for the block
    writeStatementLabel(block);
    
    int mark = controller.getOperandStack().getStackLength();
    compileStack.pushVariableScope(block.getVariableScope());
    for (Statement statement : block.getStatements()) {
        statement.visit(controller.getAcg());
    }
    compileStack.pop();

    controller.getOperandStack().popDownTo(mark);
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:StatementWriter.java

示例14: inspectBlockStatement

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
private void inspectBlockStatement(int childIndent, BlockStatement blockStatement) {
	List<Statement> children = blockStatement.getStatements();
	for (Statement child : children) {
		inspect(child, childIndent);
	}
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:7,代码来源:GradleBuildScriptResultInspector.java

示例15: visitBlockStatement

import org.codehaus.groovy.ast.stmt.BlockStatement; //导入方法依赖的package包/类
public void visitBlockStatement(final BlockStatement block) {
    assertStatementAuthorized(block);
    for (Statement statement : block.getStatements()) {
        statement.visit(this);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:SecureASTCustomizer.java


注:本文中的org.codehaus.groovy.ast.stmt.BlockStatement.getStatements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。