Top Description Inners Fields Constructors Methods
org.codehaus.groovy.classgen

public Class ReturnAdder

extends Object
Class Inheritance
Imports
org.codehaus.groovy.ast.MethodNode, .VariableScope, org.codehaus.groovy.ast.expr.Expression, org.codehaus.groovy.ast.stmt.BlockStatement, .BreakStatement, .CaseStatement, .CatchStatement, .EmptyStatement, .ExpressionStatement, .IfStatement, .ReturnStatement, .Statement, .SwitchStatement, .SynchronizedStatement, .ThrowStatement, .TryCatchStatement, java.util.ArrayList, .Iterator, .List, .Objects

Utility class to add return statements.

Extracted from Verifier as it can be useful for some AST transformations.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
private static final ReturnAdder.ReturnStatementListener
private final boolean
doAdd

If set to 'true', then returns are effectively added.

private final ReturnAdder.ReturnStatementListener

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public static void
addReturnIfNeeded(final MethodNode node)

Deprecated Use visitMethod(MethodNode) instead.
private Statement
addReturnsIfNeeded(final Statement statement, final VariableScope scope)

private Statement
adjustSwitchCaseCode(final Statement statement, final VariableScope scope, final boolean lastCase)

private static boolean
returns(final Statement statement)

public void
visitMethod(final MethodNode node)

Adds return statements to given method whenever an implicit return is detected.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_LISTENERback to summary
private static final ReturnAdder.ReturnStatementListener DEFAULT_LISTENER
doAddback to summary
private final boolean doAdd

If set to 'true', then returns are effectively added. This is useful whenever you just want to check what returns are produced without eventually adding them.

listenerback to summary
private final ReturnAdder.ReturnStatementListener listener

Constructor Detail

ReturnAdderback to summary
public ReturnAdder()
ReturnAdderback to summary
public ReturnAdder(final ReturnAdder.ReturnStatementListener listener)

Method Detail

addReturnIfNeededback to summary
public static void addReturnIfNeeded(final MethodNode node)

Deprecated

Use visitMethod(MethodNode) instead.

Annotations
@Deprecated
addReturnsIfNeededback to summary
private Statement addReturnsIfNeeded(final Statement statement, final VariableScope scope)
adjustSwitchCaseCodeback to summary
private Statement adjustSwitchCaseCode(final Statement statement, final VariableScope scope, final boolean lastCase)
returnsback to summary
private static boolean returns(final Statement statement)
visitMethodback to summary
public void visitMethod(final MethodNode node)

Adds return statements to given method whenever an implicit return is detected.

org.codehaus.groovy.classgen back to summary

public Interface ReturnAdder.ReturnStatementListener

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public void
returnStatementAdded(ReturnStatement returnStatement)

Implement this method in order to be notified whenever a return statement is generated.

Method Detail

returnStatementAddedback to summary
public void returnStatementAdded(ReturnStatement returnStatement)

Implement this method in order to be notified whenever a return statement is generated.