New J2K: Add type parameters to methods declaration
This commit is contained in:
committed by
Ilya Kirillov
parent
4097ebe583
commit
14f5d866ee
@@ -290,7 +290,8 @@ class JavaToJKTreeBuilder(var symbolProvider: JKSymbolProvider) {
|
||||
},
|
||||
JKNameIdentifierImpl(name),
|
||||
parameterList.parameters.map { it.toJK() },
|
||||
body?.toJK() ?: JKBodyStub
|
||||
body?.toJK() ?: JKBodyStub,
|
||||
typeParameterList?.toJK() ?: JKTypeParameterListImpl()
|
||||
).also {
|
||||
it.psi = this
|
||||
symbolProvider.provideUniverseSymbol(this, it)
|
||||
|
||||
@@ -266,12 +266,15 @@ class NewCodeBuilder {
|
||||
override fun visitKtFunction(ktFunction: JKKtFunction) {
|
||||
printer.printIndent()
|
||||
ktFunction.modifierList.accept(this)
|
||||
printer.printWithNoIndent(" fun ", ktFunction.name.value, "(")
|
||||
printer.printWithNoIndent(" fun ")
|
||||
ktFunction.typeParameterList.accept(this)
|
||||
printer.printWithNoIndent(ktFunction.name.value, "(")
|
||||
renderList(ktFunction.parameters) {
|
||||
it.accept(this)
|
||||
}
|
||||
printer.printWithNoIndent(")", ": ")
|
||||
ktFunction.returnType.accept(this)
|
||||
renderExtraTypeParametersUpperBounds(ktFunction.typeParameterList)
|
||||
if (ktFunction.block !== JKBodyStub) {
|
||||
printer.block(multiline = ktFunction.block.statements.isNotEmpty()) {
|
||||
ktFunction.block.accept(this)
|
||||
|
||||
+2
-1
@@ -36,7 +36,8 @@ class JavaMethodToKotlinFunctionConversion : TransformerBasedConversion() {
|
||||
it.name,
|
||||
it.parameters,
|
||||
it.block,
|
||||
it.modifierList
|
||||
it.modifierList,
|
||||
it.typeParameterList
|
||||
)
|
||||
} else {
|
||||
it
|
||||
|
||||
@@ -38,7 +38,12 @@ class JKJavaFieldImpl(modifierList: JKModifierList, type: JKTypeElement, name: J
|
||||
}
|
||||
|
||||
class JKJavaMethodImpl(
|
||||
modifierList: JKModifierList, returnType: JKTypeElement, name: JKNameIdentifier, parameters: List<JKParameter>, block: JKBlock
|
||||
modifierList: JKModifierList,
|
||||
returnType: JKTypeElement,
|
||||
name: JKNameIdentifier,
|
||||
parameters: List<JKParameter>,
|
||||
block: JKBlock,
|
||||
typeParameterList: JKTypeParameterList
|
||||
) : JKJavaMethod, JKBranchElementBase(), PsiOwner by PsiOwnerImpl() {
|
||||
override fun <R, D> accept(visitor: JKVisitor<R, D>, data: D): R = visitor.visitJavaMethod(this, data)
|
||||
|
||||
@@ -47,7 +52,7 @@ class JKJavaMethodImpl(
|
||||
override var name: JKNameIdentifier by child(name)
|
||||
override var parameters: List<JKParameter> by children(parameters)
|
||||
override var block: JKBlock by child(block)
|
||||
|
||||
override var typeParameterList: JKTypeParameterList by child(typeParameterList)
|
||||
}
|
||||
|
||||
class JKJavaLiteralExpressionImpl(
|
||||
|
||||
@@ -48,7 +48,8 @@ class JKKtFunctionImpl(
|
||||
name: JKNameIdentifier,
|
||||
parameters: List<JKParameter>,
|
||||
block: JKBlock,
|
||||
modifierList: JKModifierList
|
||||
modifierList: JKModifierList,
|
||||
typeParameterList: JKTypeParameterList
|
||||
) : JKBranchElementBase(), JKKtFunction {
|
||||
override fun <R, D> accept(visitor: JKVisitor<R, D>, data: D): R = visitor.visitKtFunction(this, data)
|
||||
|
||||
@@ -57,6 +58,7 @@ class JKKtFunctionImpl(
|
||||
override var parameters: List<JKParameter> by children(parameters)
|
||||
override var block: JKBlock by child(block)
|
||||
override var modifierList: JKModifierList by child(modifierList)
|
||||
override var typeParameterList: JKTypeParameterList by child(typeParameterList)
|
||||
}
|
||||
|
||||
sealed class JKKtQualifierImpl : JKQualifier, JKElementBase() {
|
||||
@@ -166,7 +168,7 @@ class JKKtConstructorImpl(
|
||||
override var block: JKBlock by child(block)
|
||||
override var modifierList: JKModifierList by child(modifierList)
|
||||
override var delegationCall: JKExpression by child(delegationCall)
|
||||
|
||||
override var typeParameterList: JKTypeParameterList by child(JKTypeParameterListImpl())
|
||||
override fun <R, D> accept(visitor: JKVisitor<R, D>, data: D): R = visitor.visitKtConstructor(this, data)
|
||||
}
|
||||
|
||||
@@ -184,6 +186,7 @@ class JKKtPrimaryConstructorImpl(
|
||||
override var block: JKBlock by child(block)
|
||||
override var modifierList: JKModifierList by child(modifierList)
|
||||
override var delegationCall: JKExpression by child(delegationCall)
|
||||
override var typeParameterList: JKTypeParameterList by child(JKTypeParameterListImpl())
|
||||
|
||||
override fun <R, D> accept(visitor: JKVisitor<R, D>, data: D): R = visitor.visitKtPrimaryConstructor(this, data)
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ interface JKInheritanceInfo : JKTreeElement, JKBranchElement {
|
||||
val inherit: List<JKTypeElement>
|
||||
}
|
||||
|
||||
interface JKMethod : JKDeclaration, JKModifierListOwner {
|
||||
interface JKMethod : JKDeclaration, JKModifierListOwner, JKTypeParameterListOwner {
|
||||
val name: JKNameIdentifier
|
||||
var parameters: List<JKParameter>
|
||||
val returnType: JKTypeElement
|
||||
|
||||
Reference in New Issue
Block a user