New J2K: Add typeParameters to JKClass
This commit is contained in:
committed by
Ilya Kirillov
parent
1f59f91aeb
commit
33b66ec17e
@@ -253,8 +253,11 @@ class JavaToJKTreeBuilder(var symbolProvider: JKSymbolProvider) {
|
|||||||
val implTypes = this.implementsList?.mapTypes().orEmpty()
|
val implTypes = this.implementsList?.mapTypes().orEmpty()
|
||||||
val extTypes = this.extendsList?.mapTypes().orEmpty()
|
val extTypes = this.extendsList?.mapTypes().orEmpty()
|
||||||
return JKClassImpl(
|
return JKClassImpl(
|
||||||
with(modifierMapper) { modifierList.toJK() }, JKNameIdentifierImpl(name!!), JKInheritanceInfoImpl(extTypes + implTypes),
|
with(modifierMapper) { modifierList.toJK() },
|
||||||
classKind
|
JKNameIdentifierImpl(name!!),
|
||||||
|
JKInheritanceInfoImpl(extTypes + implTypes),
|
||||||
|
classKind,
|
||||||
|
typeParameterList?.toJK() ?: JKTypeParameterListImpl()
|
||||||
).also { jkClassImpl ->
|
).also { jkClassImpl ->
|
||||||
jkClassImpl.declarationList = children.mapNotNull {
|
jkClassImpl.declarationList = children.mapNotNull {
|
||||||
ElementVisitor().apply { it.accept(this) }.resultElement as? JKDeclaration
|
ElementVisitor().apply { it.accept(this) }.resultElement as? JKDeclaration
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ class NewCodeBuilder {
|
|||||||
printer.print(classKindString(klass.classKind))
|
printer.print(classKindString(klass.classKind))
|
||||||
builder.append(" ")
|
builder.append(" ")
|
||||||
printer.printWithNoIndent(klass.name.value)
|
printer.printWithNoIndent(klass.name.value)
|
||||||
|
klass.typeParameterList.accept(this)
|
||||||
|
|
||||||
val primaryConstructor = klass.primaryConstructor()
|
val primaryConstructor = klass.primaryConstructor()
|
||||||
if (primaryConstructor != null && primaryConstructor.parameters.isNotEmpty()) {
|
if (primaryConstructor != null && primaryConstructor.parameters.isNotEmpty()) {
|
||||||
|
|||||||
@@ -23,7 +23,13 @@ class ClassToObjectPromotionConversion : RecursiveApplicableConversionBase() {
|
|||||||
companion.invalidate()
|
companion.invalidate()
|
||||||
element.invalidate()
|
element.invalidate()
|
||||||
return recurse(
|
return recurse(
|
||||||
JKClassImpl(element.modifierList, element.name, element.inheritance, JKClass.ClassKind.OBJECT)
|
JKClassImpl(
|
||||||
|
element.modifierList,
|
||||||
|
element.name,
|
||||||
|
element.inheritance,
|
||||||
|
JKClass.ClassKind.OBJECT,
|
||||||
|
element.typeParameterList
|
||||||
|
)
|
||||||
.apply {
|
.apply {
|
||||||
declarationList = companion.declarationList
|
declarationList = companion.declarationList
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -48,7 +48,8 @@ class StaticsToCompanionExtractConversion : RecursiveApplicableConversionBase()
|
|||||||
),
|
),
|
||||||
JKNameIdentifierImpl(""),
|
JKNameIdentifierImpl(""),
|
||||||
JKInheritanceInfoImpl(emptyList()),
|
JKInheritanceInfoImpl(emptyList()),
|
||||||
JKClass.ClassKind.COMPANION
|
JKClass.ClassKind.COMPANION,
|
||||||
|
JKTypeParameterListImpl()
|
||||||
).also { element.declarationList += it }
|
).also { element.declarationList += it }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ class JKClassImpl(
|
|||||||
modifierList: JKModifierList,
|
modifierList: JKModifierList,
|
||||||
name: JKNameIdentifier,
|
name: JKNameIdentifier,
|
||||||
inheritance: JKInheritanceInfo,
|
inheritance: JKInheritanceInfo,
|
||||||
override var classKind: JKClass.ClassKind
|
override var classKind: JKClass.ClassKind,
|
||||||
|
typeParameterList: JKTypeParameterList
|
||||||
) : JKClass, JKBranchElementBase(), PsiOwner by PsiOwnerImpl() {
|
) : JKClass, JKBranchElementBase(), PsiOwner by PsiOwnerImpl() {
|
||||||
override fun <R, D> accept(visitor: JKVisitor<R, D>, data: D): R = visitor.visitClass(this, data)
|
override fun <R, D> accept(visitor: JKVisitor<R, D>, data: D): R = visitor.visitClass(this, data)
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ class JKClassImpl(
|
|||||||
override var modifierList by child(modifierList)
|
override var modifierList by child(modifierList)
|
||||||
override var declarationList by children<JKDeclaration>()
|
override var declarationList by children<JKDeclaration>()
|
||||||
override val inheritance by child(inheritance)
|
override val inheritance by child(inheritance)
|
||||||
|
override var typeParameterList: JKTypeParameterList by child(typeParameterList)
|
||||||
}
|
}
|
||||||
|
|
||||||
class JKNameIdentifierImpl(override val value: String) : JKNameIdentifier, JKElementBase(), PsiOwner by PsiOwnerImpl() {
|
class JKNameIdentifierImpl(override val value: String) : JKNameIdentifier, JKElementBase(), PsiOwner by PsiOwnerImpl() {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ interface JKFile : JKTreeElement, JKBranchElement {
|
|||||||
var declarationList: List<JKDeclaration>
|
var declarationList: List<JKDeclaration>
|
||||||
}
|
}
|
||||||
|
|
||||||
interface JKClass : JKDeclaration, JKModifierListOwner, JKBranchElement {
|
interface JKClass : JKDeclaration, JKModifierListOwner, JKTypeParameterListOwner, JKBranchElement {
|
||||||
val name: JKNameIdentifier
|
val name: JKNameIdentifier
|
||||||
|
|
||||||
val inheritance: JKInheritanceInfo
|
val inheritance: JKInheritanceInfo
|
||||||
|
|||||||
Reference in New Issue
Block a user