private static void declareReusedLocalVariables(@NotNull List<? extends ReusedLocalVariable> reusedLocalVariables,
                                                  @NotNull PsiBlockStatement statement,
                                                  @NotNull PsiElementFactory factory) {
    PsiElement parent = statement.getParent();
    PsiCodeBlock codeBlock = statement.getCodeBlock();
    PsiStatement addAfter = statement;
    for (ReusedLocalVariable variable : reusedLocalVariables) {
      if (variable.reuseValue()) {
        PsiStatement declarationBefore = factory.createStatementFromText(variable.getTempDeclarationText(), codeBlock.getRBrace());
        parent.addBefore(declarationBefore, statement);

        PsiStatement assignment = factory.createStatementFromText(variable.getAssignmentText(), codeBlock.getRBrace());
        codeBlock.addBefore(assignment, codeBlock.getRBrace());
      }
      PsiStatement declarationAfter = factory.createStatementFromText(variable.getDeclarationText(), statement);
      parent.addAfter(declarationAfter, addAfter);
      addAfter = declarationAfter;
    }
  }
private static void declareReusedLocalVariables(@NotNull List<? extends ReusedLocalVariable> reusedLocalVariables,
                                                  @NotNull PsiBlockStatement statement,
                                                  @NotNull PsiElementFactory factory)