[FIR generator] Remove unused class ImplementationWithArg
This commit is contained in:
committed by
Space Team
parent
7b7bcb8ffa
commit
325b152efa
-14
@@ -27,7 +27,6 @@ abstract class AbstractFirTreeImplementationConfigurator {
|
|||||||
} ?: Implementation(element, name)
|
} ?: Implementation(element, name)
|
||||||
val context = ImplementationContext(implementation)
|
val context = ImplementationContext(implementation)
|
||||||
context.apply(config)
|
context.apply(config)
|
||||||
implementation.updateMutabilityAccordingParents()
|
|
||||||
elementsWithImpl += element
|
elementsWithImpl += element
|
||||||
return implementation
|
return implementation
|
||||||
}
|
}
|
||||||
@@ -77,19 +76,6 @@ abstract class AbstractFirTreeImplementationConfigurator {
|
|||||||
return implementation.getField(name)
|
return implementation.getField(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class ParentsHolder {
|
|
||||||
operator fun plusAssign(parent: Implementation) {
|
|
||||||
implementation.addParent(parent)
|
|
||||||
}
|
|
||||||
|
|
||||||
operator fun plusAssign(parent: ImplementationWithArg) {
|
|
||||||
implementation.addParent(parent.implementation, parent.argument)
|
|
||||||
parent.argument?.let { useTypes(it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val parents = ParentsHolder()
|
|
||||||
|
|
||||||
fun optInToInternals() {
|
fun optInToInternals() {
|
||||||
implementation.requiresOptIn = true
|
implementation.requiresOptIn = true
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-27
@@ -7,18 +7,8 @@ package org.jetbrains.kotlin.fir.tree.generator.model
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.generators.tree.*
|
import org.jetbrains.kotlin.generators.tree.*
|
||||||
|
|
||||||
class ImplementationWithArg(
|
|
||||||
val implementation: Implementation,
|
|
||||||
val argument: Importable?
|
|
||||||
) : FieldContainer by implementation, ImplementationKindOwner by implementation {
|
|
||||||
val element: Element get() = implementation.element
|
|
||||||
}
|
|
||||||
|
|
||||||
class Implementation(val element: Element, val name: String?) : FieldContainer, ImplementationKindOwner {
|
class Implementation(val element: Element, val name: String?) : FieldContainer, ImplementationKindOwner {
|
||||||
private val _parents = mutableListOf<ImplementationWithArg>()
|
override val allParents: List<ImplementationKindOwner> get() = listOf(element)
|
||||||
val parents: List<ImplementationWithArg> get() = _parents
|
|
||||||
|
|
||||||
override val allParents: List<ImplementationKindOwner> get() = listOf(element) + parents
|
|
||||||
val isDefault = name == null
|
val isDefault = name == null
|
||||||
override val typeName = name ?: (element.typeName + "Impl")
|
override val typeName = name ?: (element.typeName + "Impl")
|
||||||
|
|
||||||
@@ -80,26 +70,10 @@ class Implementation(val element: Element, val name: String?) : FieldContainer,
|
|||||||
override val transformableChildren: List<FieldWithDefault>
|
override val transformableChildren: List<FieldWithDefault>
|
||||||
get() = walkableChildren.filter { it.isMutable }
|
get() = walkableChildren.filter { it.isMutable }
|
||||||
|
|
||||||
fun addParent(parent: Implementation, arg: Importable? = null) {
|
|
||||||
_parents += ImplementationWithArg(parent, arg)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun get(fieldName: String): FieldWithDefault? {
|
override fun get(fieldName: String): FieldWithDefault? {
|
||||||
return allFields.firstOrNull { it.name == fieldName }
|
return allFields.firstOrNull { it.name == fieldName }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateMutabilityAccordingParents() {
|
|
||||||
for (parent in parents) {
|
|
||||||
for (field in allFields) {
|
|
||||||
val fieldFromParent = parent[field.name] ?: continue
|
|
||||||
field.isMutable = field.isMutable || fieldFromParent.isMutable
|
|
||||||
if (field.isMutable && field.customSetter == null) {
|
|
||||||
field.withGetter = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val fieldsWithoutDefault by lazy { allFields.filter { it.defaultValueInImplementation == null } }
|
val fieldsWithoutDefault by lazy { allFields.filter { it.defaultValueInImplementation == null } }
|
||||||
val fieldsWithDefault by lazy { allFields.filter { it.defaultValueInImplementation != null } }
|
val fieldsWithDefault by lazy { allFields.filter { it.defaultValueInImplementation != null } }
|
||||||
|
|
||||||
|
|||||||
+2
-6
@@ -6,17 +6,13 @@
|
|||||||
package org.jetbrains.kotlin.fir.tree.generator.util
|
package org.jetbrains.kotlin.fir.tree.generator.util
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder
|
import org.jetbrains.kotlin.fir.tree.generator.context.AbstractFirTreeBuilder
|
||||||
import org.jetbrains.kotlin.fir.tree.generator.model.*
|
import org.jetbrains.kotlin.fir.tree.generator.model.Implementation
|
||||||
import org.jetbrains.kotlin.generators.tree.ImplementationKindOwner
|
import org.jetbrains.kotlin.generators.tree.ImplementationKindOwner
|
||||||
import org.jetbrains.kotlin.generators.tree.ImplementationKind
|
|
||||||
import org.jetbrains.kotlin.generators.tree.InterfaceAndAbstractClassConfigurator
|
import org.jetbrains.kotlin.generators.tree.InterfaceAndAbstractClassConfigurator
|
||||||
|
|
||||||
private class FirInterfaceAndAbstractClassConfigurator(builder: AbstractFirTreeBuilder) : InterfaceAndAbstractClassConfigurator() {
|
private class FirInterfaceAndAbstractClassConfigurator(builder: AbstractFirTreeBuilder) : InterfaceAndAbstractClassConfigurator() {
|
||||||
|
|
||||||
override val elements = (builder.elements + builder.elements.flatMap { it.allImplementations }).map { it.origin }
|
override val elements: List<ImplementationKindOwner> = (builder.elements + builder.elements.flatMap { it.allImplementations })
|
||||||
|
|
||||||
override val ImplementationKindOwner.origin: ImplementationKindOwner
|
|
||||||
get() = if (this is ImplementationWithArg) implementation else this
|
|
||||||
|
|
||||||
override fun shouldBeFinalClass(element: ImplementationKindOwner, allParents: Set<ImplementationKindOwner>): Boolean =
|
override fun shouldBeFinalClass(element: ImplementationKindOwner, allParents: Set<ImplementationKindOwner>): Boolean =
|
||||||
element is Implementation && element !in allParents
|
element is Implementation && element !in allParents
|
||||||
|
|||||||
+1
-4
@@ -18,16 +18,13 @@ abstract class InterfaceAndAbstractClassConfigurator {
|
|||||||
get() = element.allParents.map(::NodeImpl)
|
get() = element.allParents.map(::NodeImpl)
|
||||||
|
|
||||||
override val origin: NodeImpl
|
override val origin: NodeImpl
|
||||||
get() = if (element.origin == element) this else NodeImpl(element.origin)
|
get() = this
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = other is NodeImpl && element == other.element
|
override fun equals(other: Any?): Boolean = other is NodeImpl && element == other.element
|
||||||
|
|
||||||
override fun hashCode(): Int = element.hashCode()
|
override fun hashCode(): Int = element.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open val ImplementationKindOwner.origin: ImplementationKindOwner
|
|
||||||
get() = this
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of elements of the tree to infer their [ImplementationKind].
|
* The list of elements of the tree to infer their [ImplementationKind].
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user