@Override public void addBuilderField( @NotNull List<PsiField> fields, @NotNull PsiVariable psiVariable, @NotNull PsiClass innerClass, @NotNull AccessorsInfo accessorsInfo) { final String fieldName = psiVariable.getName(); final PsiType fieldType = getBuilderFieldType(psiVariable.getType(), psiVariable.getProject()); final LombokLightFieldBuilder fieldBuilder = new LombokLightFieldBuilder(psiVariable.getManager(), fieldName, fieldType) .withModifier(PsiModifier.PRIVATE) .withNavigationElement(psiVariable) .withContainingClass(innerClass); fields.add(fieldBuilder); }
@Override public void addBuilderMethod( @NotNull List<PsiMethod> methods, @NotNull PsiVariable psiVariable, @NotNull PsiClass innerClass, boolean fluentBuilder, PsiType returnType, PsiAnnotation singularAnnotation, @NotNull AccessorsInfo accessorsInfo) { final String psiFieldName = psiVariable.getName(); final String singularName = createSingularName(singularAnnotation, accessorsInfo.removePrefix(psiFieldName)); final PsiType psiFieldType = psiVariable.getType(); final PsiManager psiManager = psiVariable.getManager(); final LombokLightMethodBuilder oneAddMethod = new LombokLightMethodBuilder(psiManager, singularName) .withMethodReturnType(returnType) .withContainingClass(innerClass) .withNavigationElement(psiVariable) .withModifier(PsiModifier.PUBLIC) .withBody( PsiMethodUtil.createCodeBlockFromText( getOneMethodBody(singularName, psiFieldName, fluentBuilder), innerClass)); addOneMethodParameter(singularName, psiFieldType, oneAddMethod); methods.add(oneAddMethod); final LombokLightMethodBuilder allAddMethod = new LombokLightMethodBuilder(psiManager, psiFieldName) .withMethodReturnType(returnType) .withContainingClass(innerClass) .withNavigationElement(psiVariable) .withModifier(PsiModifier.PUBLIC) .withBody( PsiMethodUtil.createCodeBlockFromText( getAllMethodBody(psiFieldName, fluentBuilder), innerClass)); addAllMethodParameter(psiFieldName, psiFieldType, allAddMethod); methods.add(allAddMethod); }
@Override public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { return myVariable != null && myVariable.isValid() && myVariable.getManager().isInProject(myVariable); }