PsiMethod (@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.createMethodFromText("public " + typeText + " " + name + "(){ return " + name + "; }", component.getContainingClass()); } catch (IncorrectOperationException e) { // typeText could be unparseable, like '@int' return null; } }