Add hidden declarations for replaced overloads with String receiver in generated code.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return true
|
return true
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("none(predicate: (T) -> Boolean)") {
|
templates add f("none(predicate: (T) -> Boolean)") {
|
||||||
@@ -29,7 +30,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return true
|
return true
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("none()") {
|
templates add f("none()") {
|
||||||
@@ -41,7 +43,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return true
|
return true
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("any(predicate: (T) -> Boolean)") {
|
templates add f("any(predicate: (T) -> Boolean)") {
|
||||||
@@ -55,7 +58,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return false
|
return false
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("any()") {
|
templates add f("any()") {
|
||||||
@@ -67,7 +71,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return false
|
return false
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("count(predicate: (T) -> Boolean)") {
|
templates add f("count(predicate: (T) -> Boolean)") {
|
||||||
@@ -82,7 +87,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return count
|
return count
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("count()") {
|
templates add f("count()") {
|
||||||
@@ -95,8 +101,9 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return count
|
return count
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Returns the length of this string."}
|
doc(CharSequences) { "Returns the length of this string."}
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"return length()"
|
"return length()"
|
||||||
}
|
}
|
||||||
body(Maps, Collections, ArraysOfObjects, ArraysOfPrimitives) {
|
body(Maps, Collections, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
@@ -106,7 +113,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("sumBy(transform: (T) -> Int)") {
|
templates add f("sumBy(transform: (T) -> Int)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(CharSequences)
|
include(CharSequences, Strings)
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc { "Returns the sum of all values produced by [transform] function from elements in the collection." }
|
doc { "Returns the sum of all values produced by [transform] function from elements in the collection." }
|
||||||
doc(CharSequences) { "Returns the sum of all values produced by [transform] function from characters in the string." }
|
doc(CharSequences) { "Returns the sum of all values produced by [transform] function from characters in the string." }
|
||||||
returns("Int")
|
returns("Int")
|
||||||
@@ -123,7 +131,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("sumByDouble(transform: (T) -> Double)") {
|
templates add f("sumByDouble(transform: (T) -> Double)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(CharSequences)
|
include(CharSequences, Strings)
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc { "Returns the sum of all values produced by [transform] function from elements in the collection." }
|
doc { "Returns the sum of all values produced by [transform] function from elements in the collection." }
|
||||||
doc(CharSequences) { "Returns the sum of all values produced by [transform] function from characters in the string." }
|
doc(CharSequences) { "Returns the sum of all values produced by [transform] function from characters in the string." }
|
||||||
returns("Double")
|
returns("Double")
|
||||||
@@ -156,7 +165,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return min
|
return min
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
if (isEmpty()) return null
|
if (isEmpty()) return null
|
||||||
var min = this[0]
|
var min = this[0]
|
||||||
@@ -194,7 +204,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return minElem
|
return minElem
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
if (isEmpty()) return null
|
if (isEmpty()) return null
|
||||||
|
|
||||||
@@ -259,7 +270,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
if (isEmpty()) return null
|
if (isEmpty()) return null
|
||||||
|
|
||||||
@@ -298,7 +310,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
return maxElem
|
return maxElem
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
if (isEmpty()) return null
|
if (isEmpty()) return null
|
||||||
|
|
||||||
@@ -347,7 +360,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
templates add f("fold(initial: R, operation: (R, T) -> R)") {
|
templates add f("fold(initial: R, operation: (R, T) -> R)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
|
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
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")
|
typeParam("R")
|
||||||
returns("R")
|
returns("R")
|
||||||
@@ -363,7 +377,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
templates add f("foldRight(initial: R, operation: (T, R) -> R)") {
|
templates add f("foldRight(initial: R, operation: (T, R) -> R)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
|
|
||||||
only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(CharSequences, 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")
|
typeParam("R")
|
||||||
returns("R")
|
returns("R")
|
||||||
@@ -382,7 +397,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("reduce(operation: (T, T) -> T)") {
|
templates add f("reduce(operation: (T, T) -> T)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
exclude(ArraysOfObjects, Iterables, Sequences)
|
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." }
|
||||||
@@ -426,7 +442,8 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
templates add f("reduceRight(operation: (T, T) -> T)") {
|
templates add f("reduceRight(operation: (T, T) -> T)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
|
|
||||||
only(CharSequences, ArraysOfPrimitives)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(CharSequences, 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")
|
returns("T")
|
||||||
body {
|
body {
|
||||||
@@ -477,12 +494,14 @@ fun aggregates(): List<GenericFunction> {
|
|||||||
for (element in this) operation(element)
|
for (element in this) operation(element)
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("forEachIndexed(operation: (Int, T) -> Unit)") {
|
templates add f("forEachIndexed(operation: (Int, T) -> Unit)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
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")
|
returns("Unit")
|
||||||
body {
|
body {
|
||||||
|
|||||||
@@ -224,7 +224,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
body(Lists, CharSequences, ArraysOfPrimitives, ArraysOfObjects) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(Lists, CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects) {
|
||||||
"""
|
"""
|
||||||
for (index in indices) {
|
for (index in indices) {
|
||||||
if (predicate(this[index])) {
|
if (predicate(this[index])) {
|
||||||
@@ -254,7 +255,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
body(Lists, CharSequences, ArraysOfPrimitives, ArraysOfObjects) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(Lists, CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects) {
|
||||||
"""
|
"""
|
||||||
for (index in indices.reversed()) {
|
for (index in indices.reversed()) {
|
||||||
if (predicate(this[index])) {
|
if (predicate(this[index])) {
|
||||||
@@ -283,7 +285,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
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(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
return get(index)
|
return get(index)
|
||||||
"""
|
"""
|
||||||
@@ -323,8 +326,9 @@ fun elements(): List<GenericFunction> {
|
|||||||
return defaultValue(index)
|
return defaultValue(index)
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
inline(true, CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
inline(true, CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives)
|
||||||
|
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
|
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
|
||||||
"""
|
"""
|
||||||
@@ -335,7 +339,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
doc { "Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection." }
|
doc { "Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection." }
|
||||||
returns("T")
|
returns("T")
|
||||||
inline(true)
|
inline(true)
|
||||||
only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives)
|
||||||
body {
|
body {
|
||||||
"""
|
"""
|
||||||
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
|
return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index)
|
||||||
@@ -377,7 +382,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
return null
|
return null
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
return if (index >= 0 && index <= lastIndex) get(index) else null
|
return if (index >= 0 && index <= lastIndex) get(index) else null
|
||||||
"""
|
"""
|
||||||
@@ -387,7 +393,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
templates add f("getOrNull(index: Int)") {
|
templates add f("getOrNull(index: Int)") {
|
||||||
doc { "Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection." }
|
doc { "Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection." }
|
||||||
returns("T?")
|
returns("T?")
|
||||||
only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives)
|
||||||
body {
|
body {
|
||||||
"""
|
"""
|
||||||
return if (index >= 0 && index <= lastIndex) get(index) else null
|
return if (index >= 0 && index <= lastIndex) get(index) else null
|
||||||
@@ -422,7 +429,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
if (isEmpty())
|
if (isEmpty())
|
||||||
throw NoSuchElementException("Collection is empty.")
|
throw NoSuchElementException("Collection is empty.")
|
||||||
@@ -460,7 +468,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
return if (isEmpty()) null else this[0]
|
return if (isEmpty()) null else this[0]
|
||||||
"""
|
"""
|
||||||
@@ -478,7 +487,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
templates add f("first(predicate: (T) -> Boolean)") {
|
templates add f("first(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
|
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { """Returns the first element matching the given [predicate].
|
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(CharSequences) { """Returns the first character matching the given [predicate].
|
doc(CharSequences) { """Returns the first character matching the given [predicate].
|
||||||
@@ -495,7 +505,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
templates add f("firstOrNull(predicate: (T) -> Boolean)") {
|
templates add f("firstOrNull(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
|
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { "Returns the first element matching the given [predicate], or `null` if element was not found." }
|
doc { "Returns the first element matching the given [predicate], or `null` if element was not found." }
|
||||||
doc(CharSequences) { "Returns the first character matching the given [predicate], or `null` if character was not found." }
|
doc(CharSequences) { "Returns the first character matching the given [predicate], or `null` if character was not found." }
|
||||||
returns("T?")
|
returns("T?")
|
||||||
@@ -509,7 +520,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("find(predicate: (T) -> Boolean)") {
|
templates add f("find(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { "Returns the first element matching the given [predicate], or `null` if element was not found." }
|
doc { "Returns the first element matching the given [predicate], or `null` if element was not found." }
|
||||||
doc(CharSequences) { "Returns the first character matching the given [predicate], or `null` if character was not found." }
|
doc(CharSequences) { "Returns the first character matching the given [predicate], or `null` if character was not found." }
|
||||||
returns("T?")
|
returns("T?")
|
||||||
@@ -554,7 +566,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
return last
|
return last
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
if (isEmpty())
|
if (isEmpty())
|
||||||
throw NoSuchElementException("Collection is empty.")
|
throw NoSuchElementException("Collection is empty.")
|
||||||
@@ -594,7 +607,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
return last
|
return last
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
return if (isEmpty()) null else this[length() - 1]
|
return if (isEmpty()) null else this[length() - 1]
|
||||||
"""
|
"""
|
||||||
@@ -609,7 +623,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
templates add f("last(predicate: (T) -> Boolean)") {
|
templates add f("last(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
|
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { """Returns the last element matching the given [predicate].
|
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(CharSequences) { """"Returns the last character matching the given [predicate].
|
doc(CharSequences) { """"Returns the last character matching the given [predicate].
|
||||||
@@ -649,7 +664,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("lastOrNull(predicate: (T) -> Boolean)") {
|
templates add f("lastOrNull(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { "Returns the last element matching the given [predicate], or `null` if no such element was found." }
|
doc { "Returns the last element matching the given [predicate], or `null` if no such element was found." }
|
||||||
doc(CharSequences) { "Returns the last character matching the given [predicate], or `null` if no such character was found." }
|
doc(CharSequences) { "Returns the last character matching the given [predicate], or `null` if no such character was found." }
|
||||||
returns("T?")
|
returns("T?")
|
||||||
@@ -684,7 +700,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("findLast(predicate: (T) -> Boolean)") {
|
templates add f("findLast(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(Lists, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Lists, CharSequences, Strings)
|
||||||
doc { "Returns the last element matching the given [predicate], or `null` if no such element was found." }
|
doc { "Returns the last element matching the given [predicate], or `null` if no such element was found." }
|
||||||
doc(CharSequences) { "Returns the last character matching the given [predicate], or `null` if no such character was found." }
|
doc(CharSequences) { "Returns the last character matching the given [predicate], or `null` if no such character was found." }
|
||||||
returns("T?")
|
returns("T?")
|
||||||
@@ -726,7 +743,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
return single
|
return single
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
return when (length()) {
|
return when (length()) {
|
||||||
0 -> throw NoSuchElementException("Collection is empty.")
|
0 -> throw NoSuchElementException("Collection is empty.")
|
||||||
@@ -777,7 +795,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
return single
|
return single
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
return if (length() == 1) this[0] else null
|
return if (length() == 1) this[0] else null
|
||||||
"""
|
"""
|
||||||
@@ -791,7 +810,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("single(predicate: (T) -> Boolean)") {
|
templates add f("single(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { "Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element." }
|
doc { "Returns the single element matching the given [predicate], or throws exception if there is no or more than one matching element." }
|
||||||
doc(CharSequences) { "Returns the single character matching the given [predicate], or throws exception if there is no or more than one matching character." }
|
doc(CharSequences) { "Returns the single character matching the given [predicate], or throws exception if there is no or more than one matching character." }
|
||||||
returns("T")
|
returns("T")
|
||||||
@@ -814,7 +834,8 @@ fun elements(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("singleOrNull(predicate: (T) -> Boolean)") {
|
templates add f("singleOrNull(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { "Returns the single element matching the given [predicate], or `null` if element was not found or more than one element 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(CharSequences) { "Returns the single character matching the given [predicate], or `null` if character was not found or more than one character was found." }
|
doc(CharSequences) { "Returns the single character matching the given [predicate], or `null` if character was not found or more than one character was found." }
|
||||||
returns("T?")
|
returns("T?")
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ fun PrimitiveType.isIntegral(): Boolean = this in PrimitiveType.integralPrimitiv
|
|||||||
fun PrimitiveType.isNumeric(): Boolean = this in PrimitiveType.numericPrimitives
|
fun PrimitiveType.isNumeric(): Boolean = this in PrimitiveType.numericPrimitives
|
||||||
|
|
||||||
data class Deprecation(val message: String, val replaceWith: String? = null, val level: DeprecationLevel = DeprecationLevel.WARNING)
|
data class Deprecation(val message: String, val replaceWith: String? = null, val level: DeprecationLevel = DeprecationLevel.WARNING)
|
||||||
|
val forBinaryCompatibility = Deprecation("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||||
|
|
||||||
class ConcreteFunction(val textBuilder: (Appendable) -> Unit, val sourceFile: SourceFile)
|
class ConcreteFunction(val textBuilder: (Appendable) -> Unit, val sourceFile: SourceFile)
|
||||||
|
|
||||||
@@ -260,14 +261,14 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
|
|||||||
}
|
}
|
||||||
"TCollection" -> {
|
"TCollection" -> {
|
||||||
when (f) {
|
when (f) {
|
||||||
Strings, CharSequences -> "Appendable"
|
CharSequences, Strings -> "Appendable"
|
||||||
else -> renderType("MutableCollection<in T>", receiver)
|
else -> renderType("MutableCollection<in T>", receiver)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"T" -> {
|
"T" -> {
|
||||||
when (f) {
|
when (f) {
|
||||||
Generic -> "T"
|
Generic -> "T"
|
||||||
Strings, CharSequences -> "Char"
|
CharSequences, Strings -> "Char"
|
||||||
Maps -> "Map.Entry<K, V>"
|
Maps -> "Map.Entry<K, V>"
|
||||||
else -> primitive?.name ?: token
|
else -> primitive?.name ?: token
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,10 @@ fun filtering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Returns a string with the first [n] characters removed."}
|
doc(CharSequences) { "Returns a string with the first [n] characters removed."}
|
||||||
body(CharSequences) { "return substring(Math.min(n, length()))" }
|
body(CharSequences, Strings) { "return substring(Math.min(n, length()))" }
|
||||||
returns(CharSequences) { "String" }
|
returns(CharSequences, Strings) { "String" }
|
||||||
|
|
||||||
body(ArraysOfObjects, ArraysOfPrimitives) {
|
body(ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
@@ -88,14 +89,15 @@ fun filtering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Returns a string containing the first [n] characters from this string, or the entire string if this string is shorter."}
|
doc(CharSequences) { "Returns a string containing the first [n] characters from this string, or the entire string if this string is shorter."}
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
require(n >= 0, { "Requested character count $n is less than zero." })
|
require(n >= 0, { "Requested character count $n is less than zero." })
|
||||||
return substring(0, Math.min(n, length()))
|
return substring(0, Math.min(n, length()))
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
returns(CharSequences) { "String" }
|
returns(CharSequences, Strings) { "String" }
|
||||||
|
|
||||||
doc(Sequences) { "Returns a sequence containing first [n] elements." }
|
doc(Sequences) { "Returns a sequence containing first [n] elements." }
|
||||||
returns(Sequences) { "Sequence<T>" }
|
returns(Sequences) { "Sequence<T>" }
|
||||||
@@ -125,7 +127,8 @@ fun filtering(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("dropLast(n: Int)") {
|
templates add f("dropLast(n: Int)") {
|
||||||
val n = "\$n"
|
val n = "\$n"
|
||||||
only(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
|
||||||
|
|
||||||
doc { "Returns a list containing all elements except last [n] elements." }
|
doc { "Returns a list containing all elements except last [n] elements." }
|
||||||
returns("List<T>")
|
returns("List<T>")
|
||||||
@@ -137,8 +140,8 @@ fun filtering(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doc(CharSequences) { "Returns a string with the last [n] characters removed." }
|
doc(CharSequences) { "Returns a string with the last [n] characters removed." }
|
||||||
returns("String", CharSequences)
|
returns("String", CharSequences, Strings)
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
require(n >= 0, { "Requested character count $n is less than zero." })
|
require(n >= 0, { "Requested character count $n is less than zero." })
|
||||||
return take((length() - n).coerceAtLeast(0))
|
return take((length() - n).coerceAtLeast(0))
|
||||||
@@ -149,18 +152,19 @@ fun filtering(): List<GenericFunction> {
|
|||||||
templates add f("takeLast(n: Int)") {
|
templates add f("takeLast(n: Int)") {
|
||||||
val n = "\$n"
|
val n = "\$n"
|
||||||
doc { "Returns a list containing last [n] elements." }
|
doc { "Returns a list containing last [n] elements." }
|
||||||
only(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
|
||||||
returns("List<T>")
|
returns("List<T>")
|
||||||
|
|
||||||
doc(CharSequences) { "Returns a string containing the last [n] characters from this string, or the entire string if this string is shorter."}
|
doc(CharSequences) { "Returns a string containing the last [n] characters from this string, or the entire string if this string is shorter."}
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
require(n >= 0, { "Requested character count $n is less than zero." })
|
require(n >= 0, { "Requested character count $n is less than zero." })
|
||||||
val length = length()
|
val length = length()
|
||||||
return substring(length - Math.min(n, length), length)
|
return substring(length - Math.min(n, length), length)
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
returns(CharSequences) { "String" }
|
returns(CharSequences, Strings) { "String" }
|
||||||
|
|
||||||
body(Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
body(Lists, ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
@@ -196,9 +200,10 @@ fun filtering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Returns a string containing all characters except first characters that satisfy the given [predicate]." }
|
doc(CharSequences) { "Returns a string containing all characters except first characters that satisfy the given [predicate]." }
|
||||||
returns(CharSequences) { "String" }
|
returns(CharSequences, Strings) { "String" }
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
return trimStart(predicate)
|
return trimStart(predicate)
|
||||||
"""
|
"""
|
||||||
@@ -232,9 +237,10 @@ fun filtering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Returns a string containing the first characters that satisfy the given [predicate]."}
|
doc(CharSequences) { "Returns a string containing the first characters that satisfy the given [predicate]."}
|
||||||
returns(CharSequences) { "String" }
|
returns(CharSequences, Strings) { "String" }
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
for (index in 0..length() - 1)
|
for (index in 0..length() - 1)
|
||||||
if (!predicate(get(index))) {
|
if (!predicate(get(index))) {
|
||||||
@@ -256,7 +262,8 @@ fun filtering(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("dropLastWhile(predicate: (T) -> Boolean)") {
|
templates add f("dropLastWhile(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
only(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
|
||||||
doc { "Returns a list containing all elements except last elements that satisfy the given [predicate]." }
|
doc { "Returns a list containing all elements except last elements that satisfy the given [predicate]." }
|
||||||
returns("List<T>")
|
returns("List<T>")
|
||||||
|
|
||||||
@@ -272,8 +279,8 @@ fun filtering(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doc(CharSequences) { "Returns a string containing all characters except last characters that satisfy the given [predicate]." }
|
doc(CharSequences) { "Returns a string containing all characters except last characters that satisfy the given [predicate]." }
|
||||||
returns("String", CharSequences)
|
returns("String", CharSequences, Strings)
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
return trimEnd(predicate)
|
return trimEnd(predicate)
|
||||||
"""
|
"""
|
||||||
@@ -282,7 +289,8 @@ fun filtering(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("takeLastWhile(predicate: (T) -> Boolean)") {
|
templates add f("takeLastWhile(predicate: (T) -> Boolean)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
only(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(Lists, ArraysOfObjects, ArraysOfPrimitives, CharSequences, Strings)
|
||||||
doc { "Returns a list containing last elements satisfying the given [predicate]."}
|
doc { "Returns a list containing last elements satisfying the given [predicate]."}
|
||||||
returns("List<T>")
|
returns("List<T>")
|
||||||
|
|
||||||
@@ -298,8 +306,8 @@ fun filtering(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
doc(CharSequences) { "Returns a string containing last characters that satisfy the given [predicate]." }
|
doc(CharSequences) { "Returns a string containing last characters that satisfy the given [predicate]." }
|
||||||
returns("String", CharSequences)
|
returns("String", CharSequences, Strings)
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
for (index in lastIndex downTo 0) {
|
for (index in lastIndex downTo 0) {
|
||||||
if (!predicate(this[index])) {
|
if (!predicate(this[index])) {
|
||||||
@@ -322,9 +330,10 @@ fun filtering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Returns a string containing only those characters from the original string that match the given [predicate]." }
|
doc(CharSequences) { "Returns a string containing only those characters from the original string that match the given [predicate]." }
|
||||||
returns(CharSequences) { "String" }
|
returns(CharSequences, Strings) { "String" }
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
return filterTo(StringBuilder(), predicate).toString()
|
return filterTo(StringBuilder(), predicate).toString()
|
||||||
"""
|
"""
|
||||||
@@ -354,8 +363,9 @@ fun filtering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Appends all characters matching the given [predicate] to the given [destination]." }
|
doc(CharSequences) { "Appends all characters matching the given [predicate] to the given [destination]." }
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
for (index in 0..length() - 1) {
|
for (index in 0..length() - 1) {
|
||||||
val element = get(index)
|
val element = get(index)
|
||||||
@@ -377,9 +387,10 @@ fun filtering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Returns a string containing only those characters from the original string that do not match the given [predicate]." }
|
doc(CharSequences) { "Returns a string containing only those characters from the original string that do not match the given [predicate]." }
|
||||||
returns(CharSequences) { "String" }
|
returns(CharSequences, Strings) { "String" }
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
return filterNotTo(StringBuilder(), predicate).toString()
|
return filterNotTo(StringBuilder(), predicate).toString()
|
||||||
"""
|
"""
|
||||||
@@ -409,8 +420,9 @@ fun filtering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Appends all characters not matching the given [predicate] to the given [destination]." }
|
doc(CharSequences) { "Appends all characters not matching the given [predicate] to the given [destination]." }
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
for (element in this) if (!predicate(element)) destination.append(element)
|
for (element in this) if (!predicate(element)) destination.append(element)
|
||||||
return destination
|
return destination
|
||||||
|
|||||||
@@ -419,6 +419,7 @@ fun generators(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) {
|
doc(CharSequences) {
|
||||||
"""
|
"""
|
||||||
Splits the original string into pair of strings,
|
Splits the original string into pair of strings,
|
||||||
@@ -426,8 +427,8 @@ fun generators(): List<GenericFunction> {
|
|||||||
while *second* string contains characters for which [predicate] yielded `false`.
|
while *second* string contains characters for which [predicate] yielded `false`.
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
returns(CharSequences) { "Pair<String, String>" }
|
returns(CharSequences, Strings) { "Pair<String, String>" }
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
val first = StringBuilder()
|
val first = StringBuilder()
|
||||||
val second = StringBuilder()
|
val second = StringBuilder()
|
||||||
@@ -555,7 +556,8 @@ fun generators(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
templates add f("zip(other: String, transform: (Char, Char) -> V)") {
|
templates add f("zip(other: String, transform: (Char, Char) -> V)") {
|
||||||
only(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(CharSequences, Strings)
|
||||||
doc {
|
doc {
|
||||||
"""
|
"""
|
||||||
Returns a list of values built from characters of both strings with same indexes using provided [transform]. List has length of shortest string.
|
Returns a list of values built from characters of both strings with same indexes using provided [transform]. List has length of shortest string.
|
||||||
@@ -595,7 +597,8 @@ fun generators(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
templates add f("zip(other: String)") {
|
templates add f("zip(other: String)") {
|
||||||
only(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
only(CharSequences, Strings)
|
||||||
doc {
|
doc {
|
||||||
"""
|
"""
|
||||||
Returns a list of pairs built from characters of both strings with same indexes. List has length of shortest collection.
|
Returns a list of pairs built from characters of both strings with same indexes. List has length of shortest collection.
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ fun mapping(): List<GenericFunction> {
|
|||||||
val templates = arrayListOf<GenericFunction>()
|
val templates = arrayListOf<GenericFunction>()
|
||||||
|
|
||||||
templates add f("withIndex()") {
|
templates add f("withIndex()") {
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
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>>")
|
returns("Iterable<IndexedValue<T>>")
|
||||||
body {
|
body {
|
||||||
@@ -36,7 +37,8 @@ fun mapping(): List<GenericFunction> {
|
|||||||
body(ArraysOfObjects, ArraysOfPrimitives) {
|
body(ArraysOfObjects, ArraysOfPrimitives) {
|
||||||
"return mapIndexedTo(ArrayList<R>(size()), transform)"
|
"return mapIndexedTo(ArrayList<R>(size()), transform)"
|
||||||
}
|
}
|
||||||
body(CharSequences) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) {
|
||||||
"return mapIndexedTo(ArrayList<R>(length()), transform)"
|
"return mapIndexedTo(ArrayList<R>(length()), transform)"
|
||||||
}
|
}
|
||||||
inline(false, Sequences)
|
inline(false, Sequences)
|
||||||
@@ -59,7 +61,8 @@ fun mapping(): List<GenericFunction> {
|
|||||||
body(ArraysOfObjects, ArraysOfPrimitives, Maps) {
|
body(ArraysOfObjects, ArraysOfPrimitives, Maps) {
|
||||||
"return mapTo(ArrayList<R>(size()), transform)"
|
"return mapTo(ArrayList<R>(size()), transform)"
|
||||||
}
|
}
|
||||||
body(CharSequences) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) {
|
||||||
"return mapTo(ArrayList<R>(length()), transform)"
|
"return mapTo(ArrayList<R>(length()), transform)"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +122,8 @@ fun mapping(): List<GenericFunction> {
|
|||||||
return destination
|
return destination
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("mapIndexedTo(destination: C, transform: (Int, T) -> R)") {
|
templates add f("mapIndexedTo(destination: C, transform: (Int, T) -> R)") {
|
||||||
@@ -143,7 +147,8 @@ fun mapping(): List<GenericFunction> {
|
|||||||
return destination
|
return destination
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -186,7 +191,8 @@ fun mapping(): List<GenericFunction> {
|
|||||||
body {
|
body {
|
||||||
"return flatMapTo(ArrayList<R>(), transform)"
|
"return flatMapTo(ArrayList<R>(), transform)"
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("flatMap(transform: (T) -> Sequence<R>)") {
|
templates add f("flatMap(transform: (T) -> Sequence<R>)") {
|
||||||
@@ -215,7 +221,8 @@ fun mapping(): List<GenericFunction> {
|
|||||||
return destination
|
return destination
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
include(Maps, CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(Maps, CharSequences, Strings)
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("flatMapTo(destination: C, transform: (T) -> Sequence<R>)") {
|
templates add f("flatMapTo(destination: C, transform: (T) -> Sequence<R>)") {
|
||||||
@@ -240,7 +247,8 @@ fun mapping(): List<GenericFunction> {
|
|||||||
templates add f("groupBy(toKey: (T) -> K)") {
|
templates add f("groupBy(toKey: (T) -> K)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
|
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
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")
|
typeParam("K")
|
||||||
returns("Map<K, List<T>>")
|
returns("Map<K, List<T>>")
|
||||||
@@ -250,7 +258,8 @@ fun mapping(): List<GenericFunction> {
|
|||||||
templates add f("groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K)") {
|
templates add f("groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
|
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
typeParam("K")
|
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>>")
|
returns("Map<K, MutableList<T>>")
|
||||||
|
|||||||
@@ -39,9 +39,10 @@ fun ordering(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
doc(CharSequences) { "Returns a string with characters in reversed order." }
|
doc(CharSequences) { "Returns a string with characters in reversed order." }
|
||||||
returns(CharSequences) { "String" }
|
returns(CharSequences, Strings) { "String" }
|
||||||
body(CharSequences) {
|
body(CharSequences, Strings) {
|
||||||
// TODO: Replace with StringBuilder(this) when JS can handle it
|
// TODO: Replace with StringBuilder(this) when JS can handle it
|
||||||
"""
|
"""
|
||||||
return StringBuilder().append(this).reverse().toString()
|
return StringBuilder().append(this).reverse().toString()
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ fun sequences(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
body(CharSequences) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
if (this is String && isEmpty()) return emptySequence()
|
if (this is String && isEmpty()) return emptySequence()
|
||||||
return object : Sequence<T> {
|
return object : Sequence<T> {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ fun snapshots(): List<GenericFunction> {
|
|||||||
val templates = arrayListOf<GenericFunction>()
|
val templates = arrayListOf<GenericFunction>()
|
||||||
|
|
||||||
templates add f("toCollection(collection: C)") {
|
templates add f("toCollection(collection: C)") {
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { "Appends all elements to the given [collection]." }
|
doc { "Appends all elements to the given [collection]." }
|
||||||
returns("C")
|
returns("C")
|
||||||
typeParam("C : MutableCollection<in T>")
|
typeParam("C : MutableCollection<in T>")
|
||||||
@@ -26,7 +27,8 @@ fun snapshots(): List<GenericFunction> {
|
|||||||
returns("Set<T>")
|
returns("Set<T>")
|
||||||
body { "return toCollection(LinkedHashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
|
body { "return toCollection(LinkedHashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
|
||||||
body(Sequences) { "return toCollection(LinkedHashSet<T>())" }
|
body(Sequences) { "return toCollection(LinkedHashSet<T>())" }
|
||||||
body(CharSequences) { "return toCollection(LinkedHashSet<T>(mapCapacity(length())))" }
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) { "return toCollection(LinkedHashSet<T>(mapCapacity(length())))" }
|
||||||
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(LinkedHashSet<T>(mapCapacity(size())))" }
|
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(LinkedHashSet<T>(mapCapacity(size())))" }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,12 +37,14 @@ fun snapshots(): List<GenericFunction> {
|
|||||||
returns("HashSet<T>")
|
returns("HashSet<T>")
|
||||||
body { "return toCollection(HashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
|
body { "return toCollection(HashSet<T>(mapCapacity(collectionSizeOrDefault(12))))" }
|
||||||
body(Sequences) { "return toCollection(HashSet<T>())" }
|
body(Sequences) { "return toCollection(HashSet<T>())" }
|
||||||
body(CharSequences) { "return toCollection(HashSet<T>(mapCapacity(length())))" }
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) { "return toCollection(HashSet<T>(mapCapacity(length())))" }
|
||||||
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(HashSet<T>(mapCapacity(size())))" }
|
body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(HashSet<T>(mapCapacity(size())))" }
|
||||||
}
|
}
|
||||||
|
|
||||||
templates add f("toSortedSet()") {
|
templates add f("toSortedSet()") {
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { "Returns a [SortedSet] of all elements." }
|
doc { "Returns a [SortedSet] of all elements." }
|
||||||
returns("SortedSet<T>")
|
returns("SortedSet<T>")
|
||||||
body { "return toCollection(TreeSet<T>())" }
|
body { "return toCollection(TreeSet<T>())" }
|
||||||
@@ -58,7 +62,8 @@ fun snapshots(): List<GenericFunction> {
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(Collections) { "return ArrayList(this)" }
|
body(Collections) { "return ArrayList(this)" }
|
||||||
body(CharSequences) { "return toCollection(ArrayList<T>(length()))" }
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) { "return toCollection(ArrayList<T>(length()))" }
|
||||||
body(ArraysOfObjects) { "return ArrayList(this.asCollection())" }
|
body(ArraysOfObjects) { "return ArrayList(this.asCollection())" }
|
||||||
body(ArraysOfPrimitives) {
|
body(ArraysOfPrimitives) {
|
||||||
"""
|
"""
|
||||||
@@ -84,7 +89,8 @@ fun snapshots(): List<GenericFunction> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
templates add f("toList()") {
|
templates add f("toList()") {
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
include(CharSequences, Strings)
|
||||||
doc { "Returns a [List] containing all elements." }
|
doc { "Returns a [List] containing all elements." }
|
||||||
returns("List<T>")
|
returns("List<T>")
|
||||||
body { "return this.toArrayList()" }
|
body { "return this.toArrayList()" }
|
||||||
@@ -99,7 +105,9 @@ fun snapshots(): List<GenericFunction> {
|
|||||||
|
|
||||||
templates add f("toMap(selector: (T) -> K)") {
|
templates add f("toMap(selector: (T) -> K)") {
|
||||||
inline(true)
|
inline(true)
|
||||||
include(CharSequences)
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(Strings) { "return toMapBy(selector)" }
|
||||||
|
include(CharSequences, Strings)
|
||||||
typeParam("K")
|
typeParam("K")
|
||||||
returns("Map<K, T>")
|
returns("Map<K, T>")
|
||||||
deprecate(Deprecation("Use toMapBy instead.", replaceWith = "toMapBy(selector)"))
|
deprecate(Deprecation("Use toMapBy instead.", replaceWith = "toMapBy(selector)"))
|
||||||
@@ -140,7 +148,8 @@ fun snapshots(): List<GenericFunction> {
|
|||||||
return result
|
return result
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
val capacity = (length()/.75f) + 1
|
val capacity = (length()/.75f) + 1
|
||||||
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
|
val result = LinkedHashMap<K, T>(Math.max(capacity.toInt(), 16))
|
||||||
@@ -198,7 +207,8 @@ fun snapshots(): List<GenericFunction> {
|
|||||||
return result
|
return result
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
body(CharSequences) {
|
deprecate(Strings) { forBinaryCompatibility }
|
||||||
|
body(CharSequences, Strings) {
|
||||||
"""
|
"""
|
||||||
val capacity = (length()/.75f) + 1
|
val capacity = (length()/.75f) + 1
|
||||||
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
val result = LinkedHashMap<K, V>(Math.max(capacity.toInt(), 16))
|
||||||
|
|||||||
Reference in New Issue
Block a user