@Override
  public void writeMethod(StringBuilder text, PsiMethod method) {
    if (method == null) return;
    String name = method.getName();
    if (!PsiNameHelper.getInstance(method.getProject()).isIdentifier(name)) {
      return; //does not have a java image
    }

    boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);

    PsiModifierList modifierList = method.getModifierList();

    ModifierListGenerator.writeModifiers(text, modifierList, STUB_MODIFIERS, false);
    if (method.hasTypeParameters()) {
      GenerationUtil.writeTypeParameters(text, method, classNameProvider);
      text.append(' ');
    }

    //append return type
    PsiType retType = method.getReturnType();
    if (retType == null) {
      retType = TypesUtil.getJavaLangObject(method);
    }

    if (!method.hasModifierProperty(PsiModifier.STATIC)) {
      final List<MethodSignatureBackedByPsiMethod> superSignatures = method.findSuperMethodSignaturesIncludingStatic(true);
      for (MethodSignatureBackedByPsiMethod superSignature : superSignatures) {
        final PsiType superType = superSignature.getSubstitutor().substitute(superSignature.getMethod().getReturnType());
        if (superType != null &&
            !superType.isAssignableFrom(retType) &&
            !(PsiUtil.resolveClassInType(superType) instanceof PsiTypeParameter)) {
          retType = superType;
        }
      }
    }

    TypeWriter.writeType(text, retType, method, classNameProvider);
    text.append(' ');

    text.append(name);


    GenerationUtil.writeParameterList(text, method.getParameterList().getParameters(), classNameProvider, null);

    writeThrowsList(text, method);

    if (!isAbstract && !method.hasModifierProperty(PsiModifier.NATIVE)) {
      // ************* body **********/
      text.append("{\nreturn ");
      text.append(GroovyToJavaGenerator.getDefaultValueText(retType.getCanonicalText()));
      text.append(";\n}");
    }
    else {
      text.append(';');
    }
    text.append('\n');
  }
@Override
  public void writeMethod(StringBuilder text, PsiMethod method)