GrMethod (PsiField field) { GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(field.getProject()); String name = field.getName(); String getName = getGetterNameNonBoolean(field.getName()); try { PsiType type = field instanceof GrField ? ((GrField)field).getDeclaredType() : field.getType(); GrMethod getter = factory.createMethod(getName, type); if (field.hasModifierProperty(PsiModifier.STATIC)) { PsiUtil.setModifierProperty(getter, PsiModifier.STATIC, true); } annotateWithNullableStuff(field, getter); GrCodeBlock body = factory.createMethodBodyFromText("\nreturn " + name + "\n"); getter.getBlock().replace(body); return getter; } catch (IncorrectOperationException e) { LOG.error(e); return null; } }