Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
13,200
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_LANG_ITERABLE, elementType); methodBuilder.withParameter(singularName, collectionType); }
addAllMethodParameter
13,201
String (@NotNull BuilderInfo info) { final String codeBlockFormat = "this.{0} = null;\n" + "return {1};"; return MessageFormat.format(codeBlockFormat, info.getFieldName(), info.getBuilderChainResult()); }
getClearMethodBody
13,202
String (@NotNull String singularName, @NotNull BuilderInfo info) { final String codeBlockTemplate = """ if (this.{0} == null) this.{0} = {2}.{3};\s this.{0}.add({1}); return {4};"""; return MessageFormat.format(codeBlockTemplate, info.getFieldName(), singularName, typeCollectionQualifiedName, sortedCollection ? "naturalOrder()" : "builder()", info.getBuilderChainResult()); }
getOneMethodBody
13,203
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}.addAll({0}); return {3};"""; return MessageFormat.format(codeBlockTemplate, singularName, typeCollectionQualifiedName, sortedCollection ? "naturalOrder()" : "builder()", info.getBuilderChainResult()); }
getAllMethodBody
13,204
String (@NotNull PsiVariable psiVariable, @NotNull String fieldName, @NotNull String builderVariable) { final PsiManager psiManager = psiVariable.getManager(); final PsiType psiFieldType = psiVariable.getType(); final PsiType elementType = PsiTypeUtil.extractOneElementType(psiFieldType, psiManager); return MessageFormat.format( "{2}<{1}> {0} = " + "{4}.{0} == null ? " + "{3}.<{1}>of() : " + "{4}.{0}.build();\n", fieldName, elementType.getCanonicalText(false), collectionQualifiedName, typeCollectionQualifiedName, builderVariable); }
renderBuildCode
13,205
String (@NotNull BuilderInfo info) { return typeCollectionQualifiedName + '.' + "builder()"; }
getEmptyCollectionCall
13,206
Collection<PsiField> (@NotNull BuilderInfo info) { Collection<PsiField> result = new ArrayList<>(); result.add(new LombokLightFieldBuilder(info.getManager(), info.renderFieldName(), info.getFieldType()) .withContainingClass(info.getBuilderClass()) .withModifier(PsiModifier.PRIVATE) .withNavigationElement(info.getVariable())); if (info.hasBuilderDefaultAnnotation()) { result.add(new LombokLightFieldBuilder(info.getManager(), info.renderFieldDefaultSetName(), PsiTypes.booleanType()) .withContainingClass(info.getBuilderClass()) .withModifier(PsiModifier.PRIVATE) .withNavigationElement(info.getVariable())); } return result; }
renderBuilderFields
13,207
Collection<PsiMethod> (@NotNull BuilderInfo info) { final String blockText = getAllMethodBody(info); final String methodName = calcBuilderMethodName(info); final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(info.getManager(), methodName) .withContainingClass(info.getBuilderClass()) .withMethodReturnType(info.getBuilderType()) .withParameter(info.getFieldName(), info.getFieldType()) .withNavigationElement(info.getVariable()) .withModifier(info.getVisibilityModifier()) .withAnnotations(info.getAnnotations()) .withBodyText(blockText); if(info.getVariable() instanceof PsiField psiField) { LombokCopyableAnnotations.copyCopyableAnnotations(psiField, methodBuilder.getModifierList(), LombokCopyableAnnotations.COPY_TO_SETTER); } createRelevantNonNullAnnotation(info.getNullAnnotationLibrary(), methodBuilder); return Collections.singleton(methodBuilder); }
renderBuilderMethod
13,208
List<String> (@NotNull String fieldName, @NotNull String prefix, @Nullable PsiAnnotation singularAnnotation, CapitalizationStrategy capitalizationStrategy) { return Collections.singletonList(LombokUtils.buildAccessorName(prefix, fieldName, capitalizationStrategy)); }
getBuilderMethodNames
13,209
String (PsiAnnotation singularAnnotation, String psiFieldName) { return psiFieldName; }
createSingularName
13,210
String (@NotNull BuilderInfo info) { StringBuilder codeBlockTemplate = new StringBuilder("this.{0} = {1};\n"); if (info.hasBuilderDefaultAnnotation()) { codeBlockTemplate.append("this.{2} = true;\n"); } codeBlockTemplate.append("return {3};"); return MessageFormat.format(codeBlockTemplate.toString(), info.renderFieldName(), info.getFieldName(), info.renderFieldDefaultSetName(), info.getBuilderChainResult()); }
getAllMethodBody
13,211
String (@NotNull BuilderInfo info) { if (info.hasBuilderDefaultAnnotation()) { return MessageFormat.format( """ {0} {1} = this.{1}; if (!this.{2}) '{' {1} = {4}.{3}(); '}'""", info.getFieldType().getCanonicalText(false), info.renderFieldName(), info.renderFieldDefaultSetName(), info.renderFieldDefaultProviderName(), info.getBuilderClass().getContainingClass().getName()); } return ""; }
renderBuildPrepare
13,212
String (@NotNull BuilderInfo info) { if (info.hasBuilderDefaultAnnotation()) { return info.renderFieldName(); } else { return "this." + info.renderFieldName(); } }
renderBuildCall
13,213
AccessorsInfo (boolean fluentValue, boolean chainValue, boolean makeFinal, boolean doNotUseIsPrefix, CapitalizationStrategy capitalizationStrategy, String... prefixes) { return new AccessorsInfo(fluentValue, chainValue, makeFinal, doNotUseIsPrefix, capitalizationStrategy, prefixes); }
build
13,214
AccessorsInfo (@Nullable PsiClass psiClass, @Nullable Boolean chainDeclaredValue, @Nullable Boolean fluentDeclaredValue, @Nullable Boolean makeFinalDeclaredValue, @NotNull Collection<String> prefixDeclared) { final boolean isFluent; final boolean isChained; final boolean makeFinal; final boolean doNotUseIsPrefix; final CapitalizationStrategy capitalizationStrategy; final String[] prefixes; if (null != psiClass) { final ConfigDiscovery configDiscovery = ConfigDiscovery.getInstance(); if (null == fluentDeclaredValue) { isFluent = configDiscovery.getBooleanLombokConfigProperty(ConfigKey.ACCESSORS_FLUENT, psiClass); } else { isFluent = fluentDeclaredValue; } if (null == chainDeclaredValue) { isChained = configDiscovery.getBooleanLombokConfigProperty(ConfigKey.ACCESSORS_CHAIN, psiClass); } else { isChained = chainDeclaredValue; } if (null == makeFinalDeclaredValue) { makeFinal = configDiscovery.getBooleanLombokConfigProperty(ConfigKey.ACCESSORS_MAKE_FINAL, psiClass); } else { makeFinal = makeFinalDeclaredValue; } if (prefixDeclared.isEmpty()) { prefixes = ArrayUtil.toStringArray(configDiscovery.getMultipleValueLombokConfigProperty(ConfigKey.ACCESSORS_PREFIX, psiClass)); } else { prefixes = ArrayUtil.toStringArray(prefixDeclared); } doNotUseIsPrefix = configDiscovery.getBooleanLombokConfigProperty(ConfigKey.GETTER_NO_IS_PREFIX, psiClass); final String capitalizationStrategyValue = configDiscovery.getStringLombokConfigProperty(ConfigKey.ACCESSORS_JAVA_BEANS_SPEC_CAPITALIZATION, psiClass); capitalizationStrategy = CapitalizationStrategy.convertValue(capitalizationStrategyValue); } else { isFluent = null != fluentDeclaredValue && fluentDeclaredValue; isChained = null != chainDeclaredValue && chainDeclaredValue; makeFinal = null != makeFinalDeclaredValue && makeFinalDeclaredValue; prefixes = ArrayUtil.toStringArray(prefixDeclared); doNotUseIsPrefix = false; capitalizationStrategy = CapitalizationStrategy.defaultValue(); } boolean isChainDeclaredOrImplicit = isChained || (isFluent && null == chainDeclaredValue); return build(isFluent, isChainDeclaredOrImplicit, makeFinal, doNotUseIsPrefix, capitalizationStrategy, prefixes); }
buildAccessorsInfo
13,215
record (Boolean chainDeclaredValue, Boolean fluentDeclaredValue, Boolean makeFinalDeclaredValue, Collection<String> prefixes) { private AccessorsValues() { this(null, null, null, Collections.emptyList()); } private AccessorsValues combine(AccessorsValues defaults) { Boolean combinedChain = chainDeclaredValue; Boolean combinedFluent = fluentDeclaredValue; Boolean combinedMakeFinal = makeFinalDeclaredValue; Collection<String> combinedPrefixes = prefixes; if (combinedChain == null && null != defaults.chainDeclaredValue) { combinedChain = defaults.chainDeclaredValue; } if (combinedFluent == null && null != defaults.fluentDeclaredValue) { combinedFluent = defaults.fluentDeclaredValue; } if (combinedMakeFinal == null && null != defaults.makeFinalDeclaredValue) { combinedMakeFinal = defaults.makeFinalDeclaredValue; } if (combinedPrefixes.isEmpty() && !defaults.prefixes.isEmpty()) { combinedPrefixes = defaults.prefixes; } return new AccessorsValues(combinedChain, combinedFluent, combinedMakeFinal, combinedPrefixes); } }
AccessorsValues
13,216
AccessorsValues (AccessorsValues defaults) { Boolean combinedChain = chainDeclaredValue; Boolean combinedFluent = fluentDeclaredValue; Boolean combinedMakeFinal = makeFinalDeclaredValue; Collection<String> combinedPrefixes = prefixes; if (combinedChain == null && null != defaults.chainDeclaredValue) { combinedChain = defaults.chainDeclaredValue; } if (combinedFluent == null && null != defaults.fluentDeclaredValue) { combinedFluent = defaults.fluentDeclaredValue; } if (combinedMakeFinal == null && null != defaults.makeFinalDeclaredValue) { combinedMakeFinal = defaults.makeFinalDeclaredValue; } if (combinedPrefixes.isEmpty() && !defaults.prefixes.isEmpty()) { combinedPrefixes = defaults.prefixes; } return new AccessorsValues(combinedChain, combinedFluent, combinedMakeFinal, combinedPrefixes); }
combine
13,217
AccessorsValues (@NotNull PsiAnnotation accessorsAnnotation) { Boolean chainDeclaredValue = PsiAnnotationUtil.getDeclaredBooleanAnnotationValue(accessorsAnnotation, CHAIN_VALUE); Boolean fluentDeclaredValue = PsiAnnotationUtil.getDeclaredBooleanAnnotationValue(accessorsAnnotation, FLUENT_VALUE); Boolean makeFinalDeclaredValue = PsiAnnotationUtil.getDeclaredBooleanAnnotationValue(accessorsAnnotation, MAKE_FINAL_VALUE); Collection<String> prefixes = PsiAnnotationUtil.getAnnotationValues(accessorsAnnotation, PREFIX_VALUE, String.class); return new AccessorsValues(chainDeclaredValue, fluentDeclaredValue, makeFinalDeclaredValue, prefixes); }
collectValues
13,218
AccessorsInfo (@Nullable PsiClass psiClass, AccessorsValues values) { return buildAccessorsInfo(psiClass, values.chainDeclaredValue, values.fluentDeclaredValue, values.makeFinalDeclaredValue, values.prefixes); }
buildFrom
13,219
AccessorsInfo (@NotNull PsiField psiField) { final AccessorsValues fieldAccessorsValues = getAccessorsValues(psiField); final AccessorsValues classAccessorsValues = getAccessorsValues(psiField.getContainingClass()); final AccessorsValues combinedAccessorValues = fieldAccessorsValues.combine(classAccessorsValues); final PsiClass containingClass = psiField.getContainingClass(); return buildFrom(containingClass, combinedAccessorValues); }
buildFor
13,220
AccessorsInfo (@NotNull PsiClass psiClass) { AccessorsValues resultAccessorsValues = getAccessorsValues(psiClass); return buildFrom(psiClass, resultAccessorsValues); }
buildFor
13,221
AccessorsValues (@NotNull PsiField psiField) { AccessorsValues accessorsValues = new AccessorsValues(); final PsiAnnotation accessorsFieldAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, LombokClassNames.ACCESSORS); if (null != accessorsFieldAnnotation) { accessorsValues = collectValues(accessorsFieldAnnotation); } return accessorsValues; }
getAccessorsValues
13,222
AccessorsValues (@Nullable PsiClass psiClass) { AccessorsValues resultAccessorsValues = new AccessorsValues(); PsiClass containingClass = psiClass; while (null != containingClass) { final PsiAnnotation accessorsClassAnnotation = PsiAnnotationSearchUtil.findAnnotation(containingClass, LombokClassNames.ACCESSORS); if (null != accessorsClassAnnotation) { final AccessorsValues classAccessorsValues = collectValues(accessorsClassAnnotation); resultAccessorsValues = resultAccessorsValues.combine(classAccessorsValues); } containingClass = containingClass.getContainingClass(); } return resultAccessorsValues; }
getAccessorsValues
13,223
AccessorsInfo (@NotNull PsiField psiField, AccessorsValues classAccessorsValues) { final AccessorsValues fieldAccessorsValues = getAccessorsValues(psiField); final AccessorsValues combinedAccessorValues = fieldAccessorsValues.combine(classAccessorsValues); final PsiClass containingClass = psiField.getContainingClass(); return buildFrom(containingClass, combinedAccessorValues); }
buildFor
13,224
boolean () { return fluent; }
isFluent
13,225
AccessorsInfo (boolean fluentValue) { if (fluent == fluentValue) { return this; } return build(fluentValue, chain, makeFinal, doNotUseIsPrefix, capitalizationStrategy, prefixes); }
withFluent
13,226
boolean () { return chain; }
isChain
13,227
boolean () { return makeFinal; }
isMakeFinal
13,228
boolean () { return doNotUseIsPrefix; }
isDoNotUseIsPrefix
13,229
CapitalizationStrategy () { return capitalizationStrategy; }
getCapitalizationStrategy
13,230
String[] () { return prefixes; }
getPrefixes
13,231
boolean (String fieldName) { if (prefixes.length == 0) { return false; } for (String prefix : prefixes) { if (canPrefixApply(fieldName, prefix)) { return false; } } return true; }
isPrefixUnDefinedOrNotStartsWith
13,232
String (String fieldName) { for (String prefix : prefixes) { if (canPrefixApply(fieldName, prefix)) { return prefix.isEmpty() ? fieldName : decapitalizeLikeLombok(fieldName.substring(prefix.length())); } } return fieldName; }
removePrefix
13,233
boolean (String fieldName, String prefix) { final int prefixLength = prefix.length(); // we can use digits and upper case letters after a prefix, but not lower case letters return prefixLength == 0 || fieldName.startsWith(prefix) && fieldName.length() > prefixLength && (!Character.isLetter(prefix.charAt(prefix.length() - 1)) || !Character.isLowerCase(fieldName.charAt(prefixLength))); }
canPrefixApply
13,234
String (String name) { if (name == null || name.isEmpty()) { return name; } char[] chars = name.toCharArray(); chars[0] = Character.toLowerCase(chars[0]); return new String(chars); }
decapitalizeLikeLombok
13,235
RequiredArgsConstructorProcessor () { return LombokProcessorManager.getInstance().getRequiredArgsConstructorProcessor(); }
getRequiredArgsConstructorProcessor
13,236
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField); final String generatedElementName = LombokUtils.getWitherName(psiField, accessorsInfo); return Collections.singletonList(generatedElementName); }
getNamesOfPossibleGeneratedElements
13,237
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField, @NotNull ProblemSink builder) { validateOnXAnnotations(psiAnnotation, psiField, builder, "onParam"); boolean valid = validateVisibility(psiAnnotation); valid &= validName(psiField, builder); valid &= validNonStatic(psiField, builder); valid &= validNonFinalInitialized(psiField, builder); valid &= validIsWitherUnique(psiField, builder); final PsiClass containingClass = psiField.getContainingClass(); valid &= null != containingClass && (containingClass.hasModifierProperty(PsiModifier.ABSTRACT) || validConstructor(containingClass, builder)); return valid; }
validate
13,238
boolean (@NotNull PsiAnnotation psiAnnotation) { final String methodVisibility = LombokProcessorUtil.getMethodModifier(psiAnnotation); return null != methodVisibility; }
validateVisibility
13,239
void (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { String methodModifier = LombokProcessorUtil.getMethodModifier(psiAnnotation); if (methodModifier != null) { AccessorsInfo accessorsInfo = buildAccessorsInfo(psiField); PsiMethod method = createWitherMethod(psiField, methodModifier, accessorsInfo); if (method != null) { target.add(method); } } }
generatePsiElements
13,240
boolean (@NotNull PsiField psiField, @NotNull ProblemSink builder) { if (psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER)) { builder.addWarningMessage("inspection.message.not.generating.wither.for.this.field.withers"); return false; } return true; }
validName
13,241
boolean (@NotNull PsiField psiField, @NotNull final ProblemSink builder) { if (psiField.hasModifierProperty(PsiModifier.STATIC)) { builder.addWarningMessage("inspection.message.not.generating.wither") .withLocalQuickFixes(()->PsiQuickFixFactory.createModifierListFix(psiField, PsiModifier.STATIC, false, false)); return false; } return true; }
validNonStatic
13,242
boolean (@NotNull PsiField psiField, @NotNull ProblemSink builder) { final PsiClass psiClass = psiField.getContainingClass(); if (null != psiClass && psiField.hasModifierProperty(PsiModifier.FINAL) && !PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, LombokClassNames.VALUE) && psiField.hasInitializer() && !PsiAnnotationSearchUtil.isAnnotatedWith(psiField, LombokClassNames.BUILDER_DEFAULT)) { builder.addWarningMessage("inspection.message.not.generating.wither.for.this.field.withers.cannot.be.generated") .withLocalQuickFixes(()->PsiQuickFixFactory.createModifierListFix(psiField, PsiModifier.FINAL, false, false)); return false; } return true; }
validNonFinalInitialized
13,243
boolean (@NotNull PsiField psiField, @NotNull final ProblemSink builder) { final PsiClass fieldContainingClass = psiField.getContainingClass(); if (fieldContainingClass != null) { final Collection<PsiMethod> classMethods = PsiClassUtil.collectClassMethodsIntern(fieldContainingClass); filterToleratedElements(classMethods); final AccessorsInfo accessorsInfo = buildAccessorsInfo(psiField); final String psiFieldName = psiField.getName(); final Collection<String> possibleWitherNames = LombokUtils.toAllWitherNames(accessorsInfo, psiFieldName, PsiTypes.booleanType().equals(psiField.getType())); for (String witherName : possibleWitherNames) { if (PsiMethodUtil.hasSimilarMethod(classMethods, witherName, 1)) { builder.addWarningMessage("inspection.message.not.generating.s.method.with.that.name.already.exists", witherName); return false; } } } return true; }
validIsWitherUnique
13,244
boolean (@NotNull PsiClass psiClass, @NotNull ProblemSink builder) { if (psiClass.isRecord() || PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, LombokClassNames.ALL_ARGS_CONSTRUCTOR, LombokClassNames.VALUE, LombokClassNames.BUILDER)) { return true; } final Collection<PsiField> constructorParameters = filterFields(psiClass); if (PsiAnnotationSearchUtil.isAnnotatedWith(psiClass, LombokClassNames.REQUIRED_ARGS_CONSTRUCTOR, LombokClassNames.DATA)) { final Collection<PsiField> requiredConstructorParameters = getRequiredArgsConstructorProcessor().getRequiredFields(psiClass); if (constructorParameters.size() == requiredConstructorParameters.size()) { return true; } } final Collection<PsiMethod> classConstructors = PsiClassUtil.collectClassConstructorIntern(psiClass); boolean constructorExists = false; for (PsiMethod classConstructor : classConstructors) { if (classConstructor.getParameterList().getParametersCount() == constructorParameters.size()) { constructorExists = true; break; } } if (!constructorExists) { builder.addWarningMessage("inspection.message.wither.needs.constructor.for.all.fields.d.parameters", constructorParameters.size()); builder.markFailed(); } return constructorExists; }
validConstructor
13,245
Collection<PsiField> (@NotNull PsiClass psiClass) { final Collection<PsiField> psiFields = PsiClassUtil.collectClassFieldsIntern(psiClass); Collection<PsiField> result = new ArrayList<>(psiFields.size()); for (PsiField classField : psiFields) { final String classFieldName = classField.getName(); if (classFieldName.startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER)) { continue; } if (classField.hasModifierProperty(PsiModifier.STATIC)) { continue; } if (classField.hasModifierProperty(PsiModifier.FINAL) && classField.hasInitializer()) { continue; } result.add(classField); } return result; }
filterFields
13,246
PsiMethod (@NotNull PsiField psiField, @NotNull String methodModifier, @NotNull AccessorsInfo accessorsInfo) { LombokLightMethodBuilder methodBuilder = null; final PsiClass psiFieldContainingClass = psiField.getContainingClass(); if (psiFieldContainingClass != null) { final PsiType returnType = PsiClassUtil.getTypeWithGenerics(psiFieldContainingClass); methodBuilder = new LombokLightMethodBuilder(psiField.getManager(), LombokUtils.getWitherName(psiField, accessorsInfo)) .withMethodReturnType(returnType) .withContainingClass(psiFieldContainingClass) .withNavigationElement(psiField) .withModifier(methodModifier) .withPureContract(); if (accessorsInfo.isMakeFinal()) { methodBuilder.withModifier(PsiModifier.FINAL); } PsiAnnotation witherAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, LombokClassNames.WITHER, LombokClassNames.WITH); LombokCopyableAnnotations.copyOnXAnnotations(witherAnnotation, methodBuilder.getModifierList(), "onMethod"); final String psiFieldName = psiField.getName(); final PsiType psiFieldType = psiField.getType(); final LombokLightParameter methodParameter = new LombokLightParameter(psiFieldName, psiFieldType, methodBuilder); methodBuilder.withParameter(methodParameter); LombokLightModifierList methodParameterModifierList = methodParameter.getModifierList(); LombokCopyableAnnotations.copyCopyableAnnotations(psiField, methodParameterModifierList, LombokCopyableAnnotations.BASE_COPYABLE); LombokCopyableAnnotations.copyOnXAnnotations(witherAnnotation, methodParameterModifierList, "onParam"); if (psiFieldContainingClass.hasModifierProperty(PsiModifier.ABSTRACT)) { methodBuilder.withModifier(PsiModifier.ABSTRACT); } else { final String paramString = getConstructorCall(psiField, psiFieldContainingClass); final String blockText = String.format("return this.%s == %s ? this : new %s(%s);", psiFieldName, psiFieldName, returnType.getCanonicalText(), paramString); methodBuilder.withBodyText(blockText); } LombokAddNullAnnotations.createRelevantNonNullAnnotation(psiFieldContainingClass, methodBuilder); } return methodBuilder; }
createWitherMethod
13,247
AccessorsInfo (@NotNull PsiField psiField) { return AccessorsInfo.buildFor(psiField).withFluent(false); }
buildAccessorsInfo
13,248
String (@NotNull PsiField psiField, @NotNull PsiClass psiClass) { final StringBuilder paramString = new StringBuilder(); final Collection<PsiField> psiFields = filterFields(psiClass); for (PsiField classField : psiFields) { final String classFieldName = classField.getName(); if (classField.equals(psiField)) { paramString.append(classFieldName); } else { paramString.append("this.").append(classFieldName); } paramString.append(','); } if (paramString.length() > 1) { paramString.deleteCharAt(paramString.length() - 1); } return paramString.toString(); }
getConstructorCall
13,249
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { return LombokPsiElementUsage.READ_WRITE; }
checkFieldUsage
13,250
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField) { return Collections.emptyList(); }
getNamesOfPossibleGeneratedElements
13,251
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField, @NotNull ProblemSink builder) { final PsiType psiFieldType = psiField.getType(); return DelegateHandler.validate(psiField, psiFieldType, psiAnnotation, builder); }
validate
13,252
void (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { DelegateHandler.generateElements(psiField, psiField.getType(), psiAnnotation, target); }
generatePsiElements
13,253
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { return LombokPsiElementUsage.READ; }
checkFieldUsage
13,254
boolean (@Nullable String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField) { if (null == nameHint) { return true; } final Collection<String> namesOfGeneratedElements = getNamesOfPossibleGeneratedElements(psiClass, psiAnnotation, psiField); return namesOfGeneratedElements.isEmpty() || namesOfGeneratedElements.contains(nameHint); }
possibleToGenerateElementNamed
13,255
Collection<PsiAnnotation> (@NotNull PsiClass psiClass) { List<PsiAnnotation> result = new ArrayList<>(); for (PsiField psiField : PsiClassUtil.collectClassFieldsIntern(psiClass)) { PsiAnnotation psiAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, getSupportedAnnotationClasses()); if (null != psiAnnotation) { result.add(psiAnnotation); } } return result; }
collectProcessedAnnotations
13,256
Collection<LombokProblem> (@NotNull PsiAnnotation psiAnnotation) { Collection<LombokProblem> result = Collections.emptyList(); PsiField psiField = PsiTreeUtil.getParentOfType(psiAnnotation, PsiField.class); if (null != psiField) { ProblemValidationSink problemNewBuilder = new ProblemValidationSink(); validate(psiAnnotation, psiField, problemNewBuilder); result = problemNewBuilder.getProblems(); } return result; }
verifyAnnotation
13,257
void (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField, @NotNull ProblemSink problemSink, @NotNull String parameterName) { if (problemSink.deepValidation()) { final @NotNull List<PsiAnnotation> copyableAnnotations = LombokCopyableAnnotations.BASE_COPYABLE.collectCopyableAnnotations(psiField); if (!copyableAnnotations.isEmpty()) { final Iterable<String> onXAnnotations = LombokProcessorUtil.getOnX(psiAnnotation, parameterName); List<String> copyableAnnotationsFQNs = ContainerUtil.map(copyableAnnotations, PsiAnnotation::getQualifiedName); for (String copyableAnnotationFQN : copyableAnnotationsFQNs) { for (String onXAnnotation : onXAnnotations) { if (onXAnnotation.startsWith(copyableAnnotationFQN)) { problemSink.addErrorMessage("inspection.message.annotation.copy.duplicate", copyableAnnotationFQN); } } } } if (psiField.isDeprecated()) { final Iterable<String> onMethodAnnotations = LombokProcessorUtil.getOnX(psiAnnotation, "onMethod"); if (ContainerUtil.exists(onMethodAnnotations, CommonClassNames.JAVA_LANG_DEPRECATED::equals)) { problemSink.addErrorMessage("inspection.message.annotation.copy.duplicate", CommonClassNames.JAVA_LANG_DEPRECATED); } } } }
validateOnXAnnotations
13,258
boolean (@NotNull PsiField psiField, @NotNull ProblemSink builder, boolean isGetter) { final PsiClass psiClass = psiField.getContainingClass(); if (null != psiClass) { //cache signatures to speed up editing of big files, where getName goes in psi tree List<MethodSignatureBackedByPsiMethod> ownSignatures = CachedValuesManager.getCachedValue(psiClass, () -> { List<MethodSignatureBackedByPsiMethod> signatures = ContainerUtil.map(PsiClassUtil.collectClassMethodsIntern(psiClass), m -> MethodSignatureBackedByPsiMethod.create(m, PsiSubstitutor.EMPTY)); return new CachedValueProvider.Result<>(signatures, PsiModificationTracker.MODIFICATION_COUNT); }); final List<MethodSignatureBackedByPsiMethod> classMethods = new ArrayList<>(ownSignatures); final boolean isBoolean = PsiTypes.booleanType().equals(psiField.getType()); final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField); final String fieldName = psiField.getName(); String accessorName = isGetter ? LombokUtils.toGetterName(accessorsInfo, fieldName, isBoolean) : LombokUtils.toSetterName(accessorsInfo, fieldName, isBoolean); int paramCount = isGetter ? 0 : 1; classMethods.removeIf(m -> m.getParameterTypes().length != paramCount || !accessorName.equals(m.getName())); classMethods.removeIf(definedMethod -> PsiAnnotationSearchUtil.isAnnotatedWith(definedMethod.getMethod(), LombokClassNames.TOLERATE)); if (!classMethods.isEmpty()) { builder.addWarningMessage("inspection.message.not.generated.s.method.with.similar.name.s.already.exists", accessorName, accessorName); return false; } } return true; }
validateExistingMethods
13,259
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField); final String generatedElementName = LombokUtils.getSetterName(psiField, accessorsInfo); return Collections.singletonList(generatedElementName); }
getNamesOfPossibleGeneratedElements
13,260
void (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { final String methodVisibility = LombokProcessorUtil.getMethodModifier(psiAnnotation); final PsiClass psiClass = psiField.getContainingClass(); if (methodVisibility != null && psiClass != null) { ContainerUtil.addIfNotNull(target, createSetterMethod(psiField, psiClass, methodVisibility, nameHint)); } }
generatePsiElements
13,261
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField, @NotNull ProblemSink builder) { boolean result; validateOnXAnnotations(psiAnnotation, psiField, builder, "onParam"); result = validateFinalModifier(psiAnnotation, psiField, builder); if (result) { result = validateVisibility(psiAnnotation); if (result) { result = validateExistingMethods(psiField, builder, false); if (result) { result = validateAccessorPrefix(psiField, builder); } } } return result; }
validate
13,262
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField, @NotNull ProblemSink builder) { boolean result = true; if (psiField.hasModifierProperty(PsiModifier.FINAL) && null != LombokProcessorUtil.getMethodModifier(psiAnnotation)) { builder.addWarningMessage("inspection.message.not.generating.setter.for.this.field.setters") .withLocalQuickFixes(() -> PsiQuickFixFactory.createModifierListFix(psiField, PsiModifier.FINAL, false, false)); result = false; } return result; }
validateFinalModifier
13,263
boolean (@NotNull PsiAnnotation psiAnnotation) { final String methodVisibility = LombokProcessorUtil.getMethodModifier(psiAnnotation); return null != methodVisibility; }
validateVisibility
13,264
boolean (@NotNull PsiField psiField, @NotNull ProblemSink builder) { boolean result = true; if (AccessorsInfo.buildFor(psiField).isPrefixUnDefinedOrNotStartsWith(psiField.getName())) { builder.addWarningMessage("inspection.message.not.generating.setter.for.this.field.it"); result = false; } return result; }
validateAccessorPrefix
13,265
Collection<String> (@NotNull PsiField psiField, boolean isBoolean) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField); return LombokUtils.toAllSetterNames(accessorsInfo, psiField.getName(), isBoolean); }
getAllSetterNames
13,266
PsiMethod (@NotNull PsiField psiField, @NotNull PsiClass psiClass, @NotNull String methodModifier, @Nullable String nameHint) { final String fieldName = psiField.getName(); final PsiType psiFieldType = psiField.getType(); final PsiAnnotation setterAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, LombokClassNames.SETTER); final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField); final String methodName = LombokUtils.getSetterName(psiField, accessorsInfo); if (nameHint != null && !nameHint.equals(methodName)) return null; PsiType returnType = getReturnType(psiField, accessorsInfo.isChain()); LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(psiField.getManager(), methodName) .withMethodReturnType(returnType) .withContainingClass(psiClass) .withParameter(fieldName, psiFieldType) .withNavigationElement(psiField) .withMutatesThisContract(); if (StringUtil.isNotEmpty(methodModifier)) { methodBuilder.withModifier(methodModifier); } boolean isStatic = psiField.hasModifierProperty(PsiModifier.STATIC); if (isStatic) { methodBuilder.withModifier(PsiModifier.STATIC); } if (accessorsInfo.isMakeFinal()) { methodBuilder.withModifier(PsiModifier.FINAL); } LombokLightParameter setterParameter = methodBuilder.getParameterList().getParameter(0); if (null != setterParameter) { LombokLightModifierList methodParameterModifierList = setterParameter.getModifierList(); LombokCopyableAnnotations.copyCopyableAnnotations(psiField, methodParameterModifierList, LombokCopyableAnnotations.BASE_COPYABLE); LombokCopyableAnnotations.copyOnXAnnotations(setterAnnotation, methodParameterModifierList, "onParam"); } final LombokLightModifierList modifierList = methodBuilder.getModifierList(); LombokCopyableAnnotations.copyCopyableAnnotations(psiField, modifierList, LombokCopyableAnnotations.COPY_TO_SETTER); LombokCopyableAnnotations.copyOnXAnnotations(setterAnnotation, modifierList, "onMethod"); if (psiField.isDeprecated()) { modifierList.addAnnotation(CommonClassNames.JAVA_LANG_DEPRECATED); } final String codeBlockText = createCodeBlockText(psiField, psiClass, returnType, isStatic, setterParameter); methodBuilder.withBodyText(codeBlockText); if (!PsiTypes.voidType().equals(returnType)) { LombokAddNullAnnotations.createRelevantNonNullAnnotation(psiClass, methodBuilder); } return methodBuilder; }
createSetterMethod
13,267
String (@NotNull PsiField psiField, @NotNull PsiClass psiClass, PsiType returnType, boolean isStatic, PsiParameter methodParameter) { final String blockText; final String thisOrClass = isStatic ? psiClass.getName() : "this"; blockText = String.format("%s.%s = %s; ", thisOrClass, psiField.getName(), methodParameter.getName()); String codeBlockText = blockText; if (!isStatic && !PsiTypes.voidType().equals(returnType)) { codeBlockText += "return this;"; } return codeBlockText; }
createCodeBlockText
13,268
PsiType (@NotNull PsiField psiField, boolean isChained) { PsiType result = PsiTypes.voidType(); if (!psiField.hasModifierProperty(PsiModifier.STATIC) && isChained) { final PsiClass fieldClass = psiField.getContainingClass(); if (null != fieldClass) { result = PsiClassUtil.getTypeWithGenerics(fieldClass); } } return result; }
getReturnType
13,269
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { return LombokPsiElementUsage.WRITE; }
checkFieldUsage
13,270
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField); final String generatedElementName = LombokUtils.getGetterName(psiField, accessorsInfo); return Collections.singletonList(generatedElementName); }
getNamesOfPossibleGeneratedElements
13,271
void (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { final String methodVisibility = LombokProcessorUtil.getMethodModifier(psiAnnotation); final PsiClass psiClass = psiField.getContainingClass(); if (null != methodVisibility && null != psiClass) { ContainerUtil.addIfNotNull(target, createGetterMethod(psiField, psiClass, methodVisibility, nameHint)); } }
generatePsiElements
13,272
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField, @NotNull ProblemSink builder) { boolean result; final String methodVisibility = LombokProcessorUtil.getMethodModifier(psiAnnotation); result = null != methodVisibility; final boolean lazy = isLazyGetter(psiAnnotation); if (null == methodVisibility && lazy) { builder.addWarningMessage("inspection.message.lazy.does.not.work.with.access.level.none"); } if (result && lazy) { if (!psiField.hasModifierProperty(PsiModifier.FINAL) || !psiField.hasModifierProperty(PsiModifier.PRIVATE)) { builder.addErrorMessage("inspection.message.lazy.requires.field.to.be.private.final") .withLocalQuickFixes(()->PsiQuickFixFactory.createModifierListFix(psiField, PsiModifier.PRIVATE, true, false), ()->PsiQuickFixFactory.createModifierListFix(psiField, PsiModifier.FINAL, true, false)); result = false; } if (!psiField.hasInitializer()) { builder.addErrorMessage("inspection.message.lazy.requires.field.initialization"); result = false; } } validateOnXAnnotations(psiAnnotation, psiField, builder, "onMethod"); if (result) { result = validateExistingMethods(psiField, builder, true); } if (result) { result = validateAccessorPrefix(psiField, builder); } return result; }
validate
13,273
boolean (@NotNull PsiAnnotation psiAnnotation) { return PsiAnnotationUtil.getBooleanAnnotationValue(psiAnnotation, "lazy", false); }
isLazyGetter
13,274
boolean (@NotNull PsiField psiField, @NotNull ProblemSink builder) { boolean result = true; if (AccessorsInfo.buildFor(psiField).isPrefixUnDefinedOrNotStartsWith(psiField.getName())) { builder.addWarningMessage("inspection.message.not.generating.getter.for.this.field"); result = false; } return result; }
validateAccessorPrefix
13,275
PsiMethod (@NotNull PsiField psiField, @NotNull PsiClass psiClass, @NotNull String methodModifier, @Nullable String nameHint) { final AccessorsInfo accessorsInfo = AccessorsInfo.buildFor(psiField); final String methodName = LombokUtils.getGetterName(psiField, accessorsInfo); if (nameHint != null && !nameHint.equals(methodName)) return null; LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(psiField.getManager(), methodName) .withMethodReturnType(psiField.getType()) .withContainingClass(psiClass) .withNavigationElement(psiField) .withPureContract(); if (StringUtil.isNotEmpty(methodModifier)) { methodBuilder.withModifier(methodModifier); } boolean isStatic = psiField.hasModifierProperty(PsiModifier.STATIC); if (isStatic) { methodBuilder.withModifier(PsiModifier.STATIC); } if (accessorsInfo.isMakeFinal()) { methodBuilder.withModifier(PsiModifier.FINAL); } final String blockText = String.format("return %s.%s;", isStatic ? psiClass.getName() : "this", psiField.getName()); methodBuilder.withBodyText(blockText); final LombokLightModifierList modifierList = methodBuilder.getModifierList(); LombokCopyableAnnotations.copyCopyableAnnotations(psiField, modifierList, LombokCopyableAnnotations.BASE_COPYABLE); PsiAnnotation fieldGetterAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, LombokClassNames.GETTER); LombokCopyableAnnotations.copyOnXAnnotations(fieldGetterAnnotation, modifierList, "onMethod"); if (psiField.isDeprecated()) { modifierList.addAnnotation(CommonClassNames.JAVA_LANG_DEPRECATED); } return methodBuilder; }
createGetterMethod
13,276
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { return LombokPsiElementUsage.READ; }
checkFieldUsage
13,277
boolean (@NotNull PsiAnnotation psiAnnotation) { // old version of @FieldNameConstants has attributes "prefix" and "suffix", the new one not return null != psiAnnotation.findAttributeValue("prefix"); }
supportAnnotationVariant
13,278
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField) { final String generatedElementName = calcFieldConstantName(psiField, psiAnnotation, psiClass); return List.of(generatedElementName); }
getNamesOfPossibleGeneratedElements
13,279
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField, @NotNull ProblemSink builder) { return LombokProcessorUtil.isLevelVisible(psiAnnotation) && checkIfFieldNameIsValidAndWarn(psiAnnotation, psiField, builder); }
validate
13,280
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField, @NotNull ProblemSink builder) { final boolean isValid = isValidFieldNameConstant(psiAnnotation, psiField); if (!isValid) { builder.addWarningMessage("inspection.message.not.generating.constant"); } return isValid; }
checkIfFieldNameIsValidAndWarn
13,281
boolean (@NotNull PsiAnnotation psiAnnotation, @NotNull PsiField psiField) { final PsiClass psiClass = psiField.getContainingClass(); if (null != psiClass) { final String fieldName = calcFieldConstantName(psiField, psiAnnotation, psiClass); return !fieldName.equals(psiField.getName()); } return false; }
isValidFieldNameConstant
13,282
void (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { final PsiClass psiClass = psiField.getContainingClass(); if (null != psiClass) { target.add(createFieldNameConstant(psiField, psiClass, psiAnnotation)); } }
generatePsiElements
13,283
PsiField (@NotNull PsiField psiField, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { final PsiManager manager = psiClass.getContainingFile().getManager(); final PsiType psiFieldType = PsiType.getJavaLangString(manager, GlobalSearchScope.allScope(psiClass.getProject())); final String fieldModifier = LombokProcessorUtil.getLevelVisibility(psiAnnotation); final String fieldName = calcFieldConstantName(psiField, psiAnnotation, psiClass); LombokLightFieldBuilder fieldNameConstant = new LombokLightFieldBuilder(manager, fieldName, psiFieldType) .withContainingClass(psiClass) .withNavigationElement(psiField) .withModifier(PsiModifier.STATIC) .withModifier(PsiModifier.FINAL); if (!PsiModifier.PACKAGE_LOCAL.equals(fieldModifier)) { fieldNameConstant.withModifier(fieldModifier); } final PsiElementFactory psiElementFactory = JavaPsiFacade.getElementFactory(psiClass.getProject()); final PsiExpression initializer = psiElementFactory.createExpressionFromText("\"" + psiField.getName() + "\"", psiClass); fieldNameConstant.setInitializer(initializer); return fieldNameConstant; }
createFieldNameConstant
13,284
String (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiClass) { String prefix = PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, "prefix", CONFIG_DEFAULT); String suffix = PsiAnnotationUtil.getStringAnnotationValue(psiAnnotation, "suffix", CONFIG_DEFAULT); final ConfigDiscovery configDiscovery = ConfigDiscovery.getInstance(); if (CONFIG_DEFAULT.equals(prefix)) { prefix = configDiscovery.getStringLombokConfigProperty(ConfigKey.FIELD_NAME_CONSTANTS_PREFIX, psiClass); } if (CONFIG_DEFAULT.equals(suffix)) { suffix = configDiscovery.getStringLombokConfigProperty(ConfigKey.FIELD_NAME_CONSTANTS_SUFFIX, psiClass); } return prefix + LombokUtils.camelCaseToConstant(psiField.getName()) + suffix; }
calcFieldConstantName
13,285
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { return LombokPsiElementUsage.USAGE; }
checkFieldUsage
13,286
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return METHOD_LIST; }
getNamesOfPossibleGeneratedElements
13,287
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); } return problemSink.success(); }
validate
13,288
void (@NotNull PsiClass psiClass, @NotNull ProblemSink builder) { if (psiClass.isAnnotationType() || psiClass.isInterface()) { builder.addErrorMessage("inspection.message.to.string.only.supported.on.class.or.enum.type"); builder.markFailed(); } }
validateAnnotationOnRightType
13,289
void (@NotNull PsiClass psiClass, @NotNull ProblemSink builder) { final boolean methodAlreadyExists = hasToStringMethodDefined(psiClass); if (methodAlreadyExists) { builder.addWarningMessage("inspection.message.not.generated.s.method.with.same.name.already.exists", TO_STRING_METHOD_NAME); builder.markFailed(); } }
validateExistingMethods
13,290
boolean (@NotNull PsiClass psiClass) { final Collection<PsiMethod> classMethods = PsiClassUtil.collectClassMethodsIntern(psiClass); return PsiMethodUtil.hasMethodByName(classMethods, TO_STRING_METHOD_NAME, 0); }
hasToStringMethodDefined
13,291
void (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation, @NotNull List<? super PsiElement> target, @Nullable String nameHint) { target.addAll(createToStringMethod(psiClass, psiAnnotation)); }
generatePsiElements
13,292
PsiMethod (@NotNull PsiClass psiClass, @NotNull Collection<MemberInfo> memberInfos, @NotNull PsiAnnotation psiAnnotation, boolean forceCallSuper) { final PsiManager psiManager = psiClass.getManager(); final String paramString = createParamString(psiClass, memberInfos, psiAnnotation, forceCallSuper); final String blockText = String.format("return \"%s(%s)\";", getSimpleClassName(psiClass), paramString); final LombokLightMethodBuilder methodBuilder = new LombokLightMethodBuilder(psiManager, TO_STRING_METHOD_NAME) .withMethodReturnType(PsiType.getJavaLangString(psiManager, GlobalSearchScope.allScope(psiClass.getProject()))) .withContainingClass(psiClass) .withNavigationElement(psiAnnotation) .withModifier(PsiModifier.PUBLIC) .withBodyText(blockText); LombokAddNullAnnotations.createRelevantNonNullAnnotation(psiClass, methodBuilder); return methodBuilder; }
createToStringMethod
13,293
String (@NotNull PsiClass psiClass) { final StringBuilder psiClassName = new StringBuilder(); PsiClass containingClass = psiClass; do { if (!psiClassName.isEmpty()) { psiClassName.insert(0, '.'); } psiClassName.insert(0, containingClass.getName()); containingClass = containingClass.getContainingClass(); } while (null != containingClass); return psiClassName.toString(); }
getSimpleClassName
13,294
String (@NotNull PsiClass psiClass, @NotNull Collection<MemberInfo> memberInfos, @NotNull PsiAnnotation psiAnnotation, boolean forceCallSuper) { final boolean callSuper = forceCallSuper || readCallSuperAnnotationOrConfigProperty(psiAnnotation, psiClass, ConfigKey.TOSTRING_CALL_SUPER); final boolean doNotUseGetters = readAnnotationOrConfigProperty(psiAnnotation, psiClass, "doNotUseGetters", ConfigKey.TOSTRING_DO_NOT_USE_GETTERS); final boolean includeFieldNames = readAnnotationOrConfigProperty(psiAnnotation, psiClass, "includeFieldNames", ConfigKey.TOSTRING_INCLUDE_FIELD_NAMES); final StringBuilder paramString = new StringBuilder(); if (callSuper) { paramString.append("super=\" + super.toString() + \", "); } for (MemberInfo memberInfo : memberInfos) { if (includeFieldNames) { paramString.append(memberInfo.getName()).append('='); } paramString.append("\"+"); final PsiType classFieldType = memberInfo.getType(); if (classFieldType instanceof PsiArrayType) { final PsiType componentType = ((PsiArrayType)classFieldType).getComponentType(); if (componentType instanceof PsiPrimitiveType) { paramString.append("java.util.Arrays.toString("); } else { paramString.append("java.util.Arrays.deepToString("); } } final String memberAccessor = EqualsAndHashCodeToStringHandler.getMemberAccessorName(memberInfo, doNotUseGetters, psiClass); paramString.append("this.").append(memberAccessor); if (classFieldType instanceof PsiArrayType) { paramString.append(")"); } paramString.append("+\", "); } if (paramString.length() > 2) { paramString.delete(paramString.length() - 2, paramString.length()); } return paramString.toString(); }
createParamString
13,295
Collection<PsiAnnotation> (@NotNull PsiClass psiClass) { final Collection<PsiAnnotation> result = super.collectProcessedAnnotations(psiClass); addFieldsAnnotation(result, psiClass, TO_STRING_INCLUDE, TO_STRING_EXCLUDE); return result; }
collectProcessedAnnotations
13,296
LombokPsiElementUsage (@NotNull PsiField psiField, @NotNull PsiAnnotation psiAnnotation) { final PsiClass containingClass = psiField.getContainingClass(); if (null != containingClass) { final String psiFieldName = psiField.getName(); final Collection<MemberInfo> memberInfos = EqualsAndHashCodeToStringHandler.filterMembers(containingClass, psiAnnotation, false, INCLUDE_ANNOTATION_METHOD, ConfigKey.TOSTRING_ONLY_EXPLICITLY_INCLUDED, TO_STRING_INCLUDE, TO_STRING_EXCLUDE); if (memberInfos.stream().filter(MemberInfo::isField).map(MemberInfo::getName).anyMatch(psiFieldName::equals)) { return LombokPsiElementUsage.READ; } } return LombokPsiElementUsage.NONE; }
checkFieldUsage
13,297
boolean (@NotNull String nameHint, @NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return nameHint.equals(psiClass.getName()); }
possibleToGenerateElementNamed
13,298
Collection<String> (@NotNull PsiClass psiClass, @NotNull PsiAnnotation psiAnnotation) { return Collections.singleton(getConstructorName(psiClass)); }
getNamesOfPossibleGeneratedElements
13,299
String (@NotNull PsiClass psiClass) { return Strings.notNullize(psiClass.getName()); }
getConstructorName