[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 {
|
||||
+field("type", coneKotlinTypeType)
|
||||
+field("delegatedTypeRef", typeRef, nullable = true)
|
||||
// TODO: add supertype in subsequent commits
|
||||
}
|
||||
|
||||
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 fullQualifiedName: String get() = super.fullQualifiedName!!
|
||||
override val parentRefs = mutableListOf<ElementOrRef<Element, Field>>()
|
||||
val additionalSupertypeInterfaces = mutableListOf<TypeRef>()
|
||||
var defaultImplementation: Implementation? = null
|
||||
val customImplementations = mutableListOf<Implementation>()
|
||||
|
||||
|
||||
+11
-12
@@ -55,25 +55,24 @@ fun SmartPrinter.printElement(element: Element) {
|
||||
print("${kind!!.title} $type")
|
||||
print(typeParameters())
|
||||
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(" : ")
|
||||
if (needPureAbstractElement) {
|
||||
print("${pureAbstractElementType.type}()")
|
||||
if (parentRefs.isNotEmpty()) {
|
||||
if (superTypesStrings.isNotEmpty()) {
|
||||
print(", ")
|
||||
}
|
||||
}
|
||||
print(
|
||||
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(superTypesStrings.joinToString(", "),)
|
||||
}
|
||||
print(multipleUpperBoundsList())
|
||||
println(" {")
|
||||
|
||||
+1
@@ -67,6 +67,7 @@ fun Element.collectImports(): List<String> {
|
||||
if (needPureAbstractElement) {
|
||||
baseTypes += pureAbstractElementType.fullQualifiedName
|
||||
}
|
||||
baseTypes.addAll(additionalSupertypeInterfaces.map { it.fullQualifiedName!! })
|
||||
return collectImportsInternal(
|
||||
baseTypes,
|
||||
ImportKind.Element,
|
||||
|
||||
Reference in New Issue
Block a user