Allow to annotate generated API with SinceKotlin and annotate new array functions.

This commit is contained in:
Ilya Gorbunov
2016-11-08 18:08:59 +03:00
parent dceec89572
commit 8feaaf4df0
5 changed files with 76 additions and 0 deletions
@@ -47,6 +47,7 @@ fun arrays(): List<GenericFunction> {
templates add f("contentEquals(other: SELF)") {
only(ArraysOfObjects, ArraysOfPrimitives)
jvmOnly(true)
since("1.1")
inline(Inline.Only)
infix(true)
doc {
@@ -62,6 +63,7 @@ fun arrays(): List<GenericFunction> {
templates add f("contentDeepEquals(other: SELF)") {
only(ArraysOfObjects)
jvmOnly(true)
since("1.1")
inline(Inline.Only)
infix(true)
doc {
@@ -80,6 +82,7 @@ fun arrays(): List<GenericFunction> {
templates add f("contentToString()") {
only(ArraysOfObjects, ArraysOfPrimitives)
jvmOnly(true)
since("1.1")
inline(Inline.Only)
doc { "Returns a string representation of the contents of the specified array as if it is [List]." }
returns("String")
@@ -89,6 +92,7 @@ fun arrays(): List<GenericFunction> {
templates add f("contentDeepToString()") {
only(ArraysOfObjects)
jvmOnly(true)
since("1.1")
inline(Inline.Only)
doc {
"""
@@ -106,6 +110,7 @@ fun arrays(): List<GenericFunction> {
templates add f("contentHashCode()") {
only(ArraysOfObjects, ArraysOfPrimitives)
jvmOnly(true)
since("1.1")
inline(Inline.Only)
doc {
"Returns a hash code based on the contents of this array as if it is [List]."
@@ -117,6 +122,7 @@ fun arrays(): List<GenericFunction> {
templates add f("contentDeepHashCode()") {
only(ArraysOfObjects)
jvmOnly(true)
since("1.1")
inline(Inline.Only)
doc {
"""
@@ -167,6 +167,7 @@ fun specialJS(): List<GenericFunction> {
templates add f("contentEquals(other: SELF)") {
only(ArraysOfObjects, ArraysOfPrimitives)
since("1.1")
infix(true)
doc {
"""
@@ -181,6 +182,7 @@ fun specialJS(): List<GenericFunction> {
templates add f("contentDeepEquals(other: SELF)") {
only(ArraysOfObjects)
since("1.1")
infix(true)
doc {
"""
@@ -198,6 +200,7 @@ fun specialJS(): List<GenericFunction> {
templates add f("contentToString()") {
only(ArraysOfObjects, ArraysOfPrimitives)
since("1.1")
doc { "Returns a string representation of the contents of the specified array as if it is a [List]." }
annotations("""@library("arrayToString")""")
returns("String")
@@ -206,6 +209,7 @@ fun specialJS(): List<GenericFunction> {
templates add f("contentDeepToString()") {
only(ArraysOfObjects)
since("1.1")
doc {
"""
Returns a string representation of the contents of this array as if it is a [List].
@@ -222,6 +226,7 @@ fun specialJS(): List<GenericFunction> {
templates add f("contentHashCode()") {
only(ArraysOfObjects, ArraysOfPrimitives)
since("1.1")
doc {
"Returns a hash code based on the contents of this array as if it is [List]."
}
@@ -232,6 +237,7 @@ fun specialJS(): List<GenericFunction> {
templates add f("contentDeepHashCode()") {
only(ArraysOfObjects)
since("1.1")
doc {
"""
Returns a hash code based on the contents of this array as if it is [List].
@@ -142,6 +142,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
val platformName = PrimitiveProperty<String>()
val inline = InlineProperty()
val jvmOnly = FamilyProperty<Boolean>()
val since = FamilyProperty<String>()
val typeParams = ArrayList<String>()
val returns = FamilyProperty<String>()
val operator = FamilyProperty<Boolean>()
@@ -395,6 +396,9 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
if (jvmOnly[f] ?: false) {
builder.append("@kotlin.jvm.JvmVersion\n")
}
since[f]?.let { since ->
builder.append("@SinceKotlin(\"$since\")\n")
}
annotations[f]?.let { builder.append(it).append('\n') }