Java Code Examples for org.codehaus.groovy.ast.stmt.ReturnStatement#setExpression()

The following examples show how to use org.codehaus.groovy.ast.stmt.ReturnStatement#setExpression() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationConstantsVisitor.java    From groovy with Apache License 2.0 5 votes vote down vote up
private static void visitStatement(Statement statement, ClassNode returnType) {
    if (statement instanceof ReturnStatement) {
        // normal path
        ReturnStatement rs = (ReturnStatement) statement;
        rs.setExpression(transformConstantExpression(rs.getExpression(), returnType));
    } else if (statement instanceof ExpressionStatement) {
        // path for JavaStubGenerator
        ExpressionStatement es = (ExpressionStatement) statement;
        es.setExpression(transformConstantExpression(es.getExpression(), returnType));
    }
}
 
Example 2
Source File: ClassCodeExpressionTransformer.java    From groovy with Apache License 2.0 4 votes vote down vote up
@Override
public void visitReturnStatement(ReturnStatement stmt) {
    stmt.setExpression(transform(stmt.getExpression()));
}