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