[FIR] In tree generator make it possible to add custom super types
...to element. MR: KT-MR-12245 ^KT-60671
This commit is contained in:
committed by
Space Team
parent
ab2c129466
commit
fbdc64cdad
+1
@@ -707,6 +707,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
|
|||||||
resolvedTypeRef.configure {
|
resolvedTypeRef.configure {
|
||||||
+field("type", coneKotlinTypeType)
|
+field("type", coneKotlinTypeType)
|
||||||
+field("delegatedTypeRef", typeRef, nullable = true)
|
+field("delegatedTypeRef", typeRef, nullable = true)
|
||||||
|
// TODO: add supertype in subsequent commits
|
||||||
}
|
}
|
||||||
|
|
||||||
typeRefWithNullability.configure {
|
typeRefWithNullability.configure {
|
||||||
|
|||||||
+1
@@ -40,6 +40,7 @@ class Element(override val name: String, kind: Kind) : AbstractElement<Element,
|
|||||||
override val packageName: String = BASE_PACKAGE + kind.packageName.let { if (it.isBlank()) it else "." + it }
|
override val packageName: String = BASE_PACKAGE + kind.packageName.let { if (it.isBlank()) it else "." + it }
|
||||||
override val fullQualifiedName: String get() = super.fullQualifiedName!!
|
override val fullQualifiedName: String get() = super.fullQualifiedName!!
|
||||||
override val parentRefs = mutableListOf<ElementOrRef<Element, Field>>()
|
override val parentRefs = mutableListOf<ElementOrRef<Element, Field>>()
|
||||||
|
val additionalSupertypeInterfaces = mutableListOf<TypeRef>()
|
||||||
var defaultImplementation: Implementation? = null
|
var defaultImplementation: Implementation? = null
|
||||||
val customImplementations = mutableListOf<Implementation>()
|
val customImplementations = mutableListOf<Implementation>()
|
||||||
|
|
||||||
|
|||||||
+11
-12
@@ -55,25 +55,24 @@ fun SmartPrinter.printElement(element: Element) {
|
|||||||
print("${kind!!.title} $type")
|
print("${kind!!.title} $type")
|
||||||
print(typeParameters())
|
print(typeParameters())
|
||||||
val needPureAbstractElement = !isInterface && !allParents.any { it.kind == ImplementationKind.AbstractClass || it.kind == ImplementationKind.SealedClass }
|
val needPureAbstractElement = !isInterface && !allParents.any { it.kind == ImplementationKind.AbstractClass || it.kind == ImplementationKind.SealedClass }
|
||||||
|
val superTypesStrings = parentRefs.map {
|
||||||
|
// TODO: Factor out
|
||||||
|
var result = it.element.type
|
||||||
|
if (it.args.isNotEmpty()) {
|
||||||
|
result += it.args.values.joinToString(", ", "<", ">") { it.typeWithArguments }
|
||||||
|
}
|
||||||
|
result + it.element.kind.braces()
|
||||||
|
} + additionalSupertypeInterfaces.map { it.type }
|
||||||
|
|
||||||
if (parentRefs.isNotEmpty() || needPureAbstractElement) {
|
if (superTypesStrings.isNotEmpty() || needPureAbstractElement) {
|
||||||
print(" : ")
|
print(" : ")
|
||||||
if (needPureAbstractElement) {
|
if (needPureAbstractElement) {
|
||||||
print("${pureAbstractElementType.type}()")
|
print("${pureAbstractElementType.type}()")
|
||||||
if (parentRefs.isNotEmpty()) {
|
if (superTypesStrings.isNotEmpty()) {
|
||||||
print(", ")
|
print(", ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print(
|
print(superTypesStrings.joinToString(", "),)
|
||||||
parentRefs.joinToString(", ") {
|
|
||||||
// TODO: Factor out
|
|
||||||
var result = it.element.type
|
|
||||||
if (it.args.isNotEmpty()) {
|
|
||||||
result += it.args.values.joinToString(", ", "<", ">") { it.typeWithArguments }
|
|
||||||
}
|
|
||||||
result + it.element.kind.braces()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
print(multipleUpperBoundsList())
|
print(multipleUpperBoundsList())
|
||||||
println(" {")
|
println(" {")
|
||||||
|
|||||||
+1
@@ -67,6 +67,7 @@ fun Element.collectImports(): List<String> {
|
|||||||
if (needPureAbstractElement) {
|
if (needPureAbstractElement) {
|
||||||
baseTypes += pureAbstractElementType.fullQualifiedName
|
baseTypes += pureAbstractElementType.fullQualifiedName
|
||||||
}
|
}
|
||||||
|
baseTypes.addAll(additionalSupertypeInterfaces.map { it.fullQualifiedName!! })
|
||||||
return collectImportsInternal(
|
return collectImportsInternal(
|
||||||
baseTypes,
|
baseTypes,
|
||||||
ImportKind.Element,
|
ImportKind.Element,
|
||||||
|
|||||||
Reference in New Issue
Block a user