Prettify kdocs and exception messages in the generated code.

This commit is contained in:
Ilya Gorbunov
2015-05-27 18:21:17 +03:00
parent fe49a2ee51
commit ae60f7a32f
28 changed files with 1523 additions and 1522 deletions
@@ -7,7 +7,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("all(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns *true* if all elements match the given *predicate*" }
doc { "Returns `true` if all elements match the given [predicate]." }
returns("Boolean")
body {
"""
@@ -21,7 +21,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("none(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns *true* if no elements match the given *predicate*" }
doc { "Returns `true` if no elements match the given [predicate]." }
returns("Boolean")
body {
"""
@@ -33,7 +33,7 @@ fun aggregates(): List<GenericFunction> {
}
templates add f("none()") {
doc { "Returns *true* if collection has no elements" }
doc { "Returns `true` if collection has no elements." }
returns("Boolean")
body {
"""
@@ -47,7 +47,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("any(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns *true* if any element matches the given [predicate]" }
doc { "Returns `true` if at least one element matches the given [predicate]." }
returns("Boolean")
body {
"""
@@ -59,7 +59,7 @@ fun aggregates(): List<GenericFunction> {
}
templates add f("any()") {
doc { "Returns *true* if collection has at least one element" }
doc { "Returns `true` if collection has at least one element." }
returns("Boolean")
body {
"""
@@ -73,7 +73,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("count(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns the number of elements matching the given [predicate]" }
doc { "Returns the number of elements matching the given [predicate]." }
returns("Int")
body {
"""
@@ -86,7 +86,7 @@ fun aggregates(): List<GenericFunction> {
}
templates add f("count()") {
doc { "Returns the number of elements" }
doc { "Returns the number of elements in this collection." }
returns("Int")
body {
"""
@@ -95,6 +95,7 @@ fun aggregates(): List<GenericFunction> {
return count
"""
}
doc(Strings) { "Returns the length of this string."}
body(Strings) {
"return length()"
}
@@ -105,8 +106,8 @@ fun aggregates(): List<GenericFunction> {
templates add f("sumBy(transform: (T) -> Int)") {
inline(true)
doc { "Returns the sum of all values produced by [transform] function from elements in the collection" }
doc(Strings) { "Returns the sum of all values produced by [transform] function from characters in the string" }
doc { "Returns the sum of all values produced by [transform] function from elements in the collection." }
doc(Strings) { "Returns the sum of all values produced by [transform] function from characters in the string." }
returns("Int")
body {
"""
@@ -121,8 +122,8 @@ fun aggregates(): List<GenericFunction> {
templates add f("sumByDouble(transform: (T) -> Double)") {
inline(true)
doc { "Returns the sum of all values produced by [transform] function from elements in the collection" }
doc(Strings) { "Returns the sum of all values produced by [transform] function from characters in the string" }
doc { "Returns the sum of all values produced by [transform] function from elements in the collection." }
doc(Strings) { "Returns the sum of all values produced by [transform] function from characters in the string." }
returns("Double")
body {
"""
@@ -136,7 +137,7 @@ fun aggregates(): List<GenericFunction> {
}
templates add f("min()") {
doc { "Returns the smallest element or null if there are no elements" }
doc { "Returns the smallest element or `null` if there are no elements." }
returns("T?")
exclude(PrimitiveType.Boolean)
typeParam("T : Comparable<T>")
@@ -169,7 +170,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("minBy(f: (T) -> R)") {
inline(true)
doc { "Returns the first element yielding the smallest value of the given function or null if there are no elements" }
doc { "Returns the first element yielding the smallest value of the given function or `null` if there are no elements." }
typeParam("R : Comparable<R>")
typeParam("T : Any")
returns("T?")
@@ -214,7 +215,7 @@ fun aggregates(): List<GenericFunction> {
inline(true)
only(Maps)
doc { "Returns the first element yielding the smallest value of the given function or null if there are no elements" }
doc { "Returns the first element yielding the smallest value of the given function or `null` if there are no elements." }
typeParam("R : Comparable<R>")
returns("T?")
body {
@@ -238,7 +239,7 @@ fun aggregates(): List<GenericFunction> {
}
templates add f("max()") {
doc { "Returns the largest element or null if there are no elements" }
doc { "Returns the largest element or `null` if there are no elements." }
returns("T?")
exclude(PrimitiveType.Boolean)
typeParam("T : Comparable<T>")
@@ -273,7 +274,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("maxBy(f: (T) -> R)") {
inline(true)
doc { "Returns the first element yielding the largest value of the given function or null if there are no elements" }
doc { "Returns the first element yielding the largest value of the given function or `null` if there are no elements." }
typeParam("R : Comparable<R>")
typeParam("T : Any")
returns("T?")
@@ -318,7 +319,7 @@ fun aggregates(): List<GenericFunction> {
inline(true)
only(Maps)
doc { "Returns the first element yielding the largest value of the given function or null if there are no elements" }
doc { "Returns the first element yielding the largest value of the given function or `null` if there are no elements." }
typeParam("R : Comparable<R>")
returns("T?")
body {
@@ -344,7 +345,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("fold(initial: R, operation: (R, T) -> R)") {
inline(true)
doc { "Accumulates value starting with *initial* value and applying *operation* from left to right to current accumulator value and each element" }
doc { "Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each element." }
typeParam("R")
returns("R")
body {
@@ -360,7 +361,7 @@ fun aggregates(): List<GenericFunction> {
inline(true)
only(Strings, Lists, ArraysOfObjects, ArraysOfPrimitives)
doc { "Accumulates value starting with *initial* value and applying *operation* from right to left to each element and current accumulator value" }
doc { "Accumulates value starting with [initial] value and applying [operation] from right to left to each element and current accumulator value." }
typeParam("R")
returns("R")
body {
@@ -380,12 +381,12 @@ fun aggregates(): List<GenericFunction> {
inline(true)
exclude(ArraysOfObjects, Iterables, Sequences)
doc { "Accumulates value starting with the first element and applying *operation* from left to right to current accumulator value and each element" }
doc { "Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element." }
returns("T")
body {
"""
val iterator = this.iterator()
if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced")
if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.")
var accumulator = iterator.next()
while (iterator.hasNext()) {
@@ -400,14 +401,14 @@ fun aggregates(): List<GenericFunction> {
inline(true)
only(ArraysOfObjects, Iterables, Sequences)
doc { "Accumulates value starting with the first element and applying *operation* from left to right to current accumulator value and each element" }
doc { "Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element." }
typeParam("S")
typeParam("T: S")
returns("S")
body {
"""
val iterator = this.iterator()
if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced")
if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.")
var accumulator: S = iterator.next()
while (iterator.hasNext()) {
@@ -422,12 +423,12 @@ fun aggregates(): List<GenericFunction> {
inline(true)
only(Strings, ArraysOfPrimitives)
doc { "Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value" }
doc { "Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value." }
returns("T")
body {
"""
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
var accumulator = get(index--)
while (index >= 0) {
@@ -443,14 +444,14 @@ fun aggregates(): List<GenericFunction> {
inline(true)
only(Lists, ArraysOfObjects)
doc { "Accumulates value starting with last element and applying *operation* from right to left to each element and current accumulator value" }
doc { "Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value." }
typeParam("S")
typeParam("T: S")
returns("S")
body {
"""
var index = lastIndex
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced")
if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.")
var accumulator: S = get(index--)
while (index >= 0) {
@@ -465,7 +466,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("forEach(operation: (T) -> Unit)") {
inline(true)
doc { "Performs the given *operation* on each element" }
doc { "Performs the given [operation] on each element." }
returns("Unit")
body {
"""
@@ -477,7 +478,7 @@ fun aggregates(): List<GenericFunction> {
templates add f("forEachIndexed(operation: (Int, T) -> Unit)") {
inline(true)
doc { "Performs the given *operation* on each element, providing sequential index with the element" }
doc { "Performs the given [operation] on each element, providing sequential index with the element." }
returns("Unit")
body {
"""
@@ -7,7 +7,7 @@ fun arrays(): List<GenericFunction> {
templates add f("isEmpty()") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns true if the array is empty" }
doc { "Returns `true` if the array is empty." }
returns("Boolean")
body {
"return size() == 0"
@@ -16,7 +16,7 @@ fun arrays(): List<GenericFunction> {
templates add f("isNotEmpty()") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns true if the array is not empty" }
doc { "Returns `true` if the array is not empty." }
returns("Boolean")
body {
"return !isEmpty()"
@@ -25,7 +25,7 @@ fun arrays(): List<GenericFunction> {
templates add f("asIterable()") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns the Iterable that wraps the original array" }
doc { "Returns the Iterable that wraps the original array." }
returns("Iterable<T>")
body {
"""
@@ -38,7 +38,7 @@ fun arrays(): List<GenericFunction> {
templates add pval("lastIndex") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns the last valid index for the array" }
doc { "Returns the last valid index for the array." }
returns("Int")
body {
"get() = size() - 1"
@@ -47,7 +47,7 @@ fun arrays(): List<GenericFunction> {
templates add pval("indices") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns the range of valid indices for the array" }
doc { "Returns the range of valid indices for the array." }
returns("IntRange")
body {
"get() = IntRange(0, lastIndex)"
@@ -6,7 +6,7 @@ fun elements(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>()
templates add f("contains(element: T)") {
doc { "Returns true if *element* is found in the collection" }
doc { "Returns `true` if [element] is found in the collection." }
returns("Boolean")
body {
"""
@@ -25,7 +25,7 @@ fun elements(): List<GenericFunction> {
templates add f("indexOf(element: T)") {
exclude(Strings, Lists) // has native implementation
doc { "Returns first index of [element], or -1 if the collection does not contain element" }
doc { "Returns first index of [element], or -1 if the collection does not contain element." }
returns("Int")
body {
"""
@@ -71,7 +71,7 @@ fun elements(): List<GenericFunction> {
templates add f("lastIndexOf(element: T)") {
exclude(Strings, Lists) // has native implementation
doc { "Returns last index of *element*, or -1 if the collection does not contain element" }
doc { "Returns last index of [element], or -1 if the collection does not contain element." }
returns("Int")
body {
"""
@@ -119,7 +119,7 @@ fun elements(): List<GenericFunction> {
templates add f("indexOfFirst(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element" }
doc { "Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element." }
returns("Int")
body {
"""
@@ -148,7 +148,7 @@ fun elements(): List<GenericFunction> {
templates add f("indexOfLast(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element" }
doc { "Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element." }
returns("Int")
body {
"""
@@ -184,12 +184,12 @@ fun elements(): List<GenericFunction> {
if (this is List<T>)
return get(index)
return elementAtOrElse(index) { throw IndexOutOfBoundsException("Collection doesn't contain element at index $index") }
return elementAtOrElse(index) { throw IndexOutOfBoundsException("Collection doesn't contain element at index $index.") }
"""
}
body(Sequences) {
"""
return elementAtOrElse(index) { throw IndexOutOfBoundsException("Sequence doesn't contain element at index $index") }
return elementAtOrElse(index) { throw IndexOutOfBoundsException("Sequence doesn't contain element at index $index.") }
"""
}
body(Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
@@ -283,10 +283,10 @@ fun elements(): List<GenericFunction> {
templates add f("first()") {
doc { """Returns first element.
@throws NoSuchElementException if the collection is empty.
@throws [NoSuchElementException] if the collection is empty.
""" }
doc(Strings) { """Returns first character.
@throws NoSuchElementException if the string is empty.
@throws [NoSuchElementException] if the string is empty.
""" }
returns("T")
body {
@@ -294,14 +294,14 @@ fun elements(): List<GenericFunction> {
when (this) {
is List<*> -> {
if (isEmpty())
throw NoSuchElementException("Collection is empty")
throw NoSuchElementException("Collection is empty.")
else
return this[0] as T
}
else -> {
val iterator = iterator()
if (!iterator.hasNext())
throw NoSuchElementException("Collection is empty")
throw NoSuchElementException("Collection is empty.")
return iterator.next()
}
}
@@ -310,14 +310,14 @@ fun elements(): List<GenericFunction> {
body(Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
if (isEmpty())
throw NoSuchElementException("Collection is empty")
throw NoSuchElementException("Collection is empty.")
return this[0]
"""
}
}
templates add f("firstOrNull()") {
doc { "Returns the first element, or null if the collection is empty." }
doc(Strings) { "Returns the first character, or null if string is empty." }
doc { "Returns the first element, or `null` if the collection is empty." }
doc(Strings) { "Returns the first character, or `null` if string is empty." }
returns("T?")
body {
"""
@@ -348,14 +348,14 @@ fun elements(): List<GenericFunction> {
inline(true)
doc { """Returns the first element matching the given [predicate].
@throws NoSuchElementException if no such element is found.""" }
@throws [NoSuchElementException] if no such element is found.""" }
doc(Strings) { """Returns the first character matching the given [predicate].
@throws NoSuchElementException if no such character is found.""" }
@throws [NoSuchElementException] if no such character is found.""" }
returns("T")
body {
"""
for (element in this) if (predicate(element)) return element
throw NoSuchElementException("No element matching predicate was found")
throw NoSuchElementException("No element matching predicate was found.")
"""
}
}
@@ -363,8 +363,8 @@ fun elements(): List<GenericFunction> {
templates add f("firstOrNull(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns the first element matching the given [predicate], or `null` if element was not found" }
doc(Strings) { "Returns the first character matching the given [predicate], or `null` if character was not found" }
doc { "Returns the first element matching the given [predicate], or `null` if element was not found." }
doc(Strings) { "Returns the first character matching the given [predicate], or `null` if character was not found." }
returns("T?")
body {
"""
@@ -376,23 +376,23 @@ fun elements(): List<GenericFunction> {
templates add f("last()") {
doc { """Returns the last element.
@throws NoSuchElementException if the collection is empty.""" }
@throws [NoSuchElementException] if the collection is empty.""" }
doc(Strings) { """"Returns the last character.
@throws NoSuchElementException if the string is empty.""" }
@throws [NoSuchElementException] if the string is empty.""" }
returns("T")
body {
"""
when (this) {
is List<*> -> {
if (isEmpty())
throw NoSuchElementException("Collection is empty")
throw NoSuchElementException("Collection is empty.")
else
return this[this.lastIndex] as T
}
else -> {
val iterator = iterator()
if (!iterator.hasNext())
throw NoSuchElementException("Collection is empty")
throw NoSuchElementException("Collection is empty.")
var last = iterator.next()
while (iterator.hasNext())
last = iterator.next()
@@ -405,7 +405,7 @@ fun elements(): List<GenericFunction> {
"""
val iterator = iterator()
if (!iterator.hasNext())
throw NoSuchElementException("Collection is empty")
throw NoSuchElementException("Collection is empty.")
var last = iterator.next()
while (iterator.hasNext())
last = iterator.next()
@@ -415,15 +415,15 @@ fun elements(): List<GenericFunction> {
body(Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
if (isEmpty())
throw NoSuchElementException("Collection is empty")
throw NoSuchElementException("Collection is empty.")
return this[lastIndex]
"""
}
}
templates add f("lastOrNull()") {
doc { "Returns the last element, or `null` if the collection is empty" }
doc(Strings) { "Returns the last character, or `null` if the string is empty" }
doc { "Returns the last element, or `null` if the collection is empty." }
doc(Strings) { "Returns the last character, or `null` if the string is empty." }
returns("T?")
body {
"""
@@ -467,9 +467,9 @@ fun elements(): List<GenericFunction> {
templates add f("last(predicate: (T) -> Boolean)") {
inline(true)
doc { """Returns the last element matching the given [predicate].
@throws NoSuchElementException if no such element is found.""" }
@throws [NoSuchElementException] if no such element is found.""" }
doc(Strings) { """"Returns the last character matching the given [predicate].
@throws NoSuchElementException if no such character is found.""" }
@throws [NoSuchElementException] if no such character is found.""" }
returns("T")
body {
"""
@@ -568,17 +568,17 @@ fun elements(): List<GenericFunction> {
"""
when (this) {
is List<*> -> return when (size()) {
0 -> throw NoSuchElementException("Collection is empty")
0 -> throw NoSuchElementException("Collection is empty.")
1 -> this[0] as T
else -> throw IllegalArgumentException("Collection has more than one element")
else -> throw IllegalArgumentException("Collection has more than one element.")
}
else -> {
val iterator = iterator()
if (!iterator.hasNext())
throw NoSuchElementException("Collection is empty")
throw NoSuchElementException("Collection is empty.")
var single = iterator.next()
if (iterator.hasNext())
throw IllegalArgumentException("Collection has more than one element")
throw IllegalArgumentException("Collection has more than one element.")
return single
}
}
@@ -587,18 +587,18 @@ fun elements(): List<GenericFunction> {
body(Strings) {
"""
return when (length()) {
0 -> throw NoSuchElementException("Collection is empty")
0 -> throw NoSuchElementException("Collection is empty.")
1 -> this[0]
else -> throw IllegalArgumentException("Collection has more than one element")
else -> throw IllegalArgumentException("Collection has more than one element.")
}
"""
}
body(Lists, ArraysOfObjects, ArraysOfPrimitives) {
"""
return when (size()) {
0 -> throw NoSuchElementException("Collection is empty")
0 -> throw NoSuchElementException("Collection is empty.")
1 -> this[0]
else -> throw IllegalArgumentException("Collection has more than one element")
else -> throw IllegalArgumentException("Collection has more than one element.")
}
"""
}
@@ -638,8 +638,8 @@ fun elements(): List<GenericFunction> {
templates add f("single(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element" }
doc(Strings) { "Returns the single character matching the given [predicate], or throws exception if there is no or more than one matching character" }
doc { "Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element." }
doc(Strings) { "Returns the single character matching the given [predicate], or throws exception if there is no or more than one matching character." }
returns("T")
body {
"""
@@ -647,12 +647,12 @@ fun elements(): List<GenericFunction> {
var found = false
for (element in this) {
if (predicate(element)) {
if (found) throw IllegalArgumentException("Collection contains more than one matching element")
if (found) throw IllegalArgumentException("Collection contains more than one matching element.")
single = element
found = true
}
}
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate")
if (!found) throw NoSuchElementException("Collection doesn't contain any element matching predicate.")
return single as T
"""
}
@@ -660,8 +660,8 @@ fun elements(): List<GenericFunction> {
templates add f("singleOrNull(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found" }
doc(Strings) { "Returns the single character matching the given [predicate], or `null` if character was not found or more than one character was found" }
doc { "Returns the single element matching the given [predicate], or `null` if element was not found or more than one element was found." }
doc(Strings) { "Returns the single character matching the given [predicate], or `null` if character was not found or more than one character was found." }
returns("T?")
body {
"""
@@ -7,7 +7,7 @@ fun filtering(): List<GenericFunction> {
templates add f("drop(n: Int)") {
val n = "\$n"
doc { "Returns a list containing all elements except first [n] elements" }
doc { "Returns a list containing all elements except first [n] elements." }
returns("List<T>")
body {
"""
@@ -37,7 +37,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Sequences) { "Returns a sequence containing all elements except first [n] elements" }
doc(Sequences) { "Returns a sequence containing all elements except first [n] elements." }
returns(Sequences) { "Sequence<T>" }
body(Sequences) {
"""
@@ -46,7 +46,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Strings) { "Returns a string with the first [n] characters removed"}
doc(Strings) { "Returns a string with the first [n] characters removed."}
body(Strings) { "return substring(Math.min(n, length()))" }
returns(Strings) { "String" }
@@ -67,7 +67,7 @@ fun filtering(): List<GenericFunction> {
templates add f("take(n: Int)") {
val n = "\$n"
doc { "Returns a list containing first [n] elements" }
doc { "Returns a list containing first [n] elements." }
returns("List<T>")
body {
"""
@@ -83,7 +83,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Strings) { "Returns a string containing the first [n] characters from this string, or the entire string if this string is shorter"}
doc(Strings) { "Returns a string containing the first [n] characters from this string, or the entire string if this string is shorter."}
body(Strings) {
"""
require(n >= 0, { "Requested element count $n is less than zero." })
@@ -92,7 +92,7 @@ fun filtering(): List<GenericFunction> {
}
returns(Strings) { "String" }
doc(Sequences) { "Returns a sequence containing first *n* elements" }
doc(Sequences) { "Returns a sequence containing first [n] elements." }
returns(Sequences) { "Sequence<T>" }
body(Sequences) {
"""
@@ -119,11 +119,11 @@ fun filtering(): List<GenericFunction> {
templates add f("takeLast(n: Int)") {
val n = "\$n"
doc { "Returns a list containing last [n] elements" }
doc { "Returns a list containing last [n] elements." }
only(Lists, ArraysOfObjects, ArraysOfPrimitives, Strings)
returns("List<T>")
doc(Strings) { "Returns a string containing the last [n] characters from this string, or the entire string if this string is shorter"}
doc(Strings) { "Returns a string containing the last [n] characters from this string, or the entire string if this string is shorter."}
body(Strings) {
"""
require(n >= 0, { "Requested element count $n is less than zero." })
@@ -149,7 +149,7 @@ fun filtering(): List<GenericFunction> {
templates add f("dropWhile(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns a list containing all elements except first elements that satisfy the given [predicate]" }
doc { "Returns a list containing all elements except first elements that satisfy the given [predicate]." }
returns("List<T>")
body {
"""
@@ -166,7 +166,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Strings) { "Returns a string containing all characters except first characters that satisfy the given [predicate]" }
doc(Strings) { "Returns a string containing all characters except first characters that satisfy the given [predicate]." }
returns(Strings) { "String" }
body(Strings) {
"""
@@ -179,7 +179,7 @@ fun filtering(): List<GenericFunction> {
}
inline(false, Sequences)
doc(Sequences) { "Returns a sequence containing all elements except first elements that satisfy the given [predicate]" }
doc(Sequences) { "Returns a sequence containing all elements except first elements that satisfy the given [predicate]." }
returns(Sequences) { "Sequence<T>" }
body(Sequences) {
"""
@@ -192,7 +192,7 @@ fun filtering(): List<GenericFunction> {
templates add f("takeWhile(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns a list containing first elements satisfying the given [predicate]" }
doc { "Returns a list containing first elements satisfying the given [predicate]." }
returns("List<T>")
body {
"""
@@ -206,7 +206,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Strings) { "Returns a string containing the first characters that satisfy the given [predicate]"}
doc(Strings) { "Returns a string containing the first characters that satisfy the given [predicate]."}
returns(Strings) { "String" }
body(Strings) {
"""
@@ -219,7 +219,7 @@ fun filtering(): List<GenericFunction> {
}
inline(false, Sequences)
doc(Sequences) { "Returns a sequence containing first elements satisfying the given [predicate]" }
doc(Sequences) { "Returns a sequence containing first elements satisfying the given [predicate]." }
returns(Sequences) { "Sequence<T>" }
body(Sequences) {
"""
@@ -231,7 +231,7 @@ fun filtering(): List<GenericFunction> {
templates add f("filter(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns a list containing all elements matching the given [predicate]" }
doc { "Returns a list containing all elements matching the given [predicate]." }
returns("List<T>")
body {
"""
@@ -239,7 +239,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Strings) { "Returns a string containing only those characters from the original string that match the given [predicate]" }
doc(Strings) { "Returns a string containing only those characters from the original string that match the given [predicate]." }
returns(Strings) { "String" }
body(Strings) {
"""
@@ -248,7 +248,7 @@ fun filtering(): List<GenericFunction> {
}
inline(false, Sequences)
doc(Sequences) { "Returns a sequence containing all elements matching the given [predicate]" }
doc(Sequences) { "Returns a sequence containing all elements matching the given [predicate]." }
returns(Sequences) { "Sequence<T>" }
body(Sequences) {
"""
@@ -260,7 +260,7 @@ fun filtering(): List<GenericFunction> {
templates add f("filterTo(destination: C, predicate: (T) -> Boolean)") {
inline(true)
doc { "Appends all elements matching the given [predicate] into the given [destination]" }
doc { "Appends all elements matching the given [predicate] into the given [destination]." }
typeParam("C : TCollection")
returns("C")
@@ -271,7 +271,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Strings) { "Appends all characters matching the given [predicate] to the given [destination]" }
doc(Strings) { "Appends all characters matching the given [predicate] to the given [destination]." }
body(Strings) {
"""
for (index in 0..length - 1) {
@@ -286,7 +286,7 @@ fun filtering(): List<GenericFunction> {
templates add f("filterNot(predicate: (T) -> Boolean)") {
inline(true)
doc { "Returns a list containing all elements not matching the given [predicate]" }
doc { "Returns a list containing all elements not matching the given [predicate]." }
returns("List<T>")
body {
"""
@@ -294,7 +294,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Strings) { "Returns a string containing only those characters from the original string that do not match the given [predicate]" }
doc(Strings) { "Returns a string containing only those characters from the original string that do not match the given [predicate]." }
returns(Strings) { "String" }
body(Strings) {
"""
@@ -303,7 +303,7 @@ fun filtering(): List<GenericFunction> {
}
inline(false, Sequences)
doc(Sequences) { "Returns a sequence containing all elements not matching the given [predicate]" }
doc(Sequences) { "Returns a sequence containing all elements not matching the given [predicate]." }
returns(Sequences) { "Sequence<T>" }
body(Sequences) {
"""
@@ -315,7 +315,7 @@ fun filtering(): List<GenericFunction> {
templates add f("filterNotTo(destination: C, predicate: (T) -> Boolean)") {
inline(true)
doc { "Appends all elements not matching the given [predicate] to the given [destination]" }
doc { "Appends all elements not matching the given [predicate] to the given [destination]." }
typeParam("C : TCollection")
returns("C")
@@ -326,7 +326,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Strings) { "Appends all characters not matching the given [predicate] to the given [destination]" }
doc(Strings) { "Appends all characters not matching the given [predicate] to the given [destination]." }
body(Strings) {
"""
for (element in this) if (!predicate(element)) destination.append(element)
@@ -337,7 +337,7 @@ fun filtering(): List<GenericFunction> {
templates add f("filterNotNull()") {
exclude(ArraysOfPrimitives, Strings)
doc { "Returns a list containing all elements that are not null" }
doc { "Returns a list containing all elements that are not `null`." }
typeParam("T : Any")
returns("List<T>")
toNullableT = true
@@ -347,7 +347,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Sequences) { "Returns a sequence containing all elements that are not null" }
doc(Sequences) { "Returns a sequence containing all elements that are not `null`." }
returns(Sequences) { "Sequence<T>" }
body(Sequences) {
"""
@@ -358,7 +358,7 @@ fun filtering(): List<GenericFunction> {
templates add f("filterNotNullTo(destination: C)") {
exclude(ArraysOfPrimitives, Strings)
doc { "Appends all elements that are not null to the given [destination]" }
doc { "Appends all elements that are not `null` to the given [destination]." }
returns("C")
typeParam("C : TCollection")
typeParam("T : Any")
@@ -373,7 +373,7 @@ fun filtering(): List<GenericFunction> {
templates add f("slice(indices: Iterable<Int>)") {
only(Strings, Lists, ArraysOfPrimitives, ArraysOfObjects)
doc { "Returns a list containing elements at specified positions" }
doc { "Returns a list containing elements at specified [indices]." }
returns("List<T>")
body {
"""
@@ -385,7 +385,7 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(Strings) { "Returns a string containing characters at specified positions" }
doc(Strings) { "Returns a string containing characters at specified [indices]." }
returns(Strings) { "String" }
body(Strings) {
"""
@@ -7,7 +7,7 @@ fun generators(): List<GenericFunction> {
templates add f("plus(element: T)") {
exclude(Strings)
doc { "Returns a list containing all elements of original collection and then the given element" }
doc { "Returns a list containing all elements of original collection and then the given [element]." }
returns("List<T>")
body {
"""
@@ -26,7 +26,7 @@ fun generators(): List<GenericFunction> {
"""
}
doc(Sequences) { "Returns a sequence containing all elements of original sequence and then the given element" }
doc(Sequences) { "Returns a sequence containing all elements of original sequence and then the given [element]." }
returns(Sequences) { "Sequence<T>" }
body(Sequences) {
"""
@@ -37,7 +37,7 @@ fun generators(): List<GenericFunction> {
templates add f("plus(collection: Iterable<T>)") {
exclude(Strings, Sequences)
doc { "Returns a list containing all elements of original collection and then all elements of the given *collection*" }
doc { "Returns a list containing all elements of original collection and then all elements of the given [collection]." }
returns("List<T>")
body {
"""
@@ -60,7 +60,7 @@ fun generators(): List<GenericFunction> {
templates add f("plus(array: Array<out T>)") {
exclude(Strings, Sequences)
doc { "Returns a list containing all elements of original collection and then all elements of the given *collection*" }
doc { "Returns a list containing all elements of original collection and then all elements of the given [collection]." }
returns("List<T>")
body {
"""
@@ -82,7 +82,7 @@ fun generators(): List<GenericFunction> {
templates add f("plus(collection: Iterable<T>)") {
only(Sequences)
doc { "Returns a sequence containing all elements of original sequence and then all elements of the given [collection]" }
doc { "Returns a sequence containing all elements of original sequence and then all elements of the given [collection]." }
returns("Sequence<T>")
body {
"""
@@ -93,7 +93,7 @@ fun generators(): List<GenericFunction> {
templates add f("plus(sequence: Sequence<T>)") {
only(Sequences)
doc { "Returns a sequence containing all elements of original sequence and then all elements of the given [sequence]" }
doc { "Returns a sequence containing all elements of original sequence and then all elements of the given [sequence]." }
returns("Sequence<T>")
body {
"""
@@ -108,8 +108,8 @@ fun generators(): List<GenericFunction> {
doc {
"""
Splits original collection into pair of collections,
where *first* collection contains elements for which predicate yielded *true*,
while *second* collection contains elements for which predicate yielded *false*
where *first* collection contains elements for which [predicate] yielded [true],
while *second* collection contains elements for which [predicate] yielded [false].
"""
}
// TODO: Sequence variant
@@ -150,7 +150,7 @@ fun generators(): List<GenericFunction> {
exclude(Sequences, Strings)
doc {
"""
Returns a list of values built from elements of both collections with same indexes using provided *transform*. List has length of shortest collection.
Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection.
"""
}
typeParam("R")
@@ -185,7 +185,7 @@ fun generators(): List<GenericFunction> {
exclude(Sequences, Strings)
doc {
"""
Returns a list of values built from elements of both collections with same indexes using provided *transform*. List has length of shortest collection.
Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection.
"""
}
typeParam("R")
@@ -222,7 +222,7 @@ fun generators(): List<GenericFunction> {
only(ArraysOfPrimitives)
doc {
"""
Returns a list of values built from elements of both collections with same indexes using provided *transform*. List has length of shortest collection.
Returns a list of values built from elements of both collections with same indexes using provided [transform]. List has length of shortest collection.
"""
}
typeParam("V")
@@ -246,7 +246,7 @@ fun generators(): List<GenericFunction> {
only(Sequences)
doc {
"""
Returns a sequence of values built from elements of both collections with same indexes using provided *transform*. Resulting sequence has length of shortest input sequences.
Returns a sequence of values built from elements of both collections with same indexes using provided [transform]. Resulting sequence has length of shortest input sequences.
"""
}
typeParam("R")
@@ -11,7 +11,7 @@ fun guards(): List<GenericFunction> {
templates add f("requireNoNulls()") {
include(Lists)
exclude(Strings, ArraysOfPrimitives)
doc { "Returns an original collection containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements" }
doc { "Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements." }
typeParam("T : Any")
toNullableT = true
returns("SELF")
@@ -19,7 +19,7 @@ fun guards(): List<GenericFunction> {
"""
for (element in this) {
if (element == null) {
throw IllegalArgumentException("null element found in $THIS")
throw IllegalArgumentException("null element found in $THIS.")
}
}
return this as SELF
@@ -27,7 +27,7 @@ fun guards(): List<GenericFunction> {
}
body(Sequences) {
"""
return map { it ?: throw IllegalArgumentException("null element found in $THIS") }
return map { it ?: throw IllegalArgumentException("null element found in $THIS.") }
"""
}
}
@@ -7,7 +7,7 @@ fun mapping(): List<GenericFunction> {
templates add f("withIndices()") {
deprecate { "Use withIndex() instead." }
doc { "Returns a list containing pairs of each element of the original collection and their index" }
doc { "Returns a list containing pairs of each element of the original collection and their index." }
returns("List<Pair<Int, T>>")
body {
"""
@@ -17,7 +17,7 @@ fun mapping(): List<GenericFunction> {
}
returns(Sequences) { "Sequence<Pair<Int, T>>" }
doc(Sequences) { "Returns a sequence containing pairs of each element of the original collection and their index" }
doc(Sequences) { "Returns a sequence containing pairs of each element of the original collection and their index." }
body(Sequences) {
"""
var index = 0
@@ -27,7 +27,7 @@ fun mapping(): List<GenericFunction> {
}
templates add f("withIndex()") {
doc { "Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection" }
doc { "Returns a lazy [Iterable] of [IndexedValue] for each element of the original collection." }
returns("Iterable<IndexedValue<T>>")
body {
"""
@@ -36,7 +36,7 @@ fun mapping(): List<GenericFunction> {
}
returns(Sequences) { "Sequence<IndexedValue<T>>" }
doc(Sequences) { "Returns a sequence of [IndexedValue] for each element of the original sequence" }
doc(Sequences) { "Returns a sequence of [IndexedValue] for each element of the original sequence." }
body(Sequences) {
"""
return IndexingSequence(this)
@@ -47,7 +47,7 @@ fun mapping(): List<GenericFunction> {
templates add f("mapIndexed(transform: (Int, T) -> R)") {
inline(true)
doc { "Returns a list containing the results of applying the given *transform* function to each element and its index of the original collection" }
doc { "Returns a list containing the results of applying the given [transform] function to each element and its index of the original collection." }
typeParam("R")
returns("List<R>")
body {
@@ -61,7 +61,7 @@ fun mapping(): List<GenericFunction> {
}
inline(false, Sequences)
returns(Sequences) { "Sequence<R>" }
doc(Sequences) { "Returns a sequence containing the results of applying the given *transform* function to each element and its index of the original sequence" }
doc(Sequences) { "Returns a sequence containing the results of applying the given [transform] function to each element and its index of the original sequence." }
body(Sequences) {
"return TransformingIndexedSequence(this, transform)"
}
@@ -70,7 +70,7 @@ fun mapping(): List<GenericFunction> {
templates add f("map(transform: (T) -> R)") {
inline(true)
doc { "Returns a list containing the results of applying the given *transform* function to each element of the original collection" }
doc { "Returns a list containing the results of applying the given [transform] function to each element of the original collection." }
typeParam("R")
returns("List<R>")
body {
@@ -85,7 +85,7 @@ fun mapping(): List<GenericFunction> {
inline(false, Sequences)
returns(Sequences) { "Sequence<R>" }
doc(Sequences) { "Returns a sequence containing the results of applying the given *transform* function to each element of the original sequence" }
doc(Sequences) { "Returns a sequence containing the results of applying the given [transform] function to each element of the original sequence." }
body(Sequences) {
"return TransformingSequence(this, transform)"
}
@@ -95,7 +95,7 @@ fun mapping(): List<GenericFunction> {
templates add f("mapNotNull(transform: (T) -> R)") {
inline(true)
exclude(Strings, ArraysOfPrimitives)
doc { "Returns a list containing the results of applying the given *transform* function to each non-null element of the original collection" }
doc { "Returns a list containing the results of applying the given [transform] function to each non-null element of the original collection." }
typeParam("T : Any")
typeParam("R")
returns("List<R>")
@@ -106,7 +106,7 @@ fun mapping(): List<GenericFunction> {
"""
}
doc(Sequences) { "Returns a sequence containing the results of applying the given *transform* function to each non-null element of the original sequence" }
doc(Sequences) { "Returns a sequence containing the results of applying the given [transform] function to each non-null element of the original sequence." }
returns(Sequences) { "Sequence<R>" }
inline(false, Sequences)
body(Sequences) {
@@ -121,8 +121,8 @@ fun mapping(): List<GenericFunction> {
doc {
"""
Appends transformed elements of the original collection using the given *transform* function
to the given *destination*
Appends transformed elements of the original collection using the given [transform] function
to the given [destination].
"""
}
typeParam("R")
@@ -144,8 +144,8 @@ fun mapping(): List<GenericFunction> {
doc {
"""
Appends transformed elements and their indices of the original collection using the given *transform* function
to the given *destination*
Appends transformed elements and their indices of the original collection using the given [transform] function
to the given [destination].
"""
}
typeParam("R")
@@ -168,8 +168,8 @@ fun mapping(): List<GenericFunction> {
exclude(Strings, ArraysOfPrimitives)
doc {
"""
Appends transformed non-null elements of original collection using the given *transform* function
to the given *destination*
Appends transformed non-null elements of original collection using the given [transform] function
to the given [destination].
"""
}
typeParam("T : Any")
@@ -193,7 +193,7 @@ fun mapping(): List<GenericFunction> {
inline(true)
exclude(Sequences)
doc { "Returns a single list of all elements yielded from results of *transform* function being invoked on each element of original collection" }
doc { "Returns a single list of all elements yielded from results of [transform] function being invoked on each element of original collection." }
typeParam("R")
returns("List<R>")
body {
@@ -204,7 +204,7 @@ fun mapping(): List<GenericFunction> {
templates add f("flatMap(transform: (T) -> Sequence<R>)") {
only(Sequences)
doc { "Returns a single sequence of all elements from results of *transform* function being invoked on each element of original sequence" }
doc { "Returns a single sequence of all elements from results of [transform] function being invoked on each element of original sequence." }
typeParam("R")
returns("Sequence<R>")
body {
@@ -215,7 +215,7 @@ fun mapping(): List<GenericFunction> {
templates add f("flatMapTo(destination: C, transform: (T) -> Iterable<R>)") {
inline(true)
exclude(Sequences)
doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original collection, to the given *destination*" }
doc { "Appends all elements yielded from results of [transform] function being invoked on each element of original collection, to the given [destination]." }
typeParam("R")
typeParam("C : MutableCollection<in R>")
returns("C")
@@ -235,7 +235,7 @@ fun mapping(): List<GenericFunction> {
inline(true)
only(Sequences)
doc { "Appends all elements yielded from results of *transform* function being invoked on each element of original sequence, to the given *destination*" }
doc { "Appends all elements yielded from results of [transform] function being invoked on each element of original sequence, to the given [destination]." }
typeParam("R")
typeParam("C : MutableCollection<in R>")
returns("C")
@@ -253,7 +253,7 @@ fun mapping(): List<GenericFunction> {
templates add f("groupBy(toKey: (T) -> K)") {
inline(true)
doc { "Returns a map of the elements in original collection grouped by the result of given *toKey* function" }
doc { "Returns a map of the elements in original collection grouped by the result of given [toKey] function." }
typeParam("K")
returns("Map<K, List<T>>")
body { "return groupByTo(LinkedHashMap<K, MutableList<T>>(), toKey)" }
@@ -263,7 +263,7 @@ fun mapping(): List<GenericFunction> {
inline(true)
typeParam("K")
doc { "Appends elements from original collection grouped by the result of given *toKey* function to the given *map*" }
doc { "Appends elements from original collection grouped by the result of given [toKey] function to the given [map]." }
returns("Map<K, MutableList<T>>")
body {
"""
@@ -24,7 +24,7 @@ fun numeric(): List<GenericFunction> {
templates add f("average()") {
exclude(Strings)
doc { "Returns an average value of elements in the collection"}
doc { "Returns an average value of elements in the collection."}
returns("Double")
platformName("averageOf<T>")
body {
@@ -6,7 +6,7 @@ fun ordering(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>()
templates add f("reverse()") {
doc { "Returns a list with elements in reversed order" }
doc { "Returns a list with elements in reversed order." }
returns { "List<T>" }
body {
"""
@@ -16,7 +16,7 @@ fun ordering(): List<GenericFunction> {
"""
}
doc(Strings) { "Returns a string with characters in reversed order" }
doc(Strings) { "Returns a string with characters in reversed order." }
returns(Strings) { "String" }
body(Strings) {
// TODO: Replace with StringBuilder(this) when JS can handle it
@@ -31,7 +31,7 @@ fun ordering(): List<GenericFunction> {
templates add f("sort()") {
doc {
"""
Returns a sorted list of all elements
Returns a sorted list of all elements.
"""
}
returns("List<T>")
@@ -53,7 +53,7 @@ fun ordering(): List<GenericFunction> {
templates add f("toSortedList()") {
doc {
"""
Returns a sorted list of all elements
Returns a sorted list of all elements.
"""
}
returns("List<T>")
@@ -72,7 +72,7 @@ fun ordering(): List<GenericFunction> {
templates add f("sortDescending()") {
doc {
"""
Returns a sorted list of all elements, in descending order
Returns a sorted list of all elements, in descending order.
"""
}
returns("List<T>")
@@ -96,7 +96,7 @@ fun ordering(): List<GenericFunction> {
doc {
"""
Returns a sorted list of all elements, ordered by results of specified *order* function.
Returns a sorted list of all elements, ordered by results of specified [order] function.
"""
}
returns("List<T>")
@@ -118,7 +118,7 @@ fun ordering(): List<GenericFunction> {
templates add f("toSortedListBy(order: (T) -> V)") {
doc {
"""
Returns a sorted list of all elements, ordered by results of specified *order* function.
Returns a sorted list of all elements, ordered by results of specified [order] function.
"""
}
returns("List<T>")
@@ -141,7 +141,7 @@ fun ordering(): List<GenericFunction> {
doc {
"""
Returns a sorted list of all elements, in descending order by results of specified *order* function.
Returns a sorted list of all elements, in descending order by results of specified [order] function.
"""
}
returns("List<T>")
@@ -163,7 +163,7 @@ fun ordering(): List<GenericFunction> {
templates add f("sortBy(comparator: Comparator<in T>)") {
doc {
"""
Returns a list of all elements, sorted by the specified *comparator*
Returns a list of all elements, sorted by the specified [comparator].
"""
}
returns("List<T>")
@@ -8,8 +8,8 @@ fun ranges(): List<GenericFunction> {
templates add f("reversed()") {
only(RangesOfPrimitives, ProgressionsOfPrimitives)
exclude(PrimitiveType.Boolean)
doc(ProgressionsOfPrimitives) { "Returns a progression that goes over the same range in the opposite direction with the same step" }
doc(RangesOfPrimitives) { "Returns a progression that goes over this range in reverse direction" }
doc(ProgressionsOfPrimitives) { "Returns a progression that goes over the same range in the opposite direction with the same step." }
doc(RangesOfPrimitives) { "Returns a progression that goes over this range in reverse direction." }
returns("TProgression")
body(RangesOfPrimitives) {
"return TProgression(end, start, -ONE)"
@@ -22,8 +22,8 @@ fun ranges(): List<GenericFunction> {
templates add f("step(step: SUM)") {
only(RangesOfPrimitives, ProgressionsOfPrimitives)
exclude(PrimitiveType.Boolean)
doc(ProgressionsOfPrimitives) { "Returns a progression that goes over the same range with the given step" }
doc(RangesOfPrimitives) { "Returns a progression that goes over this range with given step" }
doc(ProgressionsOfPrimitives) { "Returns a progression that goes over the same range with the given step." }
doc(RangesOfPrimitives) { "Returns a progression that goes over this range with given step." }
returns("TProgression")
body(RangesOfPrimitives) {
"""
@@ -33,7 +33,7 @@ fun ranges(): List<GenericFunction> {
}
bodyForTypes(RangesOfPrimitives, PrimitiveType.Float, PrimitiveType.Double) {
"""
if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN")
if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN.")
checkStepIsPositive(step > 0, step)
return TProgression(start, end, step)
"""
@@ -45,7 +45,7 @@ fun sequences(): List<GenericFunction> {
templates add f("asSequence()") {
include(Maps)
exclude(Sequences)
doc { "Returns a sequence from the given collection" }
doc { "Returns a sequence from the given collection." }
returns("Sequence<T>")
body {
"""
@@ -7,7 +7,7 @@ fun snapshots(): List<GenericFunction> {
val templates = arrayListOf<GenericFunction>()
templates add f("toCollection(collection: C)") {
doc { "Appends all elements to the given *collection*" }
doc { "Appends all elements to the given [collection]." }
returns("C")
typeParam("C : MutableCollection<in T>")
body {
@@ -21,7 +21,7 @@ fun snapshots(): List<GenericFunction> {
}
templates add f("toSet()") {
doc { "Returns a Set of all elements" }
doc { "Returns a [Set] of all elements." }
returns("Set<T>")
body { "return toCollection(LinkedHashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
body(Sequences) { "return toCollection(LinkedHashSet<T>())" }
@@ -30,7 +30,7 @@ fun snapshots(): List<GenericFunction> {
}
templates add f("toHashSet()") {
doc { "Returns a HashSet of all elements" }
doc { "Returns a [HashSet] of all elements." }
returns("HashSet<T>")
body { "return toCollection(HashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
body(Sequences) { "return toCollection(HashSet<T>())" }
@@ -39,13 +39,13 @@ fun snapshots(): List<GenericFunction> {
}
templates add f("toSortedSet()") {
doc { "Returns a SortedSet of all elements" }
doc { "Returns a [SortedSet] of all elements." }
returns("SortedSet<T>")
body { "return toCollection(TreeSet<T>())" }
}
templates add f("toArrayList()") {
doc { "Returns an ArrayList of all elements" }
doc { "Returns an [ArrayList] of all elements." }
returns("ArrayList<T>")
body { "return toCollection(ArrayList<T>())" }
body(Iterables) {
@@ -69,7 +69,7 @@ fun snapshots(): List<GenericFunction> {
templates add f("toList()") {
only(Maps)
doc { "Returns a List containing all key-value pairs" }
doc { "Returns a [List] containing all key-value pairs." }
returns("List<Pair<K, V>>")
body {
"""
@@ -82,13 +82,13 @@ fun snapshots(): List<GenericFunction> {
}
templates add f("toList()") {
doc { "Returns a List containing all elements" }
doc { "Returns a [List] containing all elements." }
returns("List<T>")
body { "return this.toArrayList()" }
}
templates add f("toLinkedList()") {
doc { "Returns a LinkedList containing all elements" }
doc { "Returns a [LinkedList] containing all elements." }
returns("LinkedList<T>")
body { "return toCollection(LinkedList<T>())" }
}
@@ -98,7 +98,7 @@ fun snapshots(): List<GenericFunction> {
typeParam("K")
doc {
"""
Returns Map containing all the values from the given collection indexed by *selector*
Returns Map containing all the values from the given collection indexed by [selector].
"""
}
returns("Map<K, T>")
@@ -155,7 +155,7 @@ fun snapshots(): List<GenericFunction> {
typeParam("V")
doc {
"""
Returns Map containing all the values provided by *transform* and indexed by *selector* from the given collection
Returns Map containing all the values provided by [transform] and indexed by [selector] from the given collection.
"""
}
returns("Map<K, V>")
@@ -7,7 +7,7 @@ fun specialJS(): List<GenericFunction> {
templates add f("asList()") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns a list that wraps the original array" }
doc { "Returns a [List] that wraps the original array." }
returns("List<T>")
body(ArraysOfObjects) {
"""
@@ -7,7 +7,7 @@ fun specialJVM(): List<GenericFunction> {
templates add f("copyOfRange(from: Int, to: Int)") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns new array which is a copy of range of original array" }
doc { "Returns new array which is a copy of range of original array." }
returns("SELF")
returns(ArraysOfObjects) { "Array<T>" }
body {
@@ -17,7 +17,7 @@ fun specialJVM(): List<GenericFunction> {
templates add f("copyOf()") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns new array which is a copy of the original array" }
doc { "Returns new array which is a copy of the original array." }
returns("SELF")
returns(ArraysOfObjects) { "Array<T>" }
body {
@@ -31,7 +31,7 @@ fun specialJVM(): List<GenericFunction> {
// This overload can cause nulls if array size is expanding, hence different return overload
templates add f("copyOf(newSize: Int)") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns new array which is a copy of the original array" }
doc { "Returns new array which is a copy of the original array." }
returns("SELF")
body {
"return Arrays.copyOf(this, newSize)"
@@ -44,7 +44,7 @@ fun specialJVM(): List<GenericFunction> {
templates add f("fill(element: T)") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Fills original array with the provided value" }
doc { "Fills original array with the provided value." }
returns { "SELF" }
returns(ArraysOfObjects) { "Array<out T>" }
body {
@@ -68,7 +68,7 @@ fun specialJVM(): List<GenericFunction> {
templates add f("sort(fromIndex: Int = 0, toIndex: Int = size())") {
only(ArraysOfObjects, ArraysOfPrimitives)
exclude(PrimitiveType.Boolean)
doc { "Sorts array or range in array inplace" }
doc { "Sorts array or range in array inplace." }
returns("Unit")
body {
"Arrays.sort(this, fromIndex, toIndex)"
@@ -76,7 +76,7 @@ fun specialJVM(): List<GenericFunction> {
}
templates add f("filterIsInstanceTo(destination: C, klass: Class<R>)") {
doc { "Appends all elements that are instances of specified class to the given *destination*" }
doc { "Appends all elements that are instances of specified class to the given [destination]." }
receiverAsterisk(true)
typeParam("C : MutableCollection<in R>")
typeParam("R")
@@ -91,7 +91,7 @@ fun specialJVM(): List<GenericFunction> {
}
templates add f("filterIsInstance(klass: Class<R>)") {
doc { "Returns a list containing all elements that are instances of specified class" }
doc { "Returns a list containing all elements that are instances of specified class." }
receiverAsterisk(true)
typeParam("R")
returns("List<R>")
@@ -102,7 +102,7 @@ fun specialJVM(): List<GenericFunction> {
}
exclude(ArraysOfPrimitives, Strings)
doc(Sequences) { "Returns a sequence containing all elements that are instances of specified class" }
doc(Sequences) { "Returns a sequence containing all elements that are instances of specified class." }
returns(Sequences) { "Sequence<R>" }
body(Sequences) {
"""
@@ -112,7 +112,7 @@ fun specialJVM(): List<GenericFunction> {
}
templates add f("filterIsInstanceTo(destination: C)") {
doc { "Appends all elements that are instances of specified type parameter R to the given *destination*" }
doc { "Appends all elements that are instances of specified type parameter R to the given [destination]." }
typeParam("reified R")
typeParam("C : MutableCollection<in R>")
inline(true)
@@ -128,7 +128,7 @@ fun specialJVM(): List<GenericFunction> {
}
templates add f("filterIsInstance()") {
doc { "Returns a list containing all elements that are instances of specified type parameter R" }
doc { "Returns a list containing all elements that are instances of specified type parameter R." }
typeParam("reified R")
returns("List<R>")
inline(true)
@@ -140,7 +140,7 @@ fun specialJVM(): List<GenericFunction> {
}
exclude(ArraysOfPrimitives, Strings)
doc(Sequences) { "Returns a sequence containing all elements that are instances of specified type parameter R" }
doc(Sequences) { "Returns a sequence containing all elements that are instances of specified type parameter R." }
returns(Sequences) { "Sequence<R>" }
inline(true)
receiverAsterisk(true)
@@ -153,7 +153,7 @@ fun specialJVM(): List<GenericFunction> {
templates add f("asList()") {
only(ArraysOfObjects, ArraysOfPrimitives)
doc { "Returns a list that wraps the original array" }
doc { "Returns a [List] that wraps the original array." }
returns("List<T>")
body(ArraysOfObjects) {
"""