public static PsiLocalVariable convertReturns(@NotNull Project project,
                                                PsiCodeBlock block,
                                                PsiType returnType,
                                                FinishMarker marker,
                                                int count,
                                                ProgressIndicator indicator) {
    ExitContext exitContext = new ExitContext(block, returnType, marker);
    int i=0;

    while (true) {
      indicator.checkCanceled();
      indicator.setFraction(0.3 + 0.6 * (i++) / count);
      ProgressManager.checkCanceled();
      PsiReturnStatement returnStatement = getNonTerminalReturn(block);
      if (returnStatement == null) break;
      ReturnReplacementContext.replaceSingleReturn(project, block, exitContext, returnStatement);
      if (i > count) {
        throw new IllegalStateException("Unable to convert to a single return form");
      }
    }
    indicator.setFraction(0.9);
    PsiLocalVariable resultVariable = exitContext.declareVariables();
    indicator.setFraction(0.92);
    return resultVariable;
  }
public static PsiLocalVariable convertReturns(@NotNull Project project,
                                                PsiCodeBlock block,
                                                PsiType returnType,
                                                FinishMarker marker,
                                                int count,
                                                ProgressIndicator indicator)