[tree generator] Rename AbstractImplementation.fieldsWith(out)Default
to better describe their intended usage, see also next commit. ^KT-65773 In Progress
This commit is contained in:
committed by
Space Team
parent
6fadc51856
commit
288351d733
+2
-2
@@ -70,9 +70,9 @@ abstract class AbstractImplementation<Implementation, Element, Field>(
|
||||
|
||||
private fun withDefault(field: Field) = !field.isFinal && (field.defaultValueInImplementation != null || field.isLateinit)
|
||||
|
||||
val fieldsWithoutDefault by lazy { allFields.filterNot(::withDefault) }
|
||||
val fieldsInConstructor by lazy { allFields.filterNot(::withDefault) }
|
||||
|
||||
val fieldsWithDefault by lazy { allFields.filter(::withDefault) }
|
||||
val fieldsInBody by lazy { allFields.filter(::withDefault) }
|
||||
|
||||
var requiresOptIn = false
|
||||
|
||||
|
||||
+4
-4
@@ -39,7 +39,7 @@ abstract class AbstractImplementationPrinter<Implementation, Element, Implementa
|
||||
add(implementationOptInAnnotation)
|
||||
}
|
||||
|
||||
for (field in implementation.fieldsWithoutDefault) {
|
||||
for (field in implementation.fieldsInConstructor) {
|
||||
field.optInAnnotation?.let {
|
||||
add(it)
|
||||
}
|
||||
@@ -61,13 +61,13 @@ abstract class AbstractImplementationPrinter<Implementation, Element, Implementa
|
||||
|
||||
val fieldPrinter = makeFieldPrinter(this)
|
||||
|
||||
if (!isInterface && !isAbstract && implementation.fieldsWithoutDefault.isNotEmpty()) {
|
||||
if (!isInterface && !isAbstract && implementation.fieldsInConstructor.isNotEmpty()) {
|
||||
if (implementation.isPublic) {
|
||||
print(" @", implementationOptInAnnotation.render(), " constructor")
|
||||
}
|
||||
println("(")
|
||||
withIndent {
|
||||
implementation.fieldsWithoutDefault.forEachIndexed { _, field ->
|
||||
implementation.fieldsInConstructor.forEachIndexed { _, field ->
|
||||
if (field.isParameter) {
|
||||
print(field.name, ": ", field.typeRef.render())
|
||||
println(",")
|
||||
@@ -90,7 +90,7 @@ abstract class AbstractImplementationPrinter<Implementation, Element, Implementa
|
||||
fieldPrinter.printField(it, override = true, modality = Modality.ABSTRACT.takeIf { isAbstract })
|
||||
}
|
||||
} else {
|
||||
implementation.fieldsWithDefault.forEach {
|
||||
implementation.fieldsInBody.forEach {
|
||||
fieldPrinter.printField(it, override = true)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ class LeafBuilder<BuilderField, Element, Implementation>(
|
||||
override val typeName: String
|
||||
get() = (implementation.name ?: implementation.element.typeName) + "Builder"
|
||||
|
||||
override val allFields: List<BuilderField> by lazy { implementation.fieldsWithoutDefault }
|
||||
override val allFields: List<BuilderField> by lazy { implementation.fieldsInConstructor }
|
||||
|
||||
override val uselessFields: List<BuilderField> by lazy {
|
||||
val fieldsFromParents = parents.flatMap { it.allFields }.distinct()
|
||||
|
||||
Reference in New Issue
Block a user