void (StringBuilder builder, PsiMethod method) { if (method == null) return; GenerationUtil.writeDocComment(builder, method, true); String name = method.getName(); boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT); PsiModifierList modifierList = method.getModifierList(); final PsiClass containingClass = method.getContainingClass(); if (method.isConstructor() && containingClass != null && containingClass.isEnum()) { ModifierListGenerator.writeModifiers(builder, modifierList, ModifierListGenerator.ENUM_CONSTRUCTOR_MODIFIERS); } else { ModifierListGenerator.writeModifiers(builder, modifierList); } if (method.hasTypeParameters()) { GenerationUtil.writeTypeParameters(builder, method, classNameProvider); builder.append(' '); } //append return type if (!method.isConstructor()) { PsiType retType = context.typeProvider.getReturnType(method); TypeWriter.writeType(builder, retType, method, classNameProvider); builder.append(' '); } builder.append(convertToJavaIdentifier(name)); if (method instanceof GroovyPsiElement) { context.searchForLocalVarsToWrap((GroovyPsiElement)method); } GenerationUtil.writeParameterList(builder, method.getParameterList().getParameters(), classNameProvider, context); if (method instanceof GrAnnotationMethod) { GrAnnotationMemberValue defaultValue = ((GrAnnotationMethod)method).getDefaultValue(); if (defaultValue != null) { builder.append("default "); defaultValue.accept(new AnnotationGenerator(builder, context)); } } GenerationUtil.writeThrowsList(builder, method.getThrowsList(), getMethodExceptions(method), classNameProvider); if (!isAbstract) { /* ************ body ********* */ if (method instanceof GrMethod) { if (method instanceof GrReflectedMethod && ((GrReflectedMethod)method).getSkippedParameters().length > 0) { builder.append("{\n").append(generateDelegateCall((GrReflectedMethod)method)).append("\n}\n"); } else { new CodeBlockGenerator(builder, context.extend()).generateMethodBody((GrMethod)method); } } else if (method instanceof GrAccessorMethod) { writeAccessorBody(builder, method); } else if (method instanceof LightMethodBuilder && containingClass instanceof GroovyScriptClass) { if ("main".equals(method.getName())) { writeMainScriptMethodBody(builder, method); } else if ("run".equals(method.getName())) { writeRunScriptMethodBody(builder, method); } } else { builder.append("{//todo\n}"); } } else { builder.append(';'); } }