private static @NotNull PsiDeclarationStatement addDeclaration(@NotNull PsiElement parent,
                                                                   @NotNull PsiElement anchor,
                                                                   @NotNull String varName,
                                                                   @NotNull PsiType type,
                                                                   @Nullable PsiExpression initializer) {
      PsiElementFactory elementFactory = PsiElementFactory.getInstance(parent.getProject());
      PsiType displayType;
      if (
        initializer != null
        && parent.getContext() != null
        && PsiUtil.isAvailable(JavaFeature.LVTI, parent)
        && JavaRefactoringSettings.getInstance().INTRODUCE_LOCAL_CREATE_VAR_TYPE
      ) {
        displayType = TypeUtils.getType(PsiKeyword.VAR, parent.getContext());
      } else {
        displayType = type;
      }
      PsiDeclarationStatement declaration = elementFactory
        .createVariableDeclarationStatement(varName, displayType, initializer);
      declaration = (PsiDeclarationStatement)parent.addBefore(declaration, anchor);
      JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(parent.getProject());
      return (PsiDeclarationStatement)codeStyleManager.shortenClassReferences(declaration);
    }
private static @NotNull PsiDeclarationStatement addDeclaration(@NotNull PsiElement parent,
                                                                   @NotNull PsiElement anchor,
                                                                   @NotNull String varName,
                                                                   @NotNull PsiType type,
                                                                   @Nullable PsiExpression initializer)