private void moveVariableDeclarations(List<Statement> from, List<Statement> to) {
    for (Statement stat : from) {
      DeclarationExpression declExpr = AstUtil.getExpression(stat, DeclarationExpression.class);
      if (declExpr == null) continue;

      // workaround for https://github.com/spockframework/spock/issues/2080
      if (stat.getStatementLabels() != null) {
        stat.getStatementLabels().clear();
        // necessary as Groovy 2.5 will fail with an empty list as it still uses `getStatementLabel` in some places,
        // which will throw an index out-of-bounds exception. In Groovy 3+ this call is a noop.
        stat.setStatementLabel(null);
      }

      ((ExpressionStatement) stat).setExpression(
          new BinaryExpression(
              copyLhsVariableExpressions(declExpr),
              Token.newSymbol(Types.ASSIGN, -1, -1),
              transformRhsExpressionIfNecessary(declExpr)));

      declExpr.setRightExpression(createDefaultValueInitializer(declExpr));
      to.add(new ExpressionStatement(declExpr));
    }
  }
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