@NotNull
  @Override
  public GrMethod createMethodFromSignature(@NotNull String name, @NotNull GrSignature signature) {
    StringBuilder builder = new StringBuilder(PsiKeyword.PUBLIC);
    final PsiType returnType = signature.getReturnType();
    if (returnType != null && returnType != PsiTypes.nullType()) {
      builder.append(' ');
      builder.append(returnType.getCanonicalText());
    }

    builder.append(' ').append(name).append('(');
    int i = 0;
    for (GrClosureParameter parameter : signature.getParameters()) {
      final PsiType type = parameter.getType();
      if (type != null) {
        builder.append(type.getCanonicalText());
        builder.append(' ');
      }
      builder.append('p').append(++i);
      final GrExpression initializer = parameter.getDefaultInitializer();
      if (initializer != null) {
        builder.append(" = ").append(initializer.getText());
        builder.append(", ");
      }
    }
    if (signature.getParameterCount() > 0) {
      builder.delete(builder.length() - 2, builder.length());
    }

    builder.append("){}");
    return createMethodFromText(builder);
  }
@NotNull
  @Override
  public GrMethod createMethodFromSignature(@NotNull String name, @NotNull GrSignature signature)