Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
13,100 | boolean (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull ProblemSink problemSink) { boolean result = validateAnnotationOnRightType(psiClass, psiAnnotation, problemSink); if (result) { final Project project = psiAnnotation.getProject(); final String builderClassName = getBuilderClassName(psiClass, psiAnnotation); final String buildMethodName = getBuildMethodName(psiAnnotation); final String builderMethodName = getBuilderMethodName(psiAnnotation); result = validateBuilderIdentifier(builderClassName, project, problemSink) && validateBuilderIdentifier(buildMethodName, project, problemSink) && (builderMethodName.isEmpty() || validateBuilderIdentifier(builderMethodName, project, problemSink)) && validateExistingBuilderClass(builderClassName, psiClass, problemSink); if (result) { final Collection<BuilderInfo> builderInfos = createBuilderInfos(psiClass, null).collect(Collectors.toList()); result = validateBuilderDefault(builderInfos, problemSink) && validateSingular(builderInfos, problemSink) && validateBuilderConstructor(psiClass, builderInfos, problemSink) && validateObtainViaAnnotations(builderInfos.stream(), problemSink); } } return result; } | validate |
13,101 | boolean (@NotNull PsiClass psiClass, Collection<BuilderInfo> builderInfos, @NotNull ProblemSink problemSink) { if (PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, LombokClassNames.NO_ARGS_CONSTRUCTOR) && PsiAnnotationSearchUtil.isNotAnnotatedWith(psiClass, LombokClassNames.ALL_ARGS_CONSTRUCTOR)) { if (PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, LombokClassNames.REQUIRED_ARGS_CONSTRUCTOR)) { Collection<PsiField> requiredFields = getNoArgsConstructorProcessor().getRequiredFields(psiClass); List<PsiType> requiredTypes = ContainerUtil.map(requiredFields, PsiField::getType); List<PsiType> psiTypes = ContainerUtil.map(builderInfos, BuilderInfo::getFieldType); if (requiredTypes.equals(psiTypes)) { return true; } } Optional<PsiMethod> existingConstructorForParameters = getExistingConstructorForParameters(psiClass, builderInfos); if (existingConstructorForParameters.isPresent()) { return true; } if (builderInfos.isEmpty() && PsiClassUtil.collectClassConstructorIntern(psiClass).isEmpty()) { return true; } problemSink.addErrorMessage("inspection.message.lombok.builder.needs.proper.constructor.for.this.class"); return false; } return true; } | validateBuilderConstructor |
13,102 | boolean (@NotNull Collection<BuilderInfo> builderInfos, @NotNull ProblemSink problemSink) { final Optional<BuilderInfo> anyBuilderDefaultAndSingulars = builderInfos.stream() .filter(BuilderInfo::hasBuilderDefaultAnnotation) .filter(BuilderInfo::hasSingularAnnotation).findAny(); anyBuilderDefaultAndSingulars.ifPresent(builderInfo -> { problemSink.addErrorMessage("inspection.message.builder.default.singular.cannot.be.mixed"); } ); final Optional<BuilderInfo> anyBuilderDefaultWithoutInitializer = builderInfos.stream() .filter(BuilderInfo::hasBuilderDefaultAnnotation) .filter(BuilderInfo::hasNoInitializer).findAny(); anyBuilderDefaultWithoutInitializer.ifPresent(builderInfo -> { problemSink.addErrorMessage("inspection.message.builder.default.requires.initializing.expression"); } ); return anyBuilderDefaultAndSingulars.isEmpty() || anyBuilderDefaultWithoutInitializer.isEmpty(); } | validateBuilderDefault |
13,103 | boolean (@NotNull PsiMethod psiMethod, @NotNull PsiAnnotation psiAnnotation, @NotNull ProblemSink problemSink) { final PsiClass psiClass = psiMethod.getContainingClass(); boolean result = null != psiClass; if (result) { final String builderClassName = getBuilderClassName(psiClass, psiAnnotation, psiMethod); final Project project = psiAnnotation.getProject(); final String buildMethodName = getBuildMethodName(psiAnnotation); final String builderMethodName = getBuilderMethodName(psiAnnotation); result = validateBuilderIdentifier(builderClassName, project, problemSink) && validateBuilderIdentifier(buildMethodName, project, problemSink) && (builderMethodName.isEmpty() || validateBuilderIdentifier(builderMethodName, project, problemSink)) && validateExistingBuilderClass(builderClassName, psiClass, problemSink); if (result) { final Stream<BuilderInfo> builderInfos = createBuilderInfos(psiClass, psiMethod); result = validateObtainViaAnnotations(builderInfos, problemSink); } } return result; } | validate |
13,104 | boolean (Collection<BuilderInfo> builderInfos, @NotNull ProblemSink problemSink) { builderInfos.stream().filter(BuilderInfo::hasSingularAnnotation).forEach(builderInfo -> { final PsiType psiVariableType = builderInfo.getVariable().getType(); String qualifiedName = null; if (psiVariableType instanceof PsiClassReferenceType psiVariableClassReferenceType) { // can also be PsiArrayType qualifiedName = psiVariableClassReferenceType.getClassName();//PsiTypeUtil.getQualifiedName(psiVariableType); } if (SingularHandlerFactory.isInvalidSingularType(qualifiedName)) { problemSink.addErrorMessage("inspection.message.lombok.does.not.know", qualifiedName != null ? qualifiedName : psiVariableType.getCanonicalText()); problemSink.markFailed(); } if (!AbstractSingularHandler.validateSingularName(builderInfo.getSingularAnnotation(), builderInfo.getFieldName())) { problemSink.addErrorMessage("inspection.message.can.t.singularize.this.name", builderInfo.getFieldName()); problemSink.markFailed(); } }); return problemSink.success(); } | validateSingular |
13,105 | boolean (@NotNull String builderClassName, @NotNull Project project, @NotNull ProblemSink builder) { final PsiNameHelper psiNameHelper = PsiNameHelper.getInstance(project); if (!psiNameHelper.isIdentifier(builderClassName)) { builder.addErrorMessage("inspection.message.s.not.valid.identifier", builderClassName); return false; } return true; } | validateBuilderIdentifier |
13,106 | boolean (@NotNull String builderClassName, @NotNull PsiClass psiClass, @NotNull ProblemSink problemSink) { final Optional<PsiClass> optionalPsiClass = PsiClassUtil.getInnerClassInternByName(psiClass, builderClassName); return optionalPsiClass.map(builderClass -> validateInvalidAnnotationsOnBuilderClass(builderClass, problemSink)).orElse(true); } | validateExistingBuilderClass |
13,107 | boolean (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull ProblemSink builder) { if (psiClass.isAnnotationType() || psiClass.isInterface() || psiClass.isEnum()) { builder.addErrorMessage("inspection.message.s.can.be.used.on.classes.only", psiAnnotation.getQualifiedName()); return false; } return true; } | validateAnnotationOnRightType |
13,108 | boolean (Stream<BuilderInfo> builderInfos, @NotNull ProblemSink problemSink) { builderInfos.map(BuilderInfo::withObtainVia) .filter(BuilderInfo::hasObtainViaAnnotation) .forEach(builderInfo -> { if (StringUtil.isEmpty(builderInfo.getViaFieldName()) == StringUtil.isEmpty(builderInfo.getViaMethodName())) { problemSink.addErrorMessage("inspection.message.syntax.either.obtain.via.field"); problemSink.markFailed(); } if (StringUtil.isEmpty(builderInfo.getViaMethodName()) && builderInfo.isViaStaticCall()) { problemSink.addErrorMessage("inspection.message.obtain.via.is.static.true.not.valid.unless.method.has.been.set"); problemSink.markFailed(); } }); return problemSink.success(); } | validateObtainViaAnnotations |
13,109 | Optional<PsiClass> (@NotNull PsiClass psiClass, @Nullable PsiMethod psiMethod, @NotNull PsiAnnotation psiAnnotation) { final String builderClassName = getBuilderClassName(psiClass, psiAnnotation, psiMethod); return PsiClassUtil.getInnerClassInternByName(psiClass, builderClassName); } | getExistInnerBuilderClass |
13,110 | String (@NotNull PsiAnnotation psiAnnotation) { final String buildMethodName = PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, ANNOTATION_BUILD_METHOD_NAME, BUILD_METHOD_NAME); return StringUtil.isEmptyOrSpaces(buildMethodName) ? BUILD_METHOD_NAME : buildMethodName; } | getBuildMethodName |
13,111 | String (@NotNull PsiAnnotation psiAnnotation) { final String builderMethodName = PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, ANNOTATION_BUILDER_METHOD_NAME, BUILDER_METHOD_NAME); return null == builderMethodName ? BUILDER_METHOD_NAME : builderMethodName; } | getBuilderMethodName |
13,112 | String (@NotNull PsiAnnotation psiAnnotation) { final String setterPrefix = PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, ANNOTATION_SETTER_PREFIX, ""); return null == setterPrefix ? "" : setterPrefix; } | getSetterPrefix |
13,113 | String (@NotNull PsiAnnotation psiAnnotation) { final String accessVisibility = LombokProcessorUtil.getAccessVisibility(psiAnnotation); return null == accessVisibility ? PsiModifier.PUBLIC : accessVisibility; } | getBuilderOuterAccessVisibility |
13,114 | String (@NotNull PsiAnnotation psiAnnotation) { final String accessVisibility = getBuilderOuterAccessVisibility(psiAnnotation); return PsiModifier.PROTECTED.equals(accessVisibility) ? PsiModifier.PUBLIC : accessVisibility; } | getBuilderInnerAccessVisibility |
13,115 | String (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return getBuilderClassName(psiClass, psiAnnotation, null); } | getBuilderClassName |
13,116 | String (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @Nullable PsiMethod psiMethod) { final String builderClassName = PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, ANNOTATION_BUILDER_CLASS_NAME, ""); if (!StringUtil.isEmptyOrSpaces(builderClassName)) { return builderClassName; } String relevantReturnType = psiClass.getName(); if (null != psiMethod && !psiMethod.isConstructor()) { final PsiType psiMethodReturnType = psiMethod.getReturnType(); if (null != psiMethodReturnType) { relevantReturnType = PsiNameHelper.getQualifiedClassName(psiMethodReturnType.getPresentableText(), false); } } return getBuilderClassName(psiClass, relevantReturnType); } | getBuilderClassName |
13,117 | String (@NotNull PsiClass psiClass, String returnTypeName) { final ConfigDiscovery configDiscovery = ConfigDiscovery.getInstance(); final String builderClassNamePattern = configDiscovery.getStringLombokConfigProperty(BUILDER_CLASS_NAME, psiClass); return replace(builderClassNamePattern, "*", capitalize(returnTypeName)); } | getBuilderClassName |
13,118 | Collection<PsiMethod> (@NotNull PsiClass containingClass, @Nullable PsiMethod psiMethod, @NotNull PsiClass builderPsiClass, @NotNull PsiAnnotation psiAnnotation) { final List<BuilderInfo> builderInfos = createBuilderInfos(psiAnnotation, containingClass, psiMethod, builderPsiClass); return builderInfos.stream() .filter(BuilderInfo::hasBuilderDefaultAnnotation) .filter(b -> !b.hasSingularAnnotation()) .filter(b -> !b.hasNoInitializer()) .map(BuilderHandler::createBuilderDefaultProviderMethod) .collect(Collectors.toList()); } | createBuilderDefaultProviderMethodsIfNecessary |
13,119 | PsiMethod (@NotNull BuilderInfo info) { final PsiClass builderClass = info.getBuilderClass(); final PsiClass containingClass = builderClass.getContainingClass(); final String blockText = String.format("return %s;", info.getFieldInitializer().getText()); return new LombokLightMethodBuilder(builderClass.getManager(), info.renderFieldDefaultProviderName()) .withMethodReturnType(info.getFieldType()) .withContainingClass(containingClass) .withNavigationElement(info.getVariable()) .withModifier(PsiModifier.PRIVATE) .withModifier(PsiModifier.STATIC) .withBodyText(blockText); } | createBuilderDefaultProviderMethod |
13,120 | Optional<PsiMethod> (@NotNull PsiClass containingClass, @Nullable PsiMethod psiMethod, @NotNull PsiClass builderPsiClass, @NotNull PsiAnnotation psiAnnotation) { final String builderMethodName = getBuilderMethodName(psiAnnotation); if (!builderMethodName.isEmpty() && !hasMethod(containingClass, builderMethodName)) { final PsiType psiTypeWithGenerics = PsiClassUtil.getTypeWithGenerics(builderPsiClass); final String blockText = String.format("return new %s();", psiTypeWithGenerics.getCanonicalText(false)); final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(containingClass.getManager(), builderMethodName) .withMethodReturnType(psiTypeWithGenerics) .withContainingClass(containingClass) .withNavigationElement(psiAnnotation) .withModifier(getBuilderOuterAccessVisibility(psiAnnotation)) .withBodyText(blockText); addTypeParameters(builderPsiClass, psiMethod, methodBuilder); if (null == psiMethod || psiMethod.isConstructor() || psiMethod.hasModifierProperty(PsiModifier.STATIC)) { methodBuilder.withModifier(PsiModifier.STATIC); } createRelevantNonNullAnnotation(containingClass, methodBuilder); return Optional.of(methodBuilder); } return Optional.empty(); } | createBuilderMethodIfNecessary |
13,121 | Optional<PsiMethod> (@NotNull PsiClass containingClass, @Nullable PsiMethod psiMethod, @NotNull PsiClass builderPsiClass, @NotNull PsiAnnotation psiAnnotation) { if (!PsiAnnotationUtil.getBooleanAnnotationValue(psiAnnotation, TO_BUILDER_ANNOTATION_KEY, false)) { return Optional.empty(); } final List<BuilderInfo> builderInfos = createBuilderInfos(psiAnnotation, containingClass, psiMethod, builderPsiClass); builderInfos.forEach(BuilderInfo::withObtainVia); final PsiType psiTypeWithGenerics; if (null != psiMethod) { psiTypeWithGenerics = calculateResultType(builderInfos, builderPsiClass, containingClass); } else { psiTypeWithGenerics = PsiClassUtil.getTypeWithGenerics(builderPsiClass); } final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(containingClass.getManager(), TO_BUILDER_METHOD_NAME) .withMethodReturnType(psiTypeWithGenerics) .withContainingClass(containingClass) .withNavigationElement(psiAnnotation) .withModifier(getBuilderOuterAccessVisibility(psiAnnotation)); final String toBuilderPrependStatements = builderInfos.stream() .map(BuilderInfo::renderToBuilderPrependStatement) .filter(Predicate.not(StringUtil::isEmpty)) .collect(Collectors.joining("\n")); final String toBuilderMethodCalls = builderInfos.stream() .map(BuilderInfo::renderToBuilderCallWithPrependLogic) .filter(Predicate.not(StringUtil::isEmpty)) .collect(Collectors.joining(".", ".", "")); final String toBuilderAppendStatements = builderInfos.stream() .map(BuilderInfo::renderToBuilderAppendStatement) .filter(Predicate.not(StringUtil::isEmpty)) .collect(Collectors.joining("\n")); final String canonicalText = psiTypeWithGenerics.getCanonicalText(false); final String blockText; if (toBuilderAppendStatements.isEmpty()) { blockText = toBuilderPrependStatements + String.format("\nreturn new %s()%s;", canonicalText, toBuilderMethodCalls); } else { blockText = toBuilderPrependStatements + String.format("\nfinal %s %s = new %s()%s;\n", canonicalText, BUILDER_TEMP_VAR, canonicalText, toBuilderMethodCalls) + toBuilderAppendStatements + String.format("\nreturn %s;", BUILDER_TEMP_VAR); } methodBuilder.withBodyText(blockText); createRelevantNonNullAnnotation(containingClass, methodBuilder); return Optional.of(methodBuilder); } | createToBuilderMethodIfNecessary |
13,122 | PsiType (@NotNull List<BuilderInfo> builderInfos, PsiClass builderPsiClass, PsiClass psiClass) { final PsiElementFactory factory = JavaPsiFacade.getElementFactory(psiClass.getProject()); final PsiType[] psiTypes = builderInfos.stream() .map(BuilderInfo::getObtainViaFieldVariableType) .filter(Optional::isPresent) .map(Optional::get) .toArray(PsiType[]::new); return factory.createType(builderPsiClass, psiTypes); } | calculateResultType |
13,123 | Stream<BuilderInfo> (@NotNull PsiClass psiClass, @Nullable PsiMethod psiClassMethod) { final Stream<BuilderInfo> result; if (null != psiClassMethod) { result = Arrays.stream(psiClassMethod.getParameterList().getParameters()).map(BuilderInfo::fromPsiParameter); } else if (psiClass.isRecord()) { result = Arrays.stream(psiClass.getRecordComponents()).map(BuilderInfo::fromPsiRecordComponent); } else { result = PsiClassUtil.collectClassFieldsIntern(psiClass).stream().map(BuilderInfo::fromPsiField) .filter(BuilderInfo::useForBuilder); } return result; } | createBuilderInfos |
13,124 | List<BuilderInfo> (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass, @Nullable PsiMethod psiClassMethod, @NotNull PsiClass builderClass) { final PsiSubstitutor builderSubstitutor = getBuilderSubstitutor(psiClass, builderClass); final String accessVisibility = getBuilderInnerAccessVisibility(psiAnnotation); final String setterPrefix = getSetterPrefix(psiAnnotation); final LombokNullAnnotationLibrary nullAnnotationLibrary = ConfigDiscovery.getInstance().getAddNullAnnotationLombokConfigProperty(psiClass); return createBuilderInfos(psiClass, psiClassMethod) .map(info -> info.withSubstitutor(builderSubstitutor)) .map(info -> info.withBuilderClass(builderClass)) .map(info -> info.withVisibilityModifier(accessVisibility)) .map(info -> info.withSetterPrefix(setterPrefix)) .map(info -> info.withNullAnnotationLibrary(nullAnnotationLibrary)) .collect(Collectors.toList()); } | createBuilderInfos |
13,125 | PsiClass (@NotNull PsiClass psiClass, @Nullable PsiMethod psiMethod, @NotNull PsiAnnotation psiAnnotation) { final LombokLightClassBuilder builderClass; if (null != psiMethod) { builderClass = createEmptyBuilderClass(psiClass, psiMethod, psiAnnotation); } else { builderClass = createEmptyBuilderClass(psiClass, psiAnnotation); } if (hasValidJacksonizedAnnotation(psiClass, psiMethod)) { handleJacksonized(psiClass, psiMethod, psiAnnotation, builderClass); } builderClass.withFieldSupplier((thisPsiClass) -> { final List<BuilderInfo> builderInfos = createBuilderInfos(psiAnnotation, psiClass, psiMethod, thisPsiClass); // create builder Fields return builderInfos.stream() .map(BuilderInfo::renderBuilderFields) .flatMap(Collection::stream) .collect(Collectors.toList()); }); builderClass.withMethodSupplier((thisPsiClass) -> { Collection<PsiMethod> psiMethods = new ArrayList<>(createConstructors(thisPsiClass, psiAnnotation)); final List<BuilderInfo> builderInfos = createBuilderInfos(psiAnnotation, psiClass, psiMethod, thisPsiClass); // create builder methods builderInfos.stream() .map(BuilderInfo::renderBuilderMethods) .forEach(psiMethods::addAll); // create 'build' method final String buildMethodName = getBuildMethodName(psiAnnotation); psiMethods.add(createBuildMethod(psiAnnotation, psiClass, psiMethod, thisPsiClass, buildMethodName, builderInfos)); // create 'toString' method psiMethods.add(createToStringMethod(psiAnnotation, thisPsiClass)); return psiMethods; }); return builderClass; } | createBuilderClass |
13,126 | boolean (@NotNull PsiClass psiClass, @Nullable PsiMethod psiMethod) { final boolean hasJacksonizedAnnotation = PsiAnnotationSearchUtil.isAnnotatedWith(null == psiMethod ? psiClass : psiMethod, LombokClassNames.JACKSONIZED); return hasJacksonizedAnnotation && JacksonizedProcessor.validateAnnotationOwner(null == psiMethod ? psiClass : psiMethod, new ProblemProcessingSink()); } | hasValidJacksonizedAnnotation |
13,127 | void (@NotNull PsiClass psiClass, @Nullable PsiMethod psiMethod, @NotNull PsiAnnotation psiAnnotation, @NotNull LombokLightClassBuilder builderClass) { //Annotation 'com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder=Foobar.FoobarBuilder[Impl].class)' should be added on PsiClass psiClass.putUserData(LombokUserDataKeys.AUGMENTED_ANNOTATIONS, Collections.singleton( "@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder=" + builderClass.getQualifiedName() + ".class)")); //add com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix="with", buildMethodName="build") final PsiAnnotation jsonPojoBuilderAnnotation = createPojoBuilderAnnotation(psiClass, psiAnnotation); builderClass.getModifierList().withAnnotation(jsonPojoBuilderAnnotation); LombokCopyableAnnotations.copyCopyableAnnotations(null == psiMethod ? psiClass : psiMethod, builderClass.getModifierList(), LombokCopyableAnnotations.JACKSON_COPY_TO_BUILDER); } | handleJacksonized |
13,128 | PsiAnnotation (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { final StringBuilder parameters = new StringBuilder(); final String setterPrefix = getSetterPrefix(psiAnnotation); parameters.append("withPrefix=\""); parameters.append(setterPrefix); parameters.append('"'); parameters.append(','); final String buildMethodName = getBuildMethodName(psiAnnotation); parameters.append("buildMethodName=\""); parameters.append(buildMethodName); parameters.append('"'); return JavaPsiFacade.getElementFactory(psiClass.getProject()) .createAnnotationFromText('@' + JACKSON_DATABIND_ANNOTATION_JSON_POJOBUILDER + "(" + parameters + ")", psiClass); } | createPojoBuilderAnnotation |
13,129 | LombokLightClassBuilder (@NotNull PsiClass psiClass, @NotNull PsiMethod psiMethod, @NotNull PsiAnnotation psiAnnotation) { return createBuilderClass(psiClass, psiMethod, psiMethod.isConstructor() || psiMethod.hasModifierProperty(PsiModifier.STATIC), psiAnnotation); } | createEmptyBuilderClass |
13,130 | LombokLightClassBuilder (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return createBuilderClass(psiClass, psiClass, true, psiAnnotation); } | createEmptyBuilderClass |
13,131 | Optional<PsiClass> (@NotNull PsiClass psiClass, @Nullable PsiMethod psiMethod, @NotNull PsiAnnotation psiAnnotation) { PsiClass builderClass = null; if (getExistInnerBuilderClass(psiClass, psiMethod, psiAnnotation).isEmpty()) { builderClass = createBuilderClass(psiClass, psiMethod, psiAnnotation); } return Optional.ofNullable(builderClass); } | createBuilderClassIfNotExist |
13,132 | PsiMethod (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass builderClass) { return createToStringMethod(psiAnnotation, builderClass, false); } | createToStringMethod |
13,133 | boolean (@NotNull PsiField psiField) { boolean isBuilderDefaultSetter = false; if (psiField.getName().endsWith("$set") && PsiTypes.booleanType().equals(psiField.getType())) { PsiElement navigationElement = psiField.getNavigationElement(); if (navigationElement instanceof PsiField) { isBuilderDefaultSetter = PsiAnnotationSearchUtil.isAnnotatedWith((PsiField)navigationElement, LombokClassNames.BUILDER_DEFAULT); } } return !isBuilderDefaultSetter; } | isNotBuilderDefaultSetterFields |
13,134 | LombokLightClassBuilder (@NotNull PsiClass psiClass, @NotNull PsiTypeParameterListOwner psiTypeParameterListOwner, final boolean isStatic, @NotNull PsiAnnotation psiAnnotation) { PsiMethod psiMethod = null; if (psiTypeParameterListOwner instanceof PsiMethod) { psiMethod = (PsiMethod)psiTypeParameterListOwner; } final String builderClassName = getBuilderClassName(psiClass, psiAnnotation, psiMethod); final String builderClassQualifiedName = psiClass.getQualifiedName() + "." + builderClassName; final LombokLightClassBuilder classBuilder = new LombokLightClassBuilder(psiClass, builderClassName, builderClassQualifiedName) .withContainingClass(psiClass) .withNavigationElement(psiAnnotation) .withParameterTypes((null != psiMethod && psiMethod.isConstructor()) ? psiClass.getTypeParameterList() : psiTypeParameterListOwner.getTypeParameterList()) .withModifier(getBuilderOuterAccessVisibility(psiAnnotation)); if (isStatic) { classBuilder.withModifier(PsiModifier.STATIC); } return classBuilder; } | createBuilderClass |
13,135 | Collection<PsiMethod> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { final Collection<PsiMethod> methodsIntern = PsiClassUtil.collectClassConstructorIntern(psiClass); final NoArgsConstructorProcessor noArgsConstructorProcessor = getNoArgsConstructorProcessor(); final String constructorName = noArgsConstructorProcessor.getConstructorName(psiClass); for (PsiMethod existedConstructor : methodsIntern) { if (constructorName.equals(existedConstructor.getName()) && existedConstructor.getParameterList().getParametersCount() == 0) { return Collections.emptySet(); } } return noArgsConstructorProcessor.createNoArgsConstructor(psiClass, PsiModifier.PACKAGE_LOCAL, psiAnnotation); } | createConstructors |
13,136 | PsiMethod (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass parentClass, @Nullable PsiMethod psiMethod, @NotNull PsiClass builderClass, @NotNull String buildMethodName, List<BuilderInfo> builderInfos) { final PsiType builderType = getReturnTypeOfBuildMethod(parentClass, psiMethod); final PsiSubstitutor builderSubstitutor = getBuilderSubstitutor(parentClass, builderClass); final PsiType returnType = builderSubstitutor.substitute(builderType); final String buildMethodPrepare = builderInfos.stream() .map(BuilderInfo::renderBuildPrepare) .collect(Collectors.joining()); final String buildMethodParameters = builderInfos.stream() .map(BuilderInfo::renderBuildCall) .collect(Collectors.joining(",")); final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(parentClass.getManager(), buildMethodName) .withMethodReturnType(returnType) .withContainingClass(builderClass) .withNavigationElement(parentClass) .withModifier(getBuilderInnerAccessVisibility(psiAnnotation)); final String codeBlockText = createBuildMethodCodeBlockText(psiMethod, builderClass, returnType, buildMethodPrepare, buildMethodParameters); methodBuilder.withBodyText(codeBlockText); if (!PsiTypes.voidType().equals(returnType)) { createRelevantNonNullAnnotation(builderClass, methodBuilder); } Optional<PsiMethod> definedConstructor = Optional.ofNullable(psiMethod); if (definedConstructor.isEmpty()) { definedConstructor = getExistingConstructorForParameters(parentClass, builderInfos); } definedConstructor.map(PsiMethod::getThrowsList).map(PsiReferenceList::getReferencedTypes).map(Arrays::stream) .ifPresent(stream -> stream.forEach(methodBuilder::withException)); return methodBuilder; } | createBuildMethod |
13,137 | Optional<PsiMethod> (@NotNull PsiClass parentClass, Collection<BuilderInfo> builderInfos) { final Collection<PsiMethod> classConstructors = PsiClassUtil.collectClassConstructorIntern(parentClass); return classConstructors.stream() .filter(m -> sameParameters(m.getParameterList().getParameters(), builderInfos)) .findFirst(); } | getExistingConstructorForParameters |
13,138 | boolean (PsiParameter[] parameters, Collection<BuilderInfo> builderInfos) { if (parameters.length != builderInfos.size()) { return false; } final Iterator<BuilderInfo> builderInfoIterator = builderInfos.iterator(); for (PsiParameter psiParameter : parameters) { final BuilderInfo builderInfo = builderInfoIterator.next(); if (!psiParameter.getType().isAssignableFrom(builderInfo.getFieldType())) { return false; } } return true; } | sameParameters |
13,139 | String (@Nullable PsiMethod psiMethod, @NotNull PsiClass psiClass, @NotNull PsiType buildMethodReturnType, @NotNull String buildMethodPrepare, @NotNull String buildMethodParameters) { final String blockText; final String codeBlockFormat, callExpressionText; if (null == psiMethod || psiMethod.isConstructor()) { codeBlockFormat = "%s\n return new %s(%s);"; callExpressionText = buildMethodReturnType.getPresentableText(); } else { if (PsiTypes.voidType().equals(buildMethodReturnType)) { codeBlockFormat = "%s\n %s(%s);"; } else { codeBlockFormat = "%s\n return %s(%s);"; } callExpressionText = calculateCallExpressionForMethod(psiMethod, psiClass); } blockText = String.format(codeBlockFormat, buildMethodPrepare, callExpressionText, buildMethodParameters); return blockText; } | createBuildMethodCodeBlockText |
13,140 | String (@NotNull PsiMethod psiMethod, @NotNull PsiClass builderClass) { final PsiClass containingClass = psiMethod.getContainingClass(); StringBuilder className = new StringBuilder(); if (null != containingClass) { className.append(containingClass.getName()).append("."); if (!psiMethod.isConstructor() && !psiMethod.hasModifierProperty(PsiModifier.STATIC)) { className.append("this."); } if (builderClass.hasTypeParameters()) { className.append( Arrays.stream(builderClass.getTypeParameters()).map(PsiTypeParameter::getName).collect(Collectors.joining(",", "<", ">"))); } } return className + psiMethod.getName(); } | calculateCallExpressionForMethod |
13,141 | NoArgsConstructorProcessor () { return LombokProcessorManager.getInstance().getNoArgsConstructorProcessor(); } | getNoArgsConstructorProcessor |
13,142 | ToStringProcessor () { return LombokProcessorManager.getInstance().getToStringProcessor(); } | getToStringProcessor |
13,143 | Collection<PsiField> (@NotNull BuilderInfo info) { final PsiType builderFieldKeyType = getBuilderFieldType(info.getFieldType(), info.getProject()); return Collections.singleton( new LombokLightFieldBuilder(info.getManager(), info.getFieldName(), builderFieldKeyType) .withContainingClass(info.getBuilderClass()) .withModifier(PsiModifier.PRIVATE) .withNavigationElement(info.getVariable())); } | renderBuilderFields |
13,144 | PsiType (@NotNull PsiType psiFieldType, @NotNull Project project) { final PsiManager psiManager = PsiManager.getInstance(project); final PsiType rowKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 0); final PsiType columnKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 1); final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 2); return PsiTypeUtil.createCollectionType(psiManager, collectionQualifiedName + ".Builder", rowKeyType, columnKeyType, valueType); } | getBuilderFieldType |
13,145 | void (@NotNull LombokLightMethodBuilder methodBuilder, @NotNull PsiType psiFieldType, @NotNull String singularName) { final PsiManager psiManager = methodBuilder.getManager(); final PsiType rowKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 0); final PsiType columnKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 1); final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 2); methodBuilder.withParameter(LOMBOK_ROW_KEY, rowKeyType); methodBuilder.withParameter(LOMBOK_COLUMN_KEY, columnKeyType); methodBuilder.withParameter(LOMBOK_VALUE, valueType); } | addOneMethodParameter |
13,146 | void (@NotNull LombokLightMethodBuilder methodBuilder, @NotNull PsiType psiFieldType, @NotNull String singularName) { final PsiManager psiManager = methodBuilder.getManager(); final PsiType rowKeyType = PsiTypeUtil.extractAllElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 0); final PsiType columnKeyType = PsiTypeUtil.extractAllElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 1); final PsiType valueType = PsiTypeUtil.extractAllElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 2); final PsiType collectionType = PsiTypeUtil.createCollectionType(psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, rowKeyType, columnKeyType, valueType); methodBuilder.withParameter(singularName, collectionType); } | addAllMethodParameter |
13,147 | String (@NotNull BuilderInfo info) { final String codeBlockFormat = "this.{0} = null;\n" + "return {1};"; return MessageFormat.format(codeBlockFormat, info.getFieldName(), info.getBuilderChainResult()); } | getClearMethodBody |
13,148 | String (@NotNull String singularName, @NotNull BuilderInfo info) { final String codeBlockTemplate = "if (this.{0} == null) this.{0} = {2}.{3}; \n" + "this.{0}.put(" + LOMBOK_ROW_KEY + ", " + LOMBOK_COLUMN_KEY + ", " + LOMBOK_VALUE + ");\n" + "return {4};"; return MessageFormat.format(codeBlockTemplate, info.getFieldName(), singularName, collectionQualifiedName, sortedCollection ? "naturalOrder()" : "builder()", info.getBuilderChainResult()); } | getOneMethodBody |
13,149 | String (@NotNull String singularName, @NotNull BuilderInfo info) { final String codeBlockTemplate = """ if({0}==null)'{'throw new NullPointerException("{0} cannot be null");'}' if (this.{0} == null) this.{0} = {1}.{2};\s this.{0}.putAll({0}); return {3};"""; return MessageFormat.format(codeBlockTemplate, singularName, collectionQualifiedName, sortedCollection ? "naturalOrder()" : "builder()", info.getBuilderChainResult()); } | getAllMethodBody |
13,150 | String (@NotNull PsiVariable psiVariable, @NotNull String fieldName, @NotNull String builderVariable) { final PsiManager psiManager = psiVariable.getManager(); final PsiType psiFieldType = psiVariable.getType(); final PsiType rowKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 0); final PsiType columnKeyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 1); final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, COM_GOOGLE_COMMON_COLLECT_TABLE, 2); return MessageFormat.format( "{4}<{1}, {2}, {3}> {0} = " + "{5}.{0} == null ? " + "{4}.<{1}, {2}, {3}>of() : " + "{5}.{0}.build();\n", fieldName, rowKeyType.getCanonicalText(false), columnKeyType.getCanonicalText(false), valueType.getCanonicalText(false), collectionQualifiedName, builderVariable); } | renderBuildCode |
13,151 | String (@NotNull BuilderInfo info) { return collectionQualifiedName + '.' + "builder()"; } | getEmptyCollectionCall |
13,152 | void (@NotNull LombokLightMethodBuilder methodBuilder, @NotNull PsiType psiFieldType, @NotNull String singularName) { final PsiType oneElementType = PsiTypeUtil.extractOneElementType(psiFieldType, methodBuilder.getManager()); methodBuilder.withParameter(singularName, oneElementType); } | addOneMethodParameter |
13,153 | void (@NotNull LombokLightMethodBuilder methodBuilder, @NotNull PsiType psiFieldType, @NotNull String singularName) { final PsiManager psiManager = methodBuilder.getManager(); final PsiType elementType = PsiTypeUtil.extractAllElementType(psiFieldType, psiManager); final PsiType collectionType = PsiTypeUtil.createCollectionType(psiManager, CommonClassNames.JAVA_UTIL_COLLECTION, elementType); methodBuilder.withParameter(singularName, collectionType); } | addAllMethodParameter |
13,154 | String (@NotNull BuilderInfo info) { final String codeBlockFormat = """ if (this.{0} != null)\s this.{0}.clear(); return {1};"""; return MessageFormat.format(codeBlockFormat, info.getFieldName(), info.getBuilderChainResult()); } | getClearMethodBody |
13,155 | String (@NotNull String singularName, @NotNull BuilderInfo info) { final String codeBlockTemplate = """ if (this.{0} == null) this.{0} = new java.util.ArrayList<{3}>();\s this.{0}.add({1}); return {2};"""; final PsiType oneElementType = PsiTypeUtil.extractOneElementType(info.getFieldType(), info.getManager()); return MessageFormat.format(codeBlockTemplate, info.getFieldName(), singularName, info.getBuilderChainResult(), oneElementType.getCanonicalText(false)); } | getOneMethodBody |
13,156 | String (@NotNull String singularName, @NotNull BuilderInfo info) { final String codeBlockTemplate = """ if({0}==null)'{'throw new NullPointerException("{0} cannot be null");'}' if (this.{0} == null) this.{0} = new java.util.ArrayList<{2}>();\s this.{0}.addAll({0}); return {1};"""; final PsiType oneElementType = PsiTypeUtil.extractOneElementType(info.getFieldType(), info.getManager()); return MessageFormat.format(codeBlockTemplate, singularName, info.getBuilderChainResult(), oneElementType.getCanonicalText(false)); } | getAllMethodBody |
13,157 | String (@NotNull BuilderInfo info) { return renderBuildCode(info.getVariable(), info.getFieldName(), "this"); } | renderBuildPrepare |
13,158 | String (@NotNull BuilderInfo info) { return info.renderFieldName(); } | renderBuildCall |
13,159 | String (@NotNull PsiVariable psiVariable, @NotNull String fieldName) { return renderBuildCode(psiVariable, fieldName, "b") + "this." + psiVariable.getName() + "=" + fieldName + ";\n"; } | renderSuperBuilderConstruction |
13,160 | String (@NotNull BuilderInfo info) { final PsiType elementType = PsiTypeUtil.extractOneElementType(info.getVariable().getType(), info.getManager()); final String typeName = elementType.getCanonicalText(false); if (ContainerUtil.exists(SingularCollectionClassNames.JAVA_SETS, collectionQualifiedName::equals)) { return "java.util.Collections.<"+typeName+">emptySet()"; } else { return "java.util.Collections.<"+typeName+">emptyList()"; } } | getEmptyCollectionCall |
13,161 | Collection<PsiField> (@NotNull BuilderInfo info) { final PsiType builderFieldKeyType = getBuilderFieldType(info.getFieldType(), info.getProject()); return Collections.singleton( new LombokLightFieldBuilder(info.getManager(), info.getFieldName(), builderFieldKeyType) .withContainingClass(info.getBuilderClass()) .withModifier(PsiModifier.PRIVATE) .withNavigationElement(info.getVariable())); } | renderBuilderFields |
13,162 | PsiType (@NotNull PsiType psiFieldType, @NotNull Project project) { final PsiManager psiManager = PsiManager.getInstance(project); final PsiType keyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 0); final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 1); return PsiTypeUtil.createCollectionType(psiManager, collectionQualifiedName + ".Builder", keyType, valueType); } | getBuilderFieldType |
13,163 | void (@NotNull LombokLightMethodBuilder methodBuilder, @NotNull PsiType psiFieldType, @NotNull String singularName) { final PsiManager psiManager = methodBuilder.getManager(); final PsiType keyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 0); final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 1); methodBuilder.withParameter(LOMBOK_KEY, keyType); methodBuilder.withParameter(LOMBOK_VALUE, valueType); } | addOneMethodParameter |
13,164 | String (@NotNull BuilderInfo info) { final String codeBlockFormat = "this.{0} = null;\n" + "return {1};"; return MessageFormat.format(codeBlockFormat, info.getFieldName(), info.getBuilderChainResult()); } | getClearMethodBody |
13,165 | String (@NotNull String singularName, @NotNull BuilderInfo info) { final String codeBlockTemplate = "if (this.{0} == null) this.{0} = {2}.{3}; \n" + "this.{0}.put(" + LOMBOK_KEY + ", " + LOMBOK_VALUE + ");\n" + "return {4};"; return MessageFormat.format(codeBlockTemplate, info.getFieldName(), singularName, collectionQualifiedName, sortedCollection ? "naturalOrder()" : "builder()", info.getBuilderChainResult()); } | getOneMethodBody |
13,166 | String (@NotNull String singularName, @NotNull BuilderInfo info) { final String codeBlockTemplate = """ if({0}==null)'{'throw new NullPointerException("{0} cannot be null");'}' if (this.{0} == null) this.{0} = {1}.{2};\s this.{0}.putAll({0}); return {3};"""; return MessageFormat.format(codeBlockTemplate, singularName, collectionQualifiedName, sortedCollection ? "naturalOrder()" : "builder()", info.getBuilderChainResult()); } | getAllMethodBody |
13,167 | String (@NotNull PsiVariable psiVariable, @NotNull String fieldName, @NotNull String builderVariable) { final PsiManager psiManager = psiVariable.getManager(); final PsiType psiFieldType = psiVariable.getType(); final PsiType keyType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 0); final PsiType valueType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 1); return MessageFormat.format( "{3}<{1}, {2}> {0} = " + "{4}.{0} == null ? " + "{3}.<{1}, {2}>of() : " + "{4}.{0}.build();\n", fieldName, keyType.getCanonicalText(false), valueType.getCanonicalText(false), collectionQualifiedName, builderVariable); } | renderBuildCode |
13,168 | String (@NotNull BuilderInfo info) { return collectionQualifiedName + '.' + "builder()"; } | getEmptyCollectionCall |
13,169 | boolean (@Nullable String qualifiedName) { return qualifiedName == null || !containsOrAnyEndsWith(VALID_SINGULAR_TYPES, qualifiedName); } | isInvalidSingularType |
13,170 | boolean (@NotNull Set<String> elements, @NotNull String className) { return elements.contains(className) || ContainerUtil.exists(elements, t -> t.endsWith("." + className)); } | containsOrAnyEndsWith |
13,171 | BuilderElementHandler (@NotNull PsiVariable psiVariable, boolean hasSingularAnnotation) { if (!hasSingularAnnotation) { return new NonSingularHandler(); } final PsiType psiType = psiVariable.getType(); final String qualifiedName = PsiTypeUtil.getQualifiedName(psiType); if (!isInvalidSingularType(qualifiedName)) { if (containsOrAnyEndsWith(COLLECTION_TYPES, qualifiedName)) { return new SingularCollectionHandler(qualifiedName); } if (containsOrAnyEndsWith(MAP_TYPES, qualifiedName)) { return new SingularMapHandler(qualifiedName); } if (containsOrAnyEndsWith(GUAVA_COLLECTION_TYPES, qualifiedName)) { return new SingularGuavaCollectionHandler(qualifiedName, qualifiedName.contains("Sorted")); } if (containsOrAnyEndsWith(GUAVA_MAP_TYPES, qualifiedName)) { return new SingularGuavaMapHandler(qualifiedName, qualifiedName.contains("Sorted")); } if (containsOrAnyEndsWith(GUAVA_TABLE_TYPES, qualifiedName)) { return new SingularGuavaTableHandler(qualifiedName, false); } } return new EmptyBuilderElementHandler(); } | getHandlerFor |
13,172 | Collection<PsiField> (@NotNull BuilderInfo info) { return Collections.emptyList(); } | renderBuilderFields |
13,173 | Collection<PsiMethod> (@NotNull BuilderInfo info) { return Collections.emptyList(); } | renderBuilderMethod |
13,174 | String (@NotNull BuilderInfo info) { return ""; } | calcBuilderMethodName |
13,175 | List<String> (@NotNull String fieldName, @NotNull String prefix, @Nullable PsiAnnotation singularAnnotation, CapitalizationStrategy capitalizationStrategy) { return Collections.emptyList(); } | getBuilderMethodNames |
13,176 | String (PsiAnnotation singularAnnotation, String psiFieldName) { return psiFieldName; } | createSingularName |
13,177 | Collection<PsiField> (@NotNull BuilderInfo info) { final PsiType builderFieldType = getBuilderFieldType(info.getFieldType(), info.getProject()); return Collections.singleton( new LombokLightFieldBuilder(info.getManager(), info.getFieldName(), builderFieldType) .withContainingClass(info.getBuilderClass()) .withModifier(PsiModifier.PRIVATE) .withNavigationElement(info.getVariable())); } | renderBuilderFields |
13,178 | PsiType (@NotNull PsiType psiFieldType, @NotNull Project project) { final PsiManager psiManager = PsiManager.getInstance(project); final PsiType elementType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager); return PsiTypeUtil.createCollectionType(psiManager, CommonClassNames.JAVA_UTIL_ARRAY_LIST, elementType); } | getBuilderFieldType |
13,179 | Collection<PsiMethod> (@NotNull BuilderInfo info) { List<PsiMethod> methods = new ArrayList<>(); final PsiType returnType = info.getBuilderType(); final String fieldName = info.getFieldName(); final String singularName = createSingularName(info.getSingularAnnotation(), fieldName); final PsiClass builderClass = info.getBuilderClass(); final LombokLightMethodBuilder oneAddMethodBuilder = new LombokLightMethodBuilder( info.getManager(), LombokUtils.buildAccessorName(info.getSetterPrefix(), singularName, info.getCapitalizationStrategy())) .withContainingClass(builderClass) .withMethodReturnType(returnType) .withNavigationElement(info.getVariable()) .withModifier(info.getVisibilityModifier()) .withAnnotations(info.getAnnotations()); addOneMethodParameter(oneAddMethodBuilder, info.getFieldType(), singularName); if(info.getVariable() instanceof PsiField psiField) { LombokCopyableAnnotations.copyCopyableAnnotations(psiField, oneAddMethodBuilder.getModifierList(), LombokCopyableAnnotations.COPY_TO_BUILDER_SINGULAR_SETTER); } final String oneMethodBody = getOneMethodBody(singularName, info); oneAddMethodBuilder.withBodyText(oneMethodBody); createRelevantNonNullAnnotation(info.getNullAnnotationLibrary(), oneAddMethodBuilder); methods.add(oneAddMethodBuilder); final LombokLightMethodBuilder allAddMethodBuilder = new LombokLightMethodBuilder( info.getManager(), LombokUtils.buildAccessorName(info.getSetterPrefix(), fieldName, info.getCapitalizationStrategy())) .withContainingClass(builderClass) .withMethodReturnType(returnType) .withNavigationElement(info.getVariable()) .withModifier(info.getVisibilityModifier()) .withAnnotations(info.getAnnotations()); addAllMethodParameter(allAddMethodBuilder, info.getFieldType(), fieldName); if(info.getVariable() instanceof PsiField psiField) { LombokCopyableAnnotations.copyCopyableAnnotations(psiField, allAddMethodBuilder.getModifierList(), LombokCopyableAnnotations.COPY_TO_SETTER); } final String allMethodBody = getAllMethodBody(fieldName, info); allAddMethodBuilder.withBodyText(allMethodBody); createRelevantNonNullAnnotation(info.getNullAnnotationLibrary(), allAddMethodBuilder); methods.add(allAddMethodBuilder); final LombokLightMethodBuilder clearMethodBuilder = new LombokLightMethodBuilder( info.getManager(), createSingularClearMethodName(fieldName, info.getCapitalizationStrategy())) .withContainingClass(builderClass) .withMethodReturnType(returnType) .withNavigationElement(info.getVariable()) .withModifier(info.getVisibilityModifier()) .withAnnotations(info.getAnnotations()); final String clearMethodBlockText = getClearMethodBody(info); clearMethodBuilder.withBodyText(clearMethodBlockText); createRelevantNonNullAnnotation(info.getNullAnnotationLibrary(), clearMethodBuilder); methods.add(clearMethodBuilder); return methods; } | renderBuilderMethod |
13,180 | String (String fieldName, CapitalizationStrategy capitalizationStrategy) { return LombokUtils.buildAccessorName("clear", fieldName, capitalizationStrategy); } | createSingularClearMethodName |
13,181 | List<String> (@NotNull String fieldName, @NotNull String prefix, @Nullable PsiAnnotation singularAnnotation, CapitalizationStrategy capitalizationStrategy) { final String accessorName = LombokUtils.buildAccessorName(prefix, fieldName, capitalizationStrategy); return Arrays.asList(createSingularName(singularAnnotation, accessorName), accessorName, createSingularClearMethodName(fieldName, capitalizationStrategy)); } | getBuilderMethodNames |
13,182 | String (@NotNull BuilderInfo info) { final String instanceGetter = info.getInstanceVariableName() + '.' + info.getVariable().getName(); return info.getFieldName() + '(' + instanceGetter + " == null ? " + getEmptyCollectionCall(info) + " : " + instanceGetter + ')'; } | renderToBuilderCall |
13,183 | String (@NotNull BuilderInfo info) { final String instanceGetter = info.getInstanceVariableName() + '.' + info.getVariable().getName(); return "if(" + instanceGetter + " != null) "+BUILDER_TEMP_VAR +"."+info.getFieldName() +'('+ instanceGetter + ");"; } | renderToBuilderAppendCall |
13,184 | String (@NotNull PsiAnnotation singularAnnotation, String psiFieldName) { String singularName = PsiAnnotationUtil.getStringAnnotationValue(singularAnnotation, "value", ""); if (StringUtil.isEmptyOrSpaces(singularName)) { singularName = Singulars.autoSingularize(psiFieldName); if (singularName == null) { singularName = psiFieldName; } } return singularName; } | createSingularName |
13,185 | boolean (PsiAnnotation singularAnnotation, String psiFieldName) { String singularName = PsiAnnotationUtil.getStringAnnotationValue(singularAnnotation, "value", ""); if (StringUtil.isEmptyOrSpaces(singularName)) { singularName = Singulars.autoSingularize(psiFieldName); return singularName != null; } return true; } | validateSingularName |
13,186 | PsiType (PsiManager psiManager, PsiType psiFieldType) { return PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 0); } | getKeyType |
13,187 | PsiType (PsiManager psiManager, PsiType psiFieldType) { return PsiTypeUtil.extractOneElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 1); } | getValueType |
13,188 | Collection<PsiField> (@NotNull BuilderInfo info) { final PsiType keyType = getKeyType(info.getManager(), info.getFieldType()); final PsiType builderFieldKeyType = getBuilderFieldType(keyType, info.getProject()); final PsiType valueType = getValueType(info.getManager(), info.getFieldType()); final PsiType builderFieldValueType = getBuilderFieldType(valueType, info.getProject()); return List.of( new LombokLightFieldBuilder(info.getManager(), info.getFieldName() + LOMBOK_KEY, builderFieldKeyType) .withContainingClass(info.getBuilderClass()) .withModifier(PsiModifier.PRIVATE) .withNavigationElement(info.getVariable()), new LombokLightFieldBuilder(info.getManager(), info.getFieldName() + LOMBOK_VALUE, builderFieldValueType) .withContainingClass(info.getBuilderClass()) .withModifier(PsiModifier.PRIVATE) .withNavigationElement(info.getVariable())); } | renderBuilderFields |
13,189 | PsiType (@NotNull PsiType psiType, @NotNull Project project) { final PsiManager psiManager = PsiManager.getInstance(project); return PsiTypeUtil.createCollectionType(psiManager, CommonClassNames.JAVA_UTIL_ARRAY_LIST, psiType); } | getBuilderFieldType |
13,190 | void (@NotNull LombokLightMethodBuilder methodBuilder, @NotNull PsiType psiFieldType, @NotNull String singularName) { final PsiManager psiManager = methodBuilder.getManager(); final PsiType keyType = getKeyType(psiManager, psiFieldType); final PsiType valueType = getValueType(psiManager, psiFieldType); methodBuilder.withParameter(singularName + KEY, keyType); methodBuilder.withParameter(singularName + VALUE, valueType); } | addOneMethodParameter |
13,191 | void (@NotNull LombokLightMethodBuilder methodBuilder, @NotNull PsiType psiFieldType, @NotNull String singularName) { final PsiManager psiManager = methodBuilder.getManager(); final PsiType keyType = PsiTypeUtil.extractAllElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 0); final PsiType valueType = PsiTypeUtil.extractAllElementType(psiFieldType, psiManager, CommonClassNames.JAVA_UTIL_MAP, 1); final PsiType collectionType = PsiTypeUtil.createCollectionType(psiManager, CommonClassNames.JAVA_UTIL_MAP, keyType, valueType); methodBuilder.withParameter(singularName, collectionType); } | addAllMethodParameter |
13,192 | String (@NotNull BuilderInfo info) { final String codeBlockFormat = "if (this.{0}" + LOMBOK_KEY + " != null) '{'\n this.{0}" + LOMBOK_KEY + ".clear();\n " + " this.{0}" + LOMBOK_VALUE + ".clear(); '}'\n" + "return {1};"; return MessageFormat.format(codeBlockFormat, info.getFieldName(), info.getBuilderChainResult()); } | getClearMethodBody |
13,193 | String (@NotNull String singularName, @NotNull BuilderInfo info) { final String codeBlockTemplate = "if (this.{0}" + LOMBOK_KEY + " == null) '{' \n" + "this.{0}" + LOMBOK_KEY + " = new java.util.ArrayList<{3}>(); \n" + "this.{0}" + LOMBOK_VALUE + " = new java.util.ArrayList<{4}>(); \n" + "'}' \n" + "this.{0}" + LOMBOK_KEY + ".add({1}" + KEY + ");\n" + "this.{0}" + LOMBOK_VALUE + ".add({1}" + VALUE + ");\n" + "return {2};"; final PsiType keyType = getKeyType(info.getManager(), info.getFieldType()); final PsiType valueType = getValueType(info.getManager(), info.getFieldType()); return MessageFormat.format(codeBlockTemplate, info.getFieldName(), singularName, info.getBuilderChainResult(), keyType.getCanonicalText(false), valueType.getCanonicalText(false)); } | getOneMethodBody |
13,194 | String (@NotNull String singularName, @NotNull BuilderInfo info) { final String codeBlockTemplate = "if({0}==null)'{'throw new NullPointerException(\"{0} cannot be null\");'}'\n" + "if (this.{0}" + LOMBOK_KEY + " == null) '{' \n" + "this.{0}" + LOMBOK_KEY + " = new java.util.ArrayList<{2}>(); \n" + "this.{0}" + LOMBOK_VALUE + " = new java.util.ArrayList<{3}>(); \n" + "'}' \n" + "for (final java.util.Map.Entry<{4},{5}> $lombokEntry : {0}.entrySet()) '{'\n" + "this.{0}" + LOMBOK_KEY + ".add($lombokEntry.getKey());\n" + "this.{0}" + LOMBOK_VALUE + ".add($lombokEntry.getValue());\n" + "'}'\n" + "return {1};"; final PsiType keyType = getKeyType(info.getManager(), info.getFieldType()); final PsiType valueType = getValueType(info.getManager(), info.getFieldType()); final PsiType keyIterType = PsiTypeUtil.extractAllElementType(info.getFieldType(), info.getManager(), CommonClassNames.JAVA_UTIL_MAP, 0); final PsiType valueIterType = PsiTypeUtil.extractAllElementType(info.getFieldType(), info.getManager(), CommonClassNames.JAVA_UTIL_MAP, 1); return MessageFormat.format(codeBlockTemplate, singularName, info.getBuilderChainResult(), keyType.getCanonicalText(false), valueType.getCanonicalText(false), keyIterType.getCanonicalText(false), valueIterType.getCanonicalText(false)); } | getAllMethodBody |
13,195 | String (@NotNull BuilderInfo info) { return renderBuildCode(info.getVariable(), info.getFieldName(), "this"); } | renderBuildPrepare |
13,196 | String (@NotNull BuilderInfo info) { return info.renderFieldName(); } | renderBuildCall |
13,197 | String (@NotNull PsiVariable psiVariable, @NotNull String fieldName) { final String basicCode = renderBuildCode(psiVariable, fieldName, "b"); final String assignment = "this." + psiVariable.getName() + "=" + fieldName + ";\n"; return basicCode + assignment; } | renderSuperBuilderConstruction |
13,198 | String (@NotNull BuilderInfo info) { final PsiManager psiManager = info.getManager(); final PsiType psiFieldType = info.getVariable().getType(); final PsiType keyType = getKeyType(psiManager, psiFieldType); final PsiType valueType = getValueType(psiManager, psiFieldType); final String keyTypeName = keyType.getCanonicalText(false); final String valueTypeName = valueType.getCanonicalText(false); return "java.util.Collections.<" + keyTypeName + "," + valueTypeName + ">emptyMap()"; } | getEmptyCollectionCall |
13,199 | PsiType (@NotNull PsiType psiFieldType, @NotNull Project project) { final PsiManager psiManager = PsiManager.getInstance(project); final PsiType elementType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager); return PsiTypeUtil.createCollectionType(psiManager, typeCollectionQualifiedName + ".Builder", elementType); } | getBuilderFieldType |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.