private static PsiElement @NotNull [] wrapWithCodeBlock(PsiElement @NotNull [] elements, @NotNull InputVariables inputVariables) {
    PsiElement fragmentStart = elements[0];
    PsiElement fragmentEnd = elements[elements.length - 1];
    List<ReusedLocalVariable> reusedLocalVariables =
      ReusedLocalVariablesFinder.findReusedLocalVariables(fragmentStart, fragmentEnd, Collections.emptySet(), inputVariables);

    PsiElement parent = fragmentStart.getParent();
    PsiElementFactory factory = JavaPsiFacade.getElementFactory(fragmentStart.getProject());
    PsiBlockStatement statement = (PsiBlockStatement)factory.createStatementFromText("{}", parent);
    statement.getCodeBlock().addRange(fragmentStart, fragmentEnd);
    statement = (PsiBlockStatement)parent.addBefore(statement, fragmentStart);
    parent.deleteChildRange(fragmentStart, fragmentEnd);

    PsiElement[] elementsInBlock = trimBracesAndWhitespaces(statement.getCodeBlock());

    declareReusedLocalVariables(reusedLocalVariables, statement, factory);
    return elementsInBlock;
  }
private static PsiElement @NotNull [] wrapWithCodeBlock(PsiElement @NotNull [] elements, @NotNull InputVariables inputVariables)