@Override
  public void visitMethodAgain(Method method) {
    this.block = null;

    if (!movedStatsBackToMethod) {
      for (Block b : method.getBlocks()) {
        // This will only run if there was no 'cleanup' block in the method.
        // Otherwise, the blocks have already been copied to try block by visitCleanupBlock.
        // We need to run as late as possible, so we'll have to do the handling here and in visitCleanupBlock.
        addBlockListeners(b);
        method.getStatements().addAll(b.getAst());
      }
    }

    // for global required interactions
    if (method instanceof FeatureMethod) {
      method.getStatements().add(createMockControllerCall(nodeCache.MockController_LeaveScope));
    }

    if (methodHasCondition) {
      errorRecorders.defineValueRecorder(method.getStatements());
    }
    if (methodHasDeepNonGroupedCondition) {
      errorRecorders.defineErrorRethrower(method.getStatements());
    }
  }
A Spec visitor responsible for most of the rewriting of a Spec's AST.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java