PsiField (@NotNull PsiRecordComponent component, @NotNull PsiElementFactory factory) { String name = component.getName(); if (hasForbiddenType(component)) return null; String typeText = getTypeText(component); if (typeText == null) return null; try { return factory.createFieldFromText("private final " + typeText + " " + name + ";", component.getContainingClass()); } catch (IncorrectOperationException e) { // typeText could be unparseable, like '@int' return null; } }