Package org.apache.groovy.contracts.generation

# Class AssertStatementCreationUtility.ReturnStatementVisitor

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.apache.groovy.contracts.generation.AssertStatementCreationUtility.ReturnStatementVisitor

All Implemented Interfaces:
  `GroovyClassVisitor`, `GroovyCodeVisitor`, `ErrorCollecting`

Enclosing class:
  AssertStatementCreationUtility

public static class AssertStatementCreationUtility.ReturnStatementVisitor extends ClassCodeVisitorSupport
Collects all `ReturnStatement` instances from a given code block.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ReturnStatementVisitor()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<ReturnStatement>`
  `getReturnStatements()`
  Returns the collected return statements.
  `protected SourceUnit`
  `getSourceUnit()`
  This visitor is source-independent.
  `void`
  `visitClosureExpression(ClosureExpression expression)`
  Skips nested closures so only returns from the surrounding method are collected.
  `void`
  `visitReturnStatement(ReturnStatement statement)`
  Records one visited return statement.

  ### Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport

  `addError, visitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClass, visitClassCodeContainer, visitConstructor, visitConstructorOrMethod, visitContinueStatement, visitDeclarationExpression, visitDoWhileLoop, visitExpressionStatement, visitField, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitStatement, visitStatementAnnotations, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`

  ### Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

  `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitArrayExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitCastExpression, visitClassExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor

  `visit, visit, visitEmptyExpression, visitListOfExpressions`

- ## Constructor Details

  - ### ReturnStatementVisitor

    public ReturnStatementVisitor()

- ## Method Details

  - ### getSourceUnit

    protected SourceUnit getSourceUnit()
    This visitor is source-independent.
    Specified by:
      `getSourceUnit` in class `ClassCodeVisitorSupport`
    Returns:
      `null`

  - ### visitReturnStatement

    public void visitReturnStatement(ReturnStatement statement)
    Records one visited return statement.
    Specified by:
      `visitReturnStatement` in interface `GroovyCodeVisitor`
    Overrides:
      `visitReturnStatement` in class `ClassCodeVisitorSupport`
    Parameters:
      `statement` - the return statement to collect

  - ### visitClosureExpression

    public void visitClosureExpression(ClosureExpression expression)
    Skips nested closures so only returns from the surrounding method are collected.
    Specified by:
      `visitClosureExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitClosureExpression` in class `ClassCodeVisitorSupport`
    Parameters:
      `expression` - the closure expression to ignore

  - ### getReturnStatements

    public List<ReturnStatement> getReturnStatements()
    Returns the collected return statements.
    Returns:
      the collected return statements