private PsiTypeElement replaceTypeElement(@NotNull PsiTypeElement templateElement, @NotNull PsiType type) {
    PsiTypeElement newTypeElement = JavaPsiFacade.getElementFactory(myProject).createTypeElement(type);
    return PostprocessReformattingAspect.getInstance(myProject).disablePostprocessFormattingInside(
      () -> (PsiTypeElement)templateElement.replace(newTypeElement)
    );
  }
private PsiTypeElement replaceTypeElement(@NotNull PsiTypeElement templateElement, @NotNull PsiType type)