Skip to content

Commit 67e60dc

Browse files
committed
[Lombok] Drop support for exclude, and of in @ToString generator
They are irrelevant or soon-to-be-deprecated in Lombok
1 parent 92e5c5f commit 67e60dc

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

plugins/lombok/lombok.k2/src/org/jetbrains/kotlin/lombok/config/annotationConfig.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,32 +554,33 @@ object ConeLombokAnnotations {
554554
val callSuper: CallSuperMode?
555555
}
556556

557+
/**
558+
* Drop `doNotUseGetters`, `exclude`, `of` arguments but report diagnostics on them.
559+
* * `doNotUseGetters` isn't relevant in Kotlin;
560+
* * `exclude`, `of` will soon be marked as deprecated in Lombok, so don't support them beforehand.
561+
*/
557562
class ToString(
558563
val includeFieldNames: Boolean?,
559564
override val callSuper: CallSuperMode?,
560-
val doNotUseGetters: Boolean?,
561565
val onlyExplicitlyIncluded: Boolean?,
562-
val excludeFields: Set<String>,
563566
annotation: FirAnnotation,
564567
) : ConeLombokAnnotation(annotation), CallSuper {
565568
companion object : ConeAnnotationCompanion<ToString>(LombokNames.TO_STRING_ID) {
566569
override fun extract(annotation: FirAnnotation, session: FirSession): ToString {
567570
return ToString(
568571
includeFieldNames = annotation.getBooleanArgument(INCLUDE_FIELD_NAMES),
569572
callSuper = annotation.getBooleanArgument(CALL_SUPER)?.let { if (it) CallSuperMode.Call else CallSuperMode.Skip },
570-
doNotUseGetters = annotation.getBooleanArgument(DO_NOT_USE_GETTERS),
571573
onlyExplicitlyIncluded = annotation.getBooleanArgument(ONLY_EXPLICITLY_INCLUDED),
572-
excludeFields = annotation.getStringArrayArgument(EXCLUDE)?.toSet() ?: emptySet(),
573574
annotation = annotation,
574575
)
575576
}
576577
}
577578
}
578579

579580
/**
580-
* Drop `doNotUseGetters`, `excludeFields`, `ofFields` arguments but report diagnostics on them.
581+
* Drop `doNotUseGetters`, `exclude`, `of` arguments but report diagnostics on them.
581582
* * `doNotUseGetters` isn't relevant in Kotlin;
582-
* * `excludeFields`, `ofFields` will soon be marked as deprecated in Lombok, so don't support them beforehand.
583+
* * `exclude`, `of` will soon be marked as deprecated in Lombok, so don't support them beforehand.
583584
*/
584585
class EqualsAndHashCode(
585586
override val callSuper: CallSuperMode?,

plugins/lombok/lombok.k2/src/org/jetbrains/kotlin/lombok/generators/ToStringGenerator.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ class ToStringGenerator(session: FirSession) : FirDeclarationGenerationExtension
139139

140140
val propertyName = property.name
141141

142-
if (property.findAnnotationOnPropertyOrField(LombokNames.TO_STRING_EXCLUDE_ID, session) != null ||
143-
propertyName.identifier in toStringConfig.excludeFields
144-
) {
142+
if (property.findAnnotationOnPropertyOrField(LombokNames.TO_STRING_EXCLUDE_ID, session) != null) {
145143
return@processAllProperties
146144
}
147145

plugins/lombok/testData/diagnostics/kotlin/toString.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,9 @@ class WithDoNotUseGettersTrue(val x: Int)
6464
// Despite the absence of behavioral difference, report a warning because the parameter is redundant and it's discrouraged to use in Kotlin.
6565
@ToString(doNotUseGetters = <!DO_NOT_USE_GETTERS_IRRELEVANT!>false<!>)
6666
class WithDoNotUseGettersFalse(val x: Int)
67+
68+
@ToString(
69+
exclude = <!ANNOTATION_ARGUMENT_IS_NOT_SUPPORTED!>[]<!>,
70+
of = <!ANNOTATION_ARGUMENT_IS_NOT_SUPPORTED!>[]<!>,
71+
)
72+
class WithUnsupportedArguments

0 commit comments

Comments
 (0)