PsiMethod (@NotNull PsiField psiField, @NotNull PsiClass psiClass, @NotNull String methodModifier, @Nullable String nameHint) { final String fieldName = psiField.getName(); final PsiType psiFieldType = psiField.getType(); final PsiAnnotation setterAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, LombokClassNames.SETTER); final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField); final String methodName = LombokUtils.getSetterName(psiField, accessorsInfo); if (nameHint != null && !nameHint.equals(methodName)) return null; PsiType returnType = getReturnType(psiField, accessorsInfo.isChain()); LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(psiField.getManager(), methodName) .withMethodReturnType(returnType) .withContainingClass(psiClass) .withParameter(fieldName, psiFieldType) .withNavigationElement(psiField) .withMutatesThisContract(); if (StringUtil.isNotEmpty(methodModifier)) { methodBuilder.withModifier(methodModifier); } boolean isStatic = psiField.hasModifierProperty(PsiModifier.STATIC); if (isStatic) { methodBuilder.withModifier(PsiModifier.STATIC); } if (accessorsInfo.isMakeFinal()) { methodBuilder.withModifier(PsiModifier.FINAL); } LombokLightParameter setterParameter = methodBuilder.getParameterList().getParameter(0); if (null != setterParameter) { LombokLightModifierList methodParameterModifierList = setterParameter.getModifierList(); LombokCopyableAnnotations.copyCopyableAnnotations(psiField, methodParameterModifierList, LombokCopyableAnnotations.BASE_COPYABLE); LombokCopyableAnnotations.copyOnXAnnotations(setterAnnotation, methodParameterModifierList, "onParam"); } final LombokLightModifierList modifierList = methodBuilder.getModifierList(); LombokCopyableAnnotations.copyCopyableAnnotations(psiField, modifierList, LombokCopyableAnnotations.COPY_TO_SETTER); LombokCopyableAnnotations.copyOnXAnnotations(setterAnnotation, modifierList, "onMethod"); if (psiField.isDeprecated()) { modifierList.addAnnotation(CommonClassNames.JAVA_LANG_DEPRECATED); } final String codeBlockText = createCodeBlockText(psiField, psiClass, returnType, isStatic, setterParameter); methodBuilder.withBodyText(codeBlockText); if (!PsiTypes.voidType().equals(returnType)) { LombokAddNullAnnotations.createRelevantNonNullAnnotation(psiClass, methodBuilder); } return methodBuilder; }