Converter:

Place function type parameters before function name
This commit is contained in:
Pavel V. Talanov
2013-11-25 20:07:57 +04:00
parent f912c0bc65
commit ea6b751645
17 changed files with 39 additions and 39 deletions
+15 -15
View File
@@ -29,13 +29,13 @@ public open class Function(val converter: Converter,
val typeParameters: List<Element>,
val params: Element,
var block: Block?) : Member(modifiers) {
private fun typeParametersToKotlin(): String {
return (if (typeParameters.size() > 0)
"<" + typeParameters.map { it.toKotlin() }.makeString(", ") + ">"
else
"")
private fun typeParametersToKotlin() = when {
!typeParameters.isEmpty() -> typeParameters.map { it.toKotlin() }.makeString(", ", "<", "> ")
else -> ""
}
private fun hasWhere(): Boolean = typeParameters.any { it is TypeParameter && it.hasWhere() }
private fun typeParameterWhereToKotlin(): String {
@@ -65,10 +65,10 @@ public open class Function(val converter: Converter,
}
if (converter.settings.openByDefault &&
!modifiers.contains(Modifier.ABSTRACT) &&
!isOverride &&
!modifiers.contains(Modifier.FINAL) &&
!modifiers.contains(Modifier.PRIVATE)) {
!modifiers.contains(Modifier.ABSTRACT) &&
!isOverride &&
!modifiers.contains(Modifier.FINAL) &&
!modifiers.contains(Modifier.PRIVATE)) {
resultingModifiers.add(Modifier.OPEN)
}
@@ -83,11 +83,11 @@ public open class Function(val converter: Converter,
public override fun toKotlin(): String {
return docComments.toKotlin("\n", "", "\n") +
modifiersToKotlin() +
"fun ${name.toKotlin()}${typeParametersToKotlin()}" +
"(${params.toKotlin()})" +
returnTypeToKotlin() +
typeParameterWhereToKotlin() +
block?.toKotlin()
modifiersToKotlin() +
"fun ${typeParametersToKotlin()}${name.toKotlin()}" +
"(${params.toKotlin()})" +
returnTypeToKotlin() +
typeParameterWhereToKotlin() +
block?.toKotlin()
}
}
@@ -10,16 +10,16 @@ myName = _myName
myHasDollar = _myHasDollar
}
class object {
public fun init<T>(name : T) : Identifier<T> {
public fun <T> init(name : T) : Identifier<T> {
val __ = Identifier(name, false)
return __
}
public fun init<T>(name : T, isNullable : Boolean) : Identifier<T> {
public fun <T> init(name : T, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, false)
__.myNullable = isNullable
return __
}
public fun init<T>(name : T, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
public fun <T> init(name : T, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, hasDollar)
__.myNullable = isNullable
return __
@@ -10,16 +10,16 @@ myName = _myName
myHasDollar = _myHasDollar
}
class object {
public open fun init<T>(name : T?) : Identifier<T> {
public open fun <T> init(name : T?) : Identifier<T> {
val __ = Identifier(name, false)
return __
}
public open fun init<T>(name : T?, isNullable : Boolean) : Identifier<T> {
public open fun <T> init(name : T?, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, false)
__.myNullable = isNullable
return __
}
public open fun init<T>(name : T?, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
public open fun <T> init(name : T?, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, hasDollar)
__.myNullable = isNullable
return __
@@ -1,2 +1,2 @@
fun putU<U>(u : U) {
fun <U> putU(u : U) {
}
@@ -1,2 +1,2 @@
fun putU<U>(u : U?) {
fun <U> putU(u : U?) {
}
@@ -1,2 +1,2 @@
fun putUVW<U, V, W>(u : U, v : V, w : W) {
fun <U, V, W> putUVW(u : U, v : V, w : W) {
}
@@ -1,2 +1,2 @@
fun putUVW<U, V, W>(u : U?, v : V?, w : W?) {
fun <U, V, W> putUVW(u : U?, v : V?, w : W?) {
}
+3 -3
View File
@@ -10,16 +10,16 @@ myName = _myName
myHasDollar = _myHasDollar
}
class object {
public fun init<T>(name : T) : Identifier<T> {
public fun <T> init(name : T) : Identifier<T> {
val __ = Identifier(name, false)
return __
}
public fun init<T>(name : T, isNullable : Boolean) : Identifier<T> {
public fun <T> init(name : T, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, false)
__.myNullable = isNullable
return __
}
public fun init<T>(name : T, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
public fun <T> init(name : T, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, hasDollar)
__.myNullable = isNullable
return __
+3 -3
View File
@@ -10,16 +10,16 @@ myName = _myName
myHasDollar = _myHasDollar
}
class object {
public open fun init<T>(name : T?) : Identifier<T> {
public open fun <T> init(name : T?) : Identifier<T> {
val __ = Identifier(name, false)
return __
}
public open fun init<T>(name : T?, isNullable : Boolean) : Identifier<T> {
public open fun <T> init(name : T?, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, false)
__.myNullable = isNullable
return __
}
public open fun init<T>(name : T?, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
public open fun <T> init(name : T?, hasDollar : Boolean, isNullable : Boolean) : Identifier<T> {
val __ = Identifier(name, hasDollar)
__.myNullable = isNullable
return __
@@ -1,6 +1,6 @@
package demo
class Map() {
fun put<K, V>(k : K, v : V) {
fun <K, V> put(k : K, v : V) {
}
}
class U() {
@@ -1,6 +1,6 @@
package demo
open class Map() {
open fun put<K, V>(k : K?, v : V?) {
open fun <K, V> put(k : K?, v : V?) {
}
}
open class U() {
@@ -1,6 +1,6 @@
package demo
class TestT() {
fun getT<T>() {
fun <T> getT() {
}
}
class U() {
@@ -1,6 +1,6 @@
package demo
open class TestT() {
open fun getT<T>() {
open fun <T> getT() {
}
}
open class U() {
@@ -1,2 +1,2 @@
fun max<T : Any, K : Node>(coll : Collection<out T>) : T where T : Comparable<in T>, K : Collection<in K> {
fun <T : Any, K : Node> max(coll : Collection<out T>) : T where T : Comparable<in T>, K : Collection<in K> {
}
@@ -1,2 +1,2 @@
fun max<T : Any?, K : Node?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>?, K : Collection<in K?>? {
fun <T : Any?, K : Node?> max(coll : Collection<out T?>?) : T? where T : Comparable<in T?>?, K : Collection<in K?>? {
}
@@ -1,2 +1,2 @@
fun max<T : Any>(coll : Collection<out T>) : T where T : Comparable<in T> {
fun <T : Any> max(coll : Collection<out T>) : T where T : Comparable<in T> {
}
@@ -1,2 +1,2 @@
fun max<T : Any?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>? {
fun <T : Any?> max(coll : Collection<out T?>?) : T? where T : Comparable<in T?>? {
}