private GrClosableBlock generateDelegateClosure(GrClosableBlock originalClosure, GrVariable anchor, String newName) {
    GrClosableBlock result;
    if (originalClosure.hasParametersSection()) {
      result = myFactory.createClosureFromText("{->}", anchor);
      final GrParameterList parameterList = (GrParameterList)originalClosure.getParameterList().copy();
      result.getParameterList().replace(parameterList);
    }
    else {
      result = myFactory.createClosureFromText("{}", anchor);
    }

    StringBuilder call = new StringBuilder();
    call.append(newName).append('(');

    final GrParameter[] parameters = result.getParameters();
    for (int i = 0; i < parameters.length; i++) {
      if (!mySettings.parametersToRemove().contains(i)) {
        call.append(parameters[i].getName()).append(", ");
      }
    }
    call.append(myParameterInitializer.getText());
    call.append(")");

    final GrStatement statement = myFactory.createStatementFromText(call.toString());
    result.addStatementBefore(statement, null);
    return result;
  }
private GrClosableBlock generateDelegateClosure(GrClosableBlock originalClosure, GrVariable anchor, String newName)