/**
  * Remove an statement
  *
  * @param statement
  */
 private void remove(CtStatement statement) {
   if (statement.getParent() instanceof CtBlock) {
     ((CtBlock) statement.getParent()).removeStatement(statement);
   } else {
     CtCodeSnippetStatementImpl comment = new CtCodeSnippetStatementImpl();
     comment.setValue("/*REMOVED*/");
     statement.replace(comment);
   }
 }
  protected CtMethod apply(CtMethod method, List<Statement> statements, int index) {
    CtMethod cloned_method = AmplificationHelper.cloneMethodTest(method, "_cf", 1000);
    CtStatement stmt = getAssertStatement(cloned_method).get(index);
    statements
        .stream()
        .forEach(
            c -> {
              stmt.insertBefore((CtStatement) c.getCtCodeFragment());
              c.getCtCodeFragment().setParent(stmt.getParent());
            });

    return cloned_method;
  }
  protected List<CtLocalVariable> getLocalVarInScope(CtStatement stmt) {
    List<CtLocalVariable> vars = new ArrayList<>();
    try {
      CtBlock parentBlock = stmt.getParent(CtBlock.class);
      if (parentBlock != null) {
        boolean beforeCurrentStmt = true;
        int i = 0;
        List<CtStatement> stmts = parentBlock.getStatements();

        while (beforeCurrentStmt && i < stmts.size()) {
          CtStatement currentStatement = stmts.get(i);
          i++;
          beforeCurrentStmt = beforeCurrentStmt && currentStatement != stmt;
          if (currentStatement instanceof CtLocalVariable) {
            vars.add((CtLocalVariable) currentStatement);
          }
        }
        vars.addAll(getLocalVarInScope(parentBlock));
      }
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    return vars;
  }