Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
13,300
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder) { if (checkWrongType(psiClass)) { builder.addErrorMessage("inspection.message.standardexception.class.only.supported.on.class"); return false; } if (checkWrongInheritorOfThrowable(psiClass)) { builder.addErrorMessage("inspection.message.standardexception.should.extend.throwable"); return false; } if (checkWrongAccessVisibility(psiAnnotation)) { builder.addErrorMessage("inspection.message.standardexception.accesslevel.none.not.valid"); //log error but continue } return true; }
validate
13,301
boolean (@NotNull PsiClass psiClass) { return psiClass.isInterface() || psiClass.isAnnotationType() || psiClass.isEnum() || psiClass.isRecord(); }
checkWrongType
13,302
boolean (@NotNull PsiClass psiClass) { return !InheritanceUtil.isInheritor(psiClass, CommonClassNames.JAVA_LANG_THROWABLE); }
checkWrongInheritorOfThrowable
13,303
boolean (@NotNull PsiAnnotation psiAnnotation) { return null == LombokProcessorUtil.getAccessVisibility(psiAnnotation); }
checkWrongAccessVisibility
13,304
void (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { final PsiManager psiManager = psiClass.getManager(); final Collection<PsiMethod> existedConstructors = PsiClassUtil.collectClassConstructorIntern(psiClass); final String accessVisibility = getAccessVisibility(psiAnnotation); // default constructor if (noConstructorWithParamsOfTypesDefined(existedConstructors)) { target.add(createConstructor(psiClass, psiAnnotation, psiManager, accessVisibility).withBodyText("this(null, null);")); } final GlobalSearchScope psiClassResolveScope = psiClass.getResolveScope(); final PsiClassType javaLangStringType = PsiType.getJavaLangString(psiManager, psiClassResolveScope); final PsiClassType javaLangThrowableType = PsiType.getJavaLangThrowable(psiManager, psiClassResolveScope); final boolean addConstructorProperties = ConfigDiscovery.getInstance().getBooleanLombokConfigProperty(ConfigKey.ANYCONSTRUCTOR_ADD_CONSTRUCTOR_PROPERTIES, psiClass); // message constructor if (noConstructorWithParamsOfTypesDefined(existedConstructors, javaLangStringType)) { final LombokLightMethodBuilder messageConstructor = createConstructor(psiClass, psiAnnotation, psiManager, accessVisibility) .withFinalParameter("message", javaLangStringType) .withBodyText("this(message, null);"); if (addConstructorProperties) { messageConstructor.withAnnotation("java.beans.ConstructorProperties(\"message\")"); } target.add(messageConstructor); } // cause constructor if (noConstructorWithParamsOfTypesDefined(existedConstructors, javaLangThrowableType)) { final LombokLightMethodBuilder causeConstructor = createConstructor(psiClass, psiAnnotation, psiManager, accessVisibility) .withFinalParameter("cause", javaLangThrowableType) .withBodyText("this(cause != null ? cause.getMessage() : null, cause);"); if (addConstructorProperties) { causeConstructor.withAnnotation("java.beans.ConstructorProperties(\"cause\")"); } target.add(causeConstructor); } // message and cause constructor if (noConstructorWithParamsOfTypesDefined(existedConstructors, javaLangStringType, javaLangThrowableType)) { final LombokLightMethodBuilder messageCauseConstructor = createConstructor(psiClass, psiAnnotation, psiManager, accessVisibility) .withFinalParameter("message", javaLangStringType) .withFinalParameter("cause", javaLangThrowableType) .withBodyText("super(message);\n" + "if (cause != null) super.initCause(cause);"); if (addConstructorProperties) { messageCauseConstructor.withAnnotation("java.beans.ConstructorProperties({\"message\",\"cause\"})"); } target.add(messageCauseConstructor); } }
generatePsiElements
13,305
String (@NotNull PsiAnnotation psiAnnotation) { String accessVisibility = LombokProcessorUtil.getAccessVisibility(psiAnnotation); if (null == accessVisibility) { accessVisibility = PsiModifier.PUBLIC; } return accessVisibility; }
getAccessVisibility
13,306
boolean (Collection<PsiMethod> existedConstructors, PsiClassType... classTypes) { return !ContainerUtil.exists(existedConstructors, method -> { final PsiParameterList parameterList = method.getParameterList(); if (parameterList.getParametersCount() != classTypes.length) { return false; } int paramIndex = 0; for (PsiClassType classType : classTypes) { if (!PsiTypesUtil.compareTypes(parameterList.getParameter(paramIndex).getType(), classType, true)) { return false; } paramIndex++; } return true; }); }
noConstructorWithParamsOfTypesDefined
13,307
LombokLightMethodBuilder (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiManager psiManager, @PsiModifier.ModifierConstant String accessVisibility) { return new LombokLightMethodBuilder(psiManager, getConstructorName(psiClass)) .withConstructor(true) .withContainingClass(psiClass) .withNavigationElement(psiAnnotation) .withModifier(accessVisibility); }
createConstructor
13,308
boolean (@NotNull String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return nameHint.equals(psiClass.getName()); }
possibleToGenerateElementNamed
13,309
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return Collections.singleton(psiClass.getName()); }
getNamesOfPossibleGeneratedElements
13,310
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder) { return validateOnRightType(psiClass, builder) && validateNoConstructorsDefined(psiClass, builder); }
validate
13,311
boolean (PsiClass psiClass, ProblemSink builder) { Collection<PsiMethod> psiMethods = PsiClassUtil.collectClassConstructorIntern(psiClass); if (!psiMethods.isEmpty()) { builder.addErrorMessage("inspection.message.utility.classes.cannot.have.declared.constructors"); return false; } return true; }
validateNoConstructorsDefined
13,312
boolean (PsiClass psiClass, ProblemSink builder) { if (checkWrongType(psiClass)) { builder.addErrorMessage("inspection.message.utility.class.only.supported.on.class"); return false; } PsiElement context = psiClass.getContext(); if (context == null) { return false; } if (!(context instanceof PsiFile)) { PsiElement contextUp = context; while (true) { if (contextUp instanceof PsiClass psiClassUp) { if (psiClassUp.getContext() instanceof PsiFile) { return true; } boolean isStatic = isStatic(psiClassUp.getModifierList()); if (isStatic || checkWrongType(psiClassUp)) { contextUp = contextUp.getContext(); } else { builder.addErrorMessage("inspection.message.utility.class.automatically.makes.class.static"); return false; } } else { builder.addErrorMessage("inspection.message.utility.class.cannot.be.placed"); return false; } } } return true; }
validateOnRightType
13,313
boolean (PsiModifierList modifierList) { return modifierList != null && modifierList.hasModifierProperty(PsiModifier.STATIC); }
isStatic
13,314
boolean (PsiClass psiClass) { return psiClass != null && (psiClass.isInterface() || psiClass.isEnum() || psiClass.isAnnotationType()); }
checkWrongType
13,315
void (@NotNull final PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { LombokLightMethodBuilder constructorBuilder = new LombokLightMethodBuilder(psiClass.getManager(), psiClass.getName()) .withConstructor(true) .withContainingClass(psiClass) .withNavigationElement(psiAnnotation) .withModifier(PsiModifier.PRIVATE) .withBodyText(String.format("throw new %s(%s);", "java.lang.UnsupportedOperationException", "\"This is a utility class and cannot be instantiated\"")); target.add(constructorBuilder); }
generatePsiElements
13,316
SetterFieldProcessor () { return LombokProcessorManager.getInstance().getSetterFieldProcessor(); }
getSetterFieldProcessor
13,317
boolean (@NotNull String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { final AccessorsInfo.AccessorsValues classAccessorsValues = AccessorsInfo.getAccessorsValues(psiClass); for (PsiField psiField : PsiClassUtil.collectClassFieldsIntern(psiClass)) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField, classAccessorsValues); if (nameHint.equals(LombokUtils.getSetterName(psiField, accessorsInfo))) return true; } return false; }
possibleToGenerateElementNamed
13,318
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { Collection<String> result = new ArrayList<>(); final AccessorsInfo.AccessorsValues classAccessorsValues = AccessorsInfo.getAccessorsValues(psiClass); for (PsiField psiField : PsiClassUtil.collectClassFieldsIntern(psiClass)) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField, classAccessorsValues); result.add(LombokUtils.getSetterName(psiField, accessorsInfo)); } return result; }
getNamesOfPossibleGeneratedElements
13,319
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder) { validateAnnotationOnRightType(psiAnnotation, psiClass, builder); validateVisibility(psiAnnotation, builder); return builder.success(); }
validate
13,320
void (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder) { if (psiClass.isAnnotationType() || psiClass.isInterface() || psiClass.isEnum()) { builder.addErrorMessage("inspection.message.s.only.supported.on.class.or.field.type", psiAnnotation.getQualifiedName()); builder.markFailed(); } }
validateAnnotationOnRightType
13,321
void (@NotNull PsiAnnotation psiAnnotation, @NotNull ProblemSink builder) { if(null == LombokProcessorUtil.getMethodModifier(psiAnnotation)) { builder.markFailed(); } }
validateVisibility
13,322
void (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { final String methodVisibility = LombokProcessorUtil.getMethodModifier(psiAnnotation); if (methodVisibility != null) { target.addAll(createFieldSetters(psiClass, methodVisibility, nameHint)); } }
generatePsiElements
13,323
Collection<PsiMethod> (@NotNull PsiClass psiClass, @NotNull String methodModifier, @Nullable String nameHint) { Collection<PsiMethod> result = new ArrayList<>(); final Collection<PsiField> setterFields = filterSetterFields(psiClass); for (PsiField setterField : setterFields) { ContainerUtil.addIfNotNull(result, SetterFieldProcessor.createSetterMethod(setterField, psiClass, methodModifier, nameHint)); } return result; }
createFieldSetters
13,324
Collection<PsiField> (@NotNull PsiClass psiClass) { final Collection<PsiMethod> classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass); filterToleratedElements(classMethods); SetterFieldProcessor fieldProcessor = getSetterFieldProcessor(); final Collection<PsiField> setterFields = new ArrayList<>(); for (PsiField psiField : psiClass.getFields()) { boolean createSetter = true; PsiModifierList modifierList = psiField.getModifierList(); if (null != modifierList) { //Skip final fields. createSetter = !modifierList.hasModifierProperty(PsiModifier.FINAL); //Skip static fields. createSetter &= !modifierList.hasModifierProperty(PsiModifier.STATIC); //Skip fields having Setter annotation already createSetter &= PsiAnnotationSearchUtil.isNotAnnotatedWith(psiField, fieldProcessor.getSupportedAnnotationClasses()); //Skip fields that start with $ createSetter &= !psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER); //Skip fields if a method with same name already exists final Collection<String> methodNames = fieldProcessor.getAllSetterNames(psiField, PsiTypes.booleanType().equals(psiField.getType())); for (String methodName : methodNames) { createSetter &= !PsiMethodUtil.hasSimilarMethod(classMethods, methodName, 1); } } if (createSetter) { setterFields.add(psiField); } } return setterFields; }
filterSetterFields
13,325
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { final PsiClass containingClass = psiField.getContainingClass(); if (null != containingClass) { if (PsiClassUtil.getNames(filterSetterFields(containingClass)).contains(psiField.getName())) { return LombokPsiElementUsage.WRITE; } } return LombokPsiElementUsage.NONE; }
checkFieldUsage
13,326
GetterFieldProcessor () { return LombokProcessorManager.getInstance().getGetterFieldProcessor(); }
getGetterFieldProcessor
13,327
boolean (@NotNull String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { final AccessorsInfo.AccessorsValues classAccessorsValues = AccessorsInfo.getAccessorsValues(psiClass); for (PsiField psiField : PsiClassUtil.collectClassFieldsIntern(psiClass)) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField, classAccessorsValues); if (nameHint.equals(LombokUtils.getGetterName(psiField, accessorsInfo))) return true; } return false; }
possibleToGenerateElementNamed
13,328
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { Collection<String> result = new ArrayList<>(); final AccessorsInfo.AccessorsValues classAccessorsValues = AccessorsInfo.getAccessorsValues(psiClass); for (PsiField psiField : PsiClassUtil.collectClassFieldsIntern(psiClass)) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField, classAccessorsValues); result.add(LombokUtils.getGetterName(psiField, accessorsInfo)); } return result; }
getNamesOfPossibleGeneratedElements
13,329
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder) { validateAnnotationOnRightType(psiClass, builder); validateVisibility(psiAnnotation, builder); if (builder.deepValidation()) { if (PsiAnnotationUtil.getBooleanAnnotationValue(psiAnnotation, "lazy", false)) { builder.addWarningMessage("inspection.message.lazy.not.supported.for.getter.on.type"); } } return builder.success(); }
validate
13,330
void (@NotNull PsiClass psiClass, @NotNull ProblemSink builder) { if (psiClass.isAnnotationType() || psiClass.isInterface()) { builder.addErrorMessage("inspection.message.getter.only.supported.on.class.enum.or.field.type"); builder.markFailed(); } }
validateAnnotationOnRightType
13,331
void (@NotNull PsiAnnotation psiAnnotation, @NotNull ProblemSink builder) { if (null == LombokProcessorUtil.getMethodModifier(psiAnnotation)) { builder.markFailed(); } }
validateVisibility
13,332
void (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { final String methodVisibility = LombokProcessorUtil.getMethodModifier(psiAnnotation); if (methodVisibility != null) { target.addAll(createFieldGetters(psiClass, methodVisibility, nameHint)); } }
generatePsiElements
13,333
Collection<PsiMethod> (@NotNull PsiClass psiClass, @NotNull String methodModifier, @Nullable String nameHint) { Collection<PsiMethod> result = new ArrayList<>(); final Collection<PsiField> getterFields = filterGetterFields(psiClass); GetterFieldProcessor fieldProcessor = getGetterFieldProcessor(); for (PsiField getterField : getterFields) { ContainerUtil.addIfNotNull(result, fieldProcessor.createGetterMethod(getterField, psiClass, methodModifier, nameHint)); } return result; }
createFieldGetters
13,334
Collection<PsiField> (@NotNull PsiClass psiClass) { final Collection<PsiField> getterFields = new ArrayList<>(); final Collection<PsiMethod> classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass); filterToleratedElements(classMethods); final AccessorsInfo.AccessorsValues classAccessorsValues = AccessorsInfo.getAccessorsValues(psiClass); GetterFieldProcessor fieldProcessor = getGetterFieldProcessor(); for (PsiField psiField : psiClass.getFields()) { boolean createGetter = true; PsiModifierList modifierList = psiField.getModifierList(); if (null != modifierList) { //Skip static fields. createGetter = !modifierList.hasModifierProperty(PsiModifier.STATIC); //Skip fields having Getter annotation already createGetter &= PsiAnnotationSearchUtil.isNotAnnotatedWith(psiField, fieldProcessor.getSupportedAnnotationClasses()); //Skip fields that start with $ createGetter &= !psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER); //Skip fields if a method with same name and arguments count already exists final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField, classAccessorsValues); final Collection<String> methodNames = LombokUtils.toAllGetterNames(accessorsInfo, psiField.getName(), PsiTypes.booleanType().equals(psiField.getType())); for (String methodName : methodNames) { createGetter &= !PsiMethodUtil.hasSimilarMethod(classMethods, methodName, 0); } } if (createGetter) { getterFields.add(psiField); } } return getterFields; }
filterGetterFields
13,335
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { final PsiClass containingClass = psiField.getContainingClass(); if (null != containingClass) { if (PsiClassUtil.getNames(filterGetterFields(containingClass)).contains(psiField.getName())) { return LombokPsiElementUsage.READ; } } return LombokPsiElementUsage.NONE; }
checkFieldUsage
13,336
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return ALL_NAMES; }
getNamesOfPossibleGeneratedElements
13,337
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink problemSink) { validateAnnotationOnRightType(psiClass, problemSink); if (problemSink.success()) { validateExistingMethods(psiClass, problemSink); } if (problemSink.deepValidation()) { final Collection<String> excludeProperty = PsiAnnotationUtil.getAnnotationValues(psiAnnotation, "exclude", String.class); final Collection<String> ofProperty = PsiAnnotationUtil.getAnnotationValues(psiAnnotation, "of", String.class); if (!excludeProperty.isEmpty() && !ofProperty.isEmpty()) { problemSink.addWarningMessage("inspection.message.exclude.are.mutually.exclusive.exclude.parameter.will.be.ignored") .withLocalQuickFixes(() -> PsiQuickFixFactory.createChangeAnnotationParameterFix(psiAnnotation, "exclude", null)); } else { validateExcludeParam(psiClass, problemSink, psiAnnotation, excludeProperty); } validateOfParam(psiClass, problemSink, psiAnnotation, ofProperty); validateCallSuperParamIntern(psiAnnotation, psiClass, problemSink); validateCallSuperParamForObject(psiAnnotation, psiClass, problemSink); } return problemSink.success(); }
validate
13,338
void (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder) { validateCallSuperParam(psiAnnotation, psiClass, builder, () -> PsiQuickFixFactory.createChangeAnnotationParameterFix(psiAnnotation, "callSuper", "false"), () -> PsiQuickFixFactory.createChangeAnnotationParameterFix(psiAnnotation, "callSuper", "true")); }
validateCallSuperParamIntern
13,339
void (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder, Supplier<LocalQuickFix>... quickFixes) { final Boolean declaredBooleanAnnotationValue = PsiAnnotationUtil.getDeclaredBooleanAnnotationValue(psiAnnotation, "callSuper"); if (null == declaredBooleanAnnotationValue) { final String configProperty = configDiscovery.getStringLombokConfigProperty(ConfigKey.EQUALSANDHASHCODE_CALL_SUPER, psiClass); if (!"CALL".equalsIgnoreCase(configProperty) && !"SKIP".equalsIgnoreCase(configProperty) && PsiClassUtil.hasSuperClass(psiClass) && !hasOneOfMethodsDefined(psiClass)) { builder.addWarningMessage("inspection.message.generating.equals.hashcode.implementation").withLocalQuickFixes(quickFixes); } } }
validateCallSuperParam
13,340
void (PsiAnnotation psiAnnotation, PsiClass psiClass, ProblemSink builder) { boolean callSuperProperty = PsiAnnotationUtil.getBooleanAnnotationValue(psiAnnotation, "callSuper", false); if (callSuperProperty && !PsiClassUtil.hasSuperClass(psiClass)) { builder.addErrorMessage("inspection.message.generating.equals.hashcode.with.super.call") .withLocalQuickFixes(() -> PsiQuickFixFactory.createChangeAnnotationParameterFix(psiAnnotation, "callSuper", "false"), () -> PsiQuickFixFactory.createChangeAnnotationParameterFix(psiAnnotation, "callSuper", null)); } }
validateCallSuperParamForObject
13,341
void (@NotNull PsiClass psiClass, @NotNull ProblemSink builder) { final boolean definedOnWrongType = psiClass.isAnnotationType() || psiClass.isInterface() || psiClass.isEnum(); if (definedOnWrongType) { builder.addErrorMessage("inspection.message.equals.and.hashcode.only.supported.on.class.type"); builder.markFailed(); } }
validateAnnotationOnRightType
13,342
void (@NotNull PsiClass psiClass, @NotNull ProblemSink builder) { if (hasOneOfMethodsDefined(psiClass)) { builder.addWarningMessage("inspection.message.not.generating.equals.hashcode"); builder.markFailed(); } }
validateExistingMethods
13,343
boolean (@NotNull PsiClass psiClass) { final Collection<PsiMethod> classMethodsIntern = PsiClassUtil.collectClassMethodsIntern(psiClass); return PsiMethodUtil.hasMethodByName(classMethodsIntern, EQUALS_METHOD_NAME, 1) || PsiMethodUtil.hasMethodByName(classMethodsIntern, HASH_CODE_METHOD_NAME, 0); }
hasOneOfMethodsDefined
13,344
void (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { target.addAll(createEqualAndHashCode(psiClass, psiAnnotation)); }
generatePsiElements
13,345
boolean (@NotNull PsiClass psiClass) { final boolean isNotDirectDescendantOfObject = PsiClassUtil.hasSuperClass(psiClass); if (isNotDirectDescendantOfObject) { return true; } final boolean isFinal = psiClass.hasModifierProperty(PsiModifier.FINAL) || (PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, LombokClassNames.VALUE) && PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.NON_FINAL)); return !isFinal; }
shouldGenerateCanEqual
13,346
PsiMethod (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, boolean hasCanEqualMethod) { final PsiManager psiManager = psiClass.getManager(); final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(psiManager, EQUALS_METHOD_NAME) .withModifier(PsiModifier.PUBLIC) .withMethodReturnType(PsiTypes.booleanType()) .withContainingClass(psiClass) .withNavigationElement(psiAnnotation) .withFinalParameter("o", PsiType.getJavaLangObject(psiManager, psiClass.getResolveScope())); LombokLightParameter parameter = methodBuilder.getParameterList().getParameter(0); if (null != parameter) { LombokAddNullAnnotations.createRelevantNullableAnnotation(psiClass, parameter); copyOnXAnnotationsForFirstParam(psiAnnotation, parameter); } methodBuilder.withBodyText(m -> { PsiClass containingClass = m.getContainingClass(); PsiAnnotation anno = (PsiAnnotation)m.getNavigationElement(); return createEqualsBlockString(containingClass, anno, hasCanEqualMethod, EqualsAndHashCodeToStringHandler.filterMembers(containingClass, anno, true, INCLUDE_ANNOTATION_METHOD, null, EQUALS_AND_HASHCODE_INCLUDE, EQUALS_AND_HASHCODE_EXCLUDE)); }); return methodBuilder; }
createEqualsMethod
13,347
PsiMethod (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { final PsiManager psiManager = psiClass.getManager(); return new LombokLightMethodBuilder(psiManager, HASH_CODE_METHOD_NAME) .withModifier(PsiModifier.PUBLIC) .withMethodReturnType(PsiTypes.intType()) .withContainingClass(psiClass) .withNavigationElement(psiAnnotation) .withBodyText(m -> { PsiClass containingClass = m.getContainingClass(); PsiAnnotation anno = (PsiAnnotation)m.getNavigationElement(); return createHashcodeBlockString(containingClass, anno, EqualsAndHashCodeToStringHandler.filterMembers(containingClass, anno, true, INCLUDE_ANNOTATION_METHOD, null, EQUALS_AND_HASHCODE_INCLUDE, EQUALS_AND_HASHCODE_EXCLUDE)); }); }
createHashCodeMethod
13,348
PsiMethod (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { final PsiManager psiManager = psiClass.getManager(); final String blockText = String.format("return other instanceof %s;", PsiTypesUtil.getClassType(psiClass).getCanonicalText()); final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(psiManager, CAN_EQUAL_METHOD_NAME) .withModifier(PsiModifier.PROTECTED) .withMethodReturnType(PsiTypes.booleanType()) .withContainingClass(psiClass) .withNavigationElement(psiAnnotation) .withFinalParameter("other", PsiType.getJavaLangObject(psiManager, psiClass.getResolveScope())); LombokLightParameter parameter = methodBuilder.getParameterList().getParameter(0); if (null != parameter) { LombokAddNullAnnotations.createRelevantNullableAnnotation(psiClass, parameter); copyOnXAnnotationsForFirstParam(psiAnnotation, parameter); } methodBuilder.withBodyText(blockText); return methodBuilder; }
createCanEqualMethod
13,349
void (@NotNull PsiAnnotation psiAnnotation, @NotNull LombokLightParameter lightParameter) { PsiModifierList methodParameterModifierList = lightParameter.getModifierList(); LombokCopyableAnnotations.copyOnXAnnotations(psiAnnotation, methodParameterModifierList, "onParam"); }
copyOnXAnnotationsForFirstParam
13,350
String (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, boolean hasCanEqualMethod, Collection<MemberInfo> memberInfos) { final boolean callSuper = readCallSuperAnnotationOrConfigProperty(psiAnnotation, psiClass, ConfigKey.EQUALSANDHASHCODE_CALL_SUPER); final boolean doNotUseGetters = readAnnotationOrConfigProperty(psiAnnotation, psiClass, "doNotUseGetters", ConfigKey.EQUALSANDHASHCODE_DO_NOT_USE_GETTERS); final String canonicalClassName = PsiTypesUtil.getClassType(psiClass).getCanonicalText(); final String canonicalWildcardClassName = PsiClassUtil.getWildcardClassType(psiClass).getCanonicalText(); final StringBuilder builder = new StringBuilder(); builder.append("if (o == this) return true;\n"); builder.append("if (!(o instanceof ").append(canonicalClassName).append(")) return false;\n"); builder.append("final ").append(canonicalWildcardClassName).append(" other = (").append(canonicalWildcardClassName).append(")o;\n"); if (hasCanEqualMethod) { builder.append("if (!other.canEqual((java.lang.Object)this)) return false;\n"); } if (callSuper) { builder.append("if (!super.equals(o)) return false;\n"); } for (MemberInfo memberInfo : memberInfos) { final String memberAccessor = EqualsAndHashCodeToStringHandler.getMemberAccessorName(memberInfo, doNotUseGetters, psiClass); final PsiType memberType = memberInfo.getType(); if (memberType instanceof PsiPrimitiveType) { if (PsiTypes.floatType().equals(memberType)) { builder.append("if (java.lang.Float.compare(this.").append(memberAccessor).append(", other.").append(memberAccessor) .append(") != 0) return false;\n"); } else if (PsiTypes.doubleType().equals(memberType)) { builder.append("if (java.lang.Double.compare(this.").append(memberAccessor).append(", other.").append(memberAccessor) .append(") != 0) return false;\n"); } else { builder.append("if (this.").append(memberAccessor).append(" != other.").append(memberAccessor).append(") return false;\n"); } } else if (memberType instanceof PsiArrayType) { final PsiType componentType = ((PsiArrayType)memberType).getComponentType(); if (componentType instanceof PsiPrimitiveType) { builder.append("if (!java.util.Arrays.equals(this.").append(memberAccessor).append(", other.").append(memberAccessor) .append(")) return false;\n"); } else { builder.append("if (!java.util.Arrays.deepEquals(this.").append(memberAccessor).append(", other.").append(memberAccessor) .append(")) return false;\n"); } } else { final String memberName = memberInfo.getName(); builder.append("final java.lang.Object this$").append(memberName).append(" = this.").append(memberAccessor).append(";\n"); builder.append("final java.lang.Object other$").append(memberName).append(" = other.").append(memberAccessor).append(";\n"); builder.append("if (this$").append(memberName).append(" == null ? other$").append(memberName).append(" != null : !this$") .append(memberName).append(".equals(other$").append(memberName).append(")) return false;\n"); } } builder.append("return true;\n"); return builder.toString(); }
createEqualsBlockString
13,351
String (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, Collection<MemberInfo> memberInfos) { final boolean callSuper = readCallSuperAnnotationOrConfigProperty(psiAnnotation, psiClass, ConfigKey.EQUALSANDHASHCODE_CALL_SUPER); final boolean doNotUseGetters = readAnnotationOrConfigProperty(psiAnnotation, psiClass, "doNotUseGetters", ConfigKey.EQUALSANDHASHCODE_DO_NOT_USE_GETTERS); final StringBuilder builder = new StringBuilder(); if (!memberInfos.isEmpty()) { builder.append("final int PRIME = ").append(PRIME_FOR_HASHCODE).append(";\n"); } builder.append("int result = "); if (callSuper) { builder.append("super.hashCode();\n"); } else { builder.append("1;\n"); } for (MemberInfo memberInfo : memberInfos) { final String memberAccessor = EqualsAndHashCodeToStringHandler.getMemberAccessorName(memberInfo, doNotUseGetters, psiClass); final String memberName = memberInfo.getMethod() == null ? memberInfo.getName() : "$" + memberInfo.getName(); final PsiType classFieldType = memberInfo.getType(); if (classFieldType instanceof PsiPrimitiveType) { if (PsiTypes.booleanType().equals(classFieldType)) { builder.append("result = result * PRIME + (this.").append(memberAccessor).append(" ? ").append(PRIME_FOR_TRUE).append(" : ") .append(PRIME_FOR_FALSE).append(");\n"); } else if (PsiTypes.longType().equals(classFieldType)) { builder.append("final long $").append(memberName).append(" = this.").append(memberAccessor).append(";\n"); builder.append("result = result * PRIME + (int)($").append(memberName).append(" >>> 32 ^ $").append(memberName).append(");\n"); } else if (PsiTypes.floatType().equals(classFieldType)) { builder.append("result = result * PRIME + java.lang.Float.floatToIntBits(this.").append(memberAccessor).append(");\n"); } else if (PsiTypes.doubleType().equals(classFieldType)) { builder.append("final long $").append(memberName).append(" = java.lang.Double.doubleToLongBits(this.").append(memberAccessor) .append(");\n"); builder.append("result = result * PRIME + (int)($").append(memberName).append(" >>> 32 ^ $").append(memberName).append(");\n"); } else { builder.append("result = result * PRIME + this.").append(memberAccessor).append(";\n"); } } else if (classFieldType instanceof PsiArrayType) { final PsiType componentType = ((PsiArrayType)classFieldType).getComponentType(); if (componentType instanceof PsiPrimitiveType) { builder.append("result = result * PRIME + java.util.Arrays.hashCode(this.").append(memberAccessor).append(");\n"); } else { builder.append("result = result * PRIME + java.util.Arrays.deepHashCode(this.").append(memberAccessor).append(");\n"); } } else { builder.append("final java.lang.Object $").append(memberName).append(" = this.").append(memberAccessor).append(";\n"); builder.append("result = result * PRIME + ($").append(memberName).append(" == null ? " + PRIME_FOR_NULL + " : $").append(memberName) .append(".hashCode());\n"); } } builder.append("return result;\n"); return builder.toString(); }
createHashcodeBlockString
13,352
Collection<PsiAnnotation> (@NotNull PsiClass psiClass) { final Collection<PsiAnnotation> result = super.collectProcessedAnnotations(psiClass); addFieldsAnnotation(result, psiClass, EQUALS_AND_HASHCODE_INCLUDE, EQUALS_AND_HASHCODE_EXCLUDE); return result; }
collectProcessedAnnotations
13,353
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { final PsiClass containingClass = psiField.getContainingClass(); if (null != containingClass) { final String psiFieldName = psiField.getName(); if (EqualsAndHashCodeToStringHandler.filterMembers(containingClass, psiAnnotation, true, INCLUDE_ANNOTATION_METHOD, null, EQUALS_AND_HASHCODE_INCLUDE, EQUALS_AND_HASHCODE_EXCLUDE).stream() .map(MemberInfo::getName).anyMatch(psiFieldName::equals)) { return LombokPsiElementUsage.READ; } } return LombokPsiElementUsage.NONE; }
checkFieldUsage
13,354
WitherFieldProcessor () { return LombokProcessorManager.getInstance().getWitherFieldProcessor(); }
getWitherFieldProcessor
13,355
boolean (@NotNull String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { if (!nameHint.startsWith("with")) return false; final Collection<? extends PsiVariable> possibleWithElements = getPossibleWithElements(psiClass); if (possibleWithElements.isEmpty()) return false; final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiClass).withFluent(false); for (PsiVariable possibleWithElement : possibleWithElements) { if (nameHint.equals(LombokUtils.getWitherName(possibleWithElement, accessorsInfo))) return true; } return false; }
possibleToGenerateElementNamed
13,356
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { Collection<String> result = new ArrayList<>(); final Collection<? extends PsiVariable> possibleWithElements = getPossibleWithElements(psiClass); if (!possibleWithElements.isEmpty()) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiClass).withFluent(false); for (PsiVariable possibleWithElement : possibleWithElements) { result.add(LombokUtils.getWitherName(possibleWithElement, accessorsInfo)); } } return result; }
getNamesOfPossibleGeneratedElements
13,357
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder) { validateAnnotationOnRightType(psiClass, builder); validateVisibility(psiAnnotation, builder); if (builder.success()) { WitherFieldProcessor.validConstructor(psiClass, builder); } return builder.success(); }
validate
13,358
void (@NotNull PsiClass psiClass, @NotNull ProblemSink builder) { if (psiClass.isAnnotationType() || psiClass.isInterface() || psiClass.isEnum()) { builder.addErrorMessage("inspection.message.wither.only.supported.on.class.or.field"); builder.markFailed(); } }
validateAnnotationOnRightType
13,359
void (@NotNull PsiAnnotation psiAnnotation, @NotNull ProblemSink builder) { if (null == LombokProcessorUtil.getMethodModifier(psiAnnotation)) { builder.markFailed(); } }
validateVisibility
13,360
void (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { final String methodVisibility = LombokProcessorUtil.getMethodModifier(psiAnnotation); if (methodVisibility != null) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiClass).withFluent(false); target.addAll(createFieldWithers(psiClass, methodVisibility, accessorsInfo)); } }
generatePsiElements
13,361
Collection<PsiMethod> (@NotNull PsiClass psiClass, @NotNull String methodModifier, @NotNull AccessorsInfo accessors) { Collection<PsiMethod> result = new ArrayList<>(); final Collection<PsiField> witherFields = getWitherFields(psiClass); for (PsiField witherField : witherFields) { PsiMethod method = getWitherFieldProcessor().createWitherMethod(witherField, methodModifier, accessors); if (method != null) { result.add(method); } } return result; }
createFieldWithers
13,362
Collection<PsiField> (@NotNull PsiClass psiClass) { Collection<PsiField> witherFields = new ArrayList<>(); for (PsiField psiField : psiClass.getFields()) { boolean createWither = true; PsiModifierList modifierList = psiField.getModifierList(); if (null != modifierList) { // Skip static fields. createWither = !modifierList.hasModifierProperty(PsiModifier.STATIC); // Skip final fields that are initialized and not annotated with @Builder.Default createWither &= !(modifierList.hasModifierProperty(PsiModifier.FINAL) && psiField.hasInitializer() && PsiAnnotationSearchUtil.findAnnotation(psiField, BUILDER_DEFAULT_ANNOTATION) == null); // Skip fields that start with $ createWither &= !psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER); // Skip fields having Wither annotation already createWither &= !PsiAnnotationSearchUtil.isAnnotatedWith(psiField, LombokClassNames.WITHER, LombokClassNames.WITH); } if (createWither) { witherFields.add(psiField); } } return witherFields; }
getWitherFields
13,363
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { final PsiClass containingClass = psiField.getContainingClass(); if (null != containingClass) { final Collection<PsiField> witherFields = getWitherFields(containingClass); if (PsiClassUtil.getNames(witherFields).contains(psiField.getName())) { return LombokPsiElementUsage.READ_WRITE; } } return LombokPsiElementUsage.NONE; }
checkFieldUsage
13,364
ToStringProcessor () { return LombokProcessorManager.getInstance().getToStringProcessor(); }
getToStringProcessor
13,365
AllArgsConstructorProcessor () { return LombokProcessorManager.getInstance().getAllArgsConstructorProcessor(); }
getAllArgsConstructorProcessor
13,366
NoArgsConstructorProcessor () { return LombokProcessorManager.getInstance().getNoArgsConstructorProcessor(); }
getNoArgsConstructorProcessor
13,367
GetterProcessor () { return LombokProcessorManager.getInstance().getGetterProcessor(); }
getGetterProcessor
13,368
EqualsAndHashCodeProcessor () { return LombokProcessorManager.getInstance().getEqualsAndHashCodeProcessor(); }
getEqualsAndHashCodeProcessor
13,369
boolean (@NotNull String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return nameHint.equals(getStaticConstructorNameValue(psiAnnotation)) || getNoArgsConstructorProcessor().possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation) || getToStringProcessor().possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation) || getEqualsAndHashCodeProcessor().possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation) || getGetterProcessor().possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation); }
possibleToGenerateElementNamed
13,370
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { Collection<String> result = new ArrayList<>(); final String staticConstructorName = getStaticConstructorNameValue(psiAnnotation); if(StringUtil.isNotEmpty(staticConstructorName)) { result.add(staticConstructorName); } result.addAll(getNoArgsConstructorProcessor().getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation)); result.addAll(getToStringProcessor().getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation)); result.addAll(getEqualsAndHashCodeProcessor().getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation)); result.addAll(getGetterProcessor().getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation)); return result; }
getNamesOfPossibleGeneratedElements
13,371
String (@NotNull PsiAnnotation psiAnnotation) { return PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, "staticConstructor", ""); }
getStaticConstructorNameValue
13,372
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder) { validateAnnotationOnRightType(psiClass, builder); if (builder.deepValidation()) { if (PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.EQUALS_AND_HASHCODE)) { getEqualsAndHashCodeProcessor().validateCallSuperParamExtern(psiAnnotation, psiClass, builder); } } return builder.success(); }
validate
13,373
void (@NotNull PsiClass psiClass, @NotNull ProblemSink builder) { if (psiClass.isAnnotationType() || psiClass.isInterface() || psiClass.isEnum()) { builder.addErrorMessage("inspection.message.value.only.supported.on.class.type"); builder.markFailed(); } }
validateAnnotationOnRightType
13,374
void (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { if (PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.GETTER)) { target.addAll(getGetterProcessor().createFieldGetters(psiClass, PsiModifier.PUBLIC, nameHint)); } if (PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.EQUALS_AND_HASHCODE)) { target.addAll(getEqualsAndHashCodeProcessor().createEqualAndHashCode(psiClass, psiAnnotation)); } if (PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.TO_STRING)) { target.addAll(getToStringProcessor().createToStringMethod(psiClass, psiAnnotation)); } // create required constructor only if there are no other constructor annotations if (PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.NO_ARGS_CONSTRUCTOR, LombokClassNames.REQUIRED_ARGS_CONSTRUCTOR, LombokClassNames.ALL_ARGS_CONSTRUCTOR, LombokClassNames.BUILDER)) { final Collection<PsiMethod> definedConstructors = PsiClassUtil.collectClassConstructorIntern(psiClass); filterToleratedElements(definedConstructors); final String staticName = getStaticConstructorNameValue(psiAnnotation); final Collection<PsiField> requiredFields = AbstractConstructorClassProcessor.getAllFields(psiClass); if (getAllArgsConstructorProcessor().validateIsConstructorNotDefined(psiClass, staticName, requiredFields, new ProblemProcessingSink())) { target.addAll( getAllArgsConstructorProcessor().createAllArgsConstructor(psiClass, PsiModifier.PUBLIC, psiAnnotation, staticName, requiredFields, true)); } } if (shouldGenerateExtraNoArgsConstructor(psiClass)) { target.addAll(getNoArgsConstructorProcessor().createNoArgsConstructor(psiClass, PsiModifier.PRIVATE, psiAnnotation, true)); } }
generatePsiElements
13,375
Collection<PsiAnnotation> (@NotNull PsiClass psiClass) { final Collection<PsiAnnotation> result = super.collectProcessedAnnotations(psiClass); addClassAnnotation(result, psiClass, LombokClassNames.NON_FINAL, LombokClassNames.PACKAGE_PRIVATE); addFieldsAnnotation(result, psiClass, LombokClassNames.NON_FINAL, LombokClassNames.PACKAGE_PRIVATE); return result; }
collectProcessedAnnotations
13,376
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { return LombokPsiElementUsage.READ_WRITE; }
checkFieldUsage
13,377
ToStringProcessor () { return LombokProcessorManager.getInstance().getToStringProcessor(); }
getToStringProcessor
13,378
NoArgsConstructorProcessor () { return LombokProcessorManager.getInstance().getNoArgsConstructorProcessor(); }
getNoArgsConstructorProcessor
13,379
GetterProcessor () { return LombokProcessorManager.getInstance().getGetterProcessor(); }
getGetterProcessor
13,380
SetterProcessor () { return LombokProcessorManager.getInstance().getSetterProcessor(); }
getSetterProcessor
13,381
EqualsAndHashCodeProcessor () { return LombokProcessorManager.getInstance().getEqualsAndHashCodeProcessor(); }
getEqualsAndHashCodeProcessor
13,382
RequiredArgsConstructorProcessor () { return LombokProcessorManager.getInstance().getRequiredArgsConstructorProcessor(); }
getRequiredArgsConstructorProcessor
13,383
boolean (@NotNull String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return nameHint.equals(getStaticConstructorNameValue(psiAnnotation)) || getNoArgsConstructorProcessor().possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation) || getToStringProcessor().possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation) || getEqualsAndHashCodeProcessor().possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation) || getGetterProcessor().possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation) || getSetterProcessor().possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation); }
possibleToGenerateElementNamed
13,384
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { Collection<String> result = new ArrayList<>(); final String staticConstructorName = getStaticConstructorNameValue(psiAnnotation); if(StringUtil.isNotEmpty(staticConstructorName)) { result.add(staticConstructorName); } result.addAll(getNoArgsConstructorProcessor().getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation)); result.addAll(getToStringProcessor().getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation)); result.addAll(getEqualsAndHashCodeProcessor().getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation)); result.addAll(getGetterProcessor().getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation)); result.addAll(getSetterProcessor().getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation)); return result; }
getNamesOfPossibleGeneratedElements
13,385
String (@NotNull PsiAnnotation psiAnnotation) { return PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, "staticConstructor", ""); }
getStaticConstructorNameValue
13,386
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @NotNull ProblemSink builder) { validateAnnotationOnRightType(psiClass, builder); if (builder.deepValidation()) { final boolean hasNoEqualsAndHashCodeAnnotation = PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.EQUALS_AND_HASHCODE); if (hasNoEqualsAndHashCodeAnnotation) { getEqualsAndHashCodeProcessor().validateCallSuperParamExtern(psiAnnotation, psiClass, builder); } final String staticName = getStaticConstructorNameValue(psiAnnotation); if (shouldGenerateRequiredArgsConstructor(psiClass, staticName)) { getRequiredArgsConstructorProcessor().validateBaseClassConstructor(psiClass, builder); } } return builder.success(); }
validate
13,387
void (@NotNull PsiClass psiClass, @NotNull ProblemSink builder) { if (psiClass.isAnnotationType() || psiClass.isInterface() || psiClass.isEnum()) { builder.addErrorMessage("inspection.message.data.only.supported.on.class.type"); builder.markFailed(); } }
validateAnnotationOnRightType
13,388
void (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { if (PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.GETTER)) { target.addAll(getGetterProcessor().createFieldGetters(psiClass, PsiModifier.PUBLIC, nameHint)); } if (PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.SETTER)) { target.addAll(getSetterProcessor().createFieldSetters(psiClass, PsiModifier.PUBLIC, nameHint)); } if (PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.EQUALS_AND_HASHCODE) && getEqualsAndHashCodeProcessor().noHintOrPossibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation)) { target.addAll(getEqualsAndHashCodeProcessor().createEqualAndHashCode(psiClass, psiAnnotation)); } if (PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.TO_STRING) && getToStringProcessor().noHintOrPossibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation)) { target.addAll(getToStringProcessor().createToStringMethod(psiClass, psiAnnotation)); } final boolean hasConstructorWithoutParameters; final String staticName = getStaticConstructorNameValue(psiAnnotation); if (nameHint != null && !nameHint.equals(staticName) && !nameHint.equals(psiClass.getName())) return; if (shouldGenerateRequiredArgsConstructor(psiClass, staticName)) { target.addAll( getRequiredArgsConstructorProcessor().createRequiredArgsConstructor(psiClass, PsiModifier.PUBLIC, psiAnnotation, staticName, true)); // if there are no required field, it will already have a default constructor without parameters hasConstructorWithoutParameters = getRequiredArgsConstructorProcessor().getRequiredFields(psiClass).isEmpty(); } else { hasConstructorWithoutParameters = false; } if (!hasConstructorWithoutParameters && shouldGenerateExtraNoArgsConstructor(psiClass)) { target.addAll(getNoArgsConstructorProcessor().createNoArgsConstructor(psiClass, PsiModifier.PRIVATE, psiAnnotation, true)); } }
generatePsiElements
13,389
boolean (@NotNull PsiClass psiClass, @Nullable String staticName) { boolean result = false; // create required constructor only if there are no other constructor annotations final boolean notAnnotatedWith = PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.NO_ARGS_CONSTRUCTOR, LombokClassNames.REQUIRED_ARGS_CONSTRUCTOR, LombokClassNames.ALL_ARGS_CONSTRUCTOR, LombokClassNames.BUILDER, LombokClassNames.SUPER_BUILDER); if (notAnnotatedWith) { final RequiredArgsConstructorProcessor requiredArgsConstructorProcessor = getRequiredArgsConstructorProcessor(); final Collection<PsiField> requiredFields = requiredArgsConstructorProcessor.getRequiredFields(psiClass); result = requiredArgsConstructorProcessor.validateIsConstructorNotDefined( psiClass, staticName, requiredFields, new ProblemProcessingSink()); } return result; }
shouldGenerateRequiredArgsConstructor
13,390
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { return LombokPsiElementUsage.READ_WRITE; }
checkFieldUsage
13,391
boolean (@Nullable String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return nameHint == null || possibleToGenerateElementNamed(nameHint, psiClass, psiAnnotation); }
noHintOrPossibleToGenerateElementNamed
13,392
boolean (@NotNull String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { final Collection<String> namesOfGeneratedElements = getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation); return namesOfGeneratedElements.isEmpty() || namesOfGeneratedElements.contains(nameHint); }
possibleToGenerateElementNamed
13,393
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return Collections.emptyList(); }
getNamesOfPossibleGeneratedElements
13,394
Collection<PsiAnnotation> (@NotNull PsiClass psiClass) { Collection<PsiAnnotation> result = new ArrayList<>(); PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiClass, getSupportedAnnotationClasses()); if (null != psiAnnotation) { result.add(psiAnnotation); } return result; }
collectProcessedAnnotations
13,395
void (Collection<PsiAnnotation> result, @NotNull PsiClass psiClass, String... annotationFQNs) { PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiClass, annotationFQNs); if (null != psiAnnotation) { result.add(psiAnnotation); } }
addClassAnnotation
13,396
void (Collection<PsiAnnotation> result, @NotNull PsiClass psiClass, String... annotationFQNs) { for (PsiField psiField : PsiClassUtil.collectClassFieldsIntern(psiClass)) { PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, annotationFQNs); if (null != psiAnnotation) { result.add(psiAnnotation); } } }
addFieldsAnnotation
13,397
Collection<LombokProblem> (@NotNull PsiAnnotation psiAnnotation) { Collection<LombokProblem> result = Collections.emptyList(); // check first for fields, methods and filter it out, because PsiClass is parent of all annotations and will match other parents too PsiElement psiElement = PsiTreeUtil.getParentOfType(psiAnnotation, PsiField.class, PsiMethod.class, PsiClass.class); if (psiElement instanceof PsiClass) { ProblemValidationSink problemNewBuilder = new ProblemValidationSink(); validate(psiAnnotation, (PsiClass) psiElement, problemNewBuilder); result = problemNewBuilder.getProblems(); } return result; }
verifyAnnotation
13,398
Optional<PsiClass> (@NotNull PsiClass psiClass) { final PsiElement parentElement = psiClass.getParent(); if (parentElement instanceof PsiClass && !(parentElement instanceof LombokLightClassBuilder)) { return Optional.of((PsiClass) parentElement); } return Optional.empty(); }
getSupportedParentClass
13,399
PsiAnnotation (@NotNull PsiClass psiParentClass) { return PsiAnnotationSearchUtil.findAnnotation(psiParentClass, getSupportedAnnotationClasses()); }
getSupportedAnnotation