void (@NotNull Project project, @NotNull PsiTypeElement typeElement, @NotNull PsiType withType) { PsiElementFactory pf = PsiElementFactory.getInstance(project); PsiTypeElement newTypeElement = pf.createTypeElement(withType); if (typeElement.isPhysical()) { WriteCommandAction.runWriteCommandAction(project, JavaBundle.message("command.name.replace.type"), null, () -> typeElement.replace(newTypeElement), typeElement.getContainingFile()); } else { typeElement.replace(newTypeElement); } }