private void generateClosureMainMethod(@NotNull GrClosableBlock block) {
    builder.append("public ");
    final PsiType returnType = context.typeProvider.getReturnType(block);
    TypeWriter.writeType(builder, returnType, block);
    builder.append(" doCall");
    final GrParameter[] parameters = block.getAllParameters();
    GenerationUtil.writeParameterList(builder, parameters, new GeneratorClassNameProvider(), context);

    Collection<GrStatement> myExitPoints = !PsiTypes.voidType().equals(returnType) ? ControlFlowUtils.collectReturns(block) : Collections.emptySet();
    boolean shouldInsertReturnNull = !(returnType instanceof PsiPrimitiveType) &&
                                     MissingReturnInspection.methodMissesSomeReturns(block, MissingReturnInspection.ReturnStatus.shouldNotReturnValue);

    new CodeBlockGenerator(builder, context.extend(), myExitPoints).generateCodeBlock(parameters, block, shouldInsertReturnNull);
    builder.append('\n');
  }
private void generateClosureMainMethod(@NotNull GrClosableBlock block)