@NotNull
  @Override
  public GrMethod createMethod(@NotNull @NonNls String name, PsiType returnType, PsiElement context) throws IncorrectOperationException {
    @NonNls final StringBuilder builder = new StringBuilder();
    builder.append("def <T>");
    if (returnType != null) {
      builder.append(returnType.getCanonicalText());
    }
    builder.append(' ');
    if (GroovyNamesUtil.isIdentifier(name)) {
      builder.append(name);
    }
    else {
      builder.append('"');
      builder.append(GrStringUtil.escapeSymbolsForGString(name, true, false));
      builder.append('"');
    }
    builder.append("(){}");
    GrMethod method = createMethodFromText(builder.toString(), context);
    PsiTypeParameterList typeParameterList = method.getTypeParameterList();
    assert typeParameterList != null;
    typeParameterList.getFirstChild().delete();
    typeParameterList.getFirstChild().delete();
    typeParameterList.getFirstChild().delete();

    if (returnType != null) {
      method.getModifierList().setModifierProperty(GrModifier.DEF, false);
    }

    return method;
  }
@NotNull
  @Override
  public GrMethod createMethod(@NotNull @NonNls String name, PsiType returnType, PsiElement context)