From a05d0a3c499d2de50d706bc4923e9d87e119c9e3 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sun, 22 Nov 2015 09:20:39 +0300 Subject: [PATCH] Drop hidden declarations provided for binary compatibility in beta2 --- libraries/stdlib/src/generated/_Arrays.kt | 90 --- .../stdlib/src/generated/_Collections.kt | 10 - libraries/stdlib/src/generated/_Ranges.kt | 163 ----- libraries/stdlib/src/generated/_Sequences.kt | 10 - libraries/stdlib/src/generated/_Strings.kt | 671 ------------------ .../stdlib/src/kotlin/collections/MapsJVM.kt | 4 - .../src/kotlin/text/StringsDeprecated.kt | 577 --------------- .../src/kotlin/text/StringsDeprecatedJVM.kt | 182 ----- .../src/templates/Aggregates.kt | 57 +- .../src/templates/Comparables.kt | 21 - .../src/templates/Elements.kt | 69 +- .../src/templates/Filtering.kt | 6 +- .../src/templates/Generators.kt | 6 +- .../src/templates/Mapping.kt | 27 +- .../kotlin-stdlib-gen/src/templates/Ranges.kt | 92 +-- .../src/templates/Sequence.kt | 3 +- .../src/templates/Snapshots.kt | 28 +- .../src/templates/Strings.kt | 21 - 18 files changed, 70 insertions(+), 1967 deletions(-) delete mode 100644 libraries/stdlib/src/kotlin/text/StringsDeprecated.kt delete mode 100644 libraries/stdlib/src/kotlin/text/StringsDeprecatedJVM.kt diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index d3fa33036c1..224e18a0c50 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -10322,51 +10322,6 @@ public fun ShortArray.joinTo(buffer: A, separator: CharSequence return buffer } -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun Array.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun BooleanArray.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Boolean) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun ByteArray.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Byte) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun CharArray.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Char) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun DoubleArray.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Double) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun FloatArray.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Float) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun IntArray.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Int) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun LongArray.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Long) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun ShortArray.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Short) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - /** * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] @@ -10448,51 +10403,6 @@ public fun ShortArray.joinToString(separator: CharSequence = ", ", prefix: CharS return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() } -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun Array.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun BooleanArray.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Boolean) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun ByteArray.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Byte) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun CharArray.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Char) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun DoubleArray.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Double) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun FloatArray.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Float) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun IntArray.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Int) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun LongArray.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Long) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun ShortArray.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((Short) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - /** * Returns a sequence from the given collection. */ diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index b19c5f00a25..a69519760e9 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -1701,11 +1701,6 @@ public fun Iterable.joinTo(buffer: A, separator: CharSequ return buffer } -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun Iterable.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - /** * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] @@ -1715,11 +1710,6 @@ public fun Iterable.joinToString(separator: CharSequence = ", ", prefix: return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() } -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun Iterable.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - /** * Returns a sequence from the given collection. */ diff --git a/libraries/stdlib/src/generated/_Ranges.kt b/libraries/stdlib/src/generated/_Ranges.kt index 6c21ed33e06..8725ec32105 100644 --- a/libraries/stdlib/src/generated/_Ranges.kt +++ b/libraries/stdlib/src/generated/_Ranges.kt @@ -12,60 +12,6 @@ import java.util.* import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@[kotlin.jvm.JvmName("downTo") kotlin.jvm.JvmVersion] -public fun Byte.`-downTo`(to: Byte): ByteProgression { - return ByteProgression.fromClosedRange(this, to, -1) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@[kotlin.jvm.JvmName("downTo") kotlin.jvm.JvmVersion] -public fun Short.`-downTo`(to: Byte): ShortProgression { - return ShortProgression.fromClosedRange(this, to.toShort(), -1) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@[kotlin.jvm.JvmName("downTo") kotlin.jvm.JvmVersion] -public fun Byte.`-downTo`(to: Short): ShortProgression { - return ShortProgression.fromClosedRange(this.toShort(), to, -1) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@[kotlin.jvm.JvmName("downTo") kotlin.jvm.JvmVersion] -public fun Short.`-downTo`(to: Short): ShortProgression { - return ShortProgression.fromClosedRange(this, to, -1) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@[kotlin.jvm.JvmName("until") kotlin.jvm.JvmVersion] -public fun Byte.`-until`(to: Byte): ByteRange { - val to_ = (to - 1).toByte() - if (to_ > to) throw IllegalArgumentException("The to argument value '$to' was too small.") - return ByteRange(this, to_) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@[kotlin.jvm.JvmName("until") kotlin.jvm.JvmVersion] -public fun Short.`-until`(to: Byte): ShortRange { - return ShortRange(this, (to.toShort() - 1).toShort()) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@[kotlin.jvm.JvmName("until") kotlin.jvm.JvmVersion] -public fun Byte.`-until`(to: Short): ShortRange { - val to_ = (to - 1).toShort() - if (to_ > to) throw IllegalArgumentException("The to argument value '$to' was too small.") - return ShortRange(this.toShort(), to_) -} - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@[kotlin.jvm.JvmName("until") kotlin.jvm.JvmVersion] -public fun Short.`-until`(to: Short): ShortRange { - val to_ = (to - 1).toShort() - if (to_ > to) throw IllegalArgumentException("The to argument value '$to' was too small.") - return ShortRange(this, to_) -} - /** * Checks if the specified [item] belongs to this range. */ @@ -733,30 +679,6 @@ public fun LongProgression.reversed(): LongProgression { return LongProgression.fromClosedRange(last, first, -increment) } -/** - * Returns a progression that goes over this range in reverse direction. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun CharRange.reversed(): CharProgression { - return CharProgression.fromClosedRange(last, first, -1) -} - -/** - * Returns a progression that goes over this range in reverse direction. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun IntRange.reversed(): IntProgression { - return IntProgression.fromClosedRange(last, first, -1) -} - -/** - * Returns a progression that goes over this range in reverse direction. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun LongRange.reversed(): LongProgression { - return LongProgression.fromClosedRange(last, first, -1L) -} - /** * Returns a progression that goes over the same range in the opposite direction with the same step. */ @@ -775,24 +697,6 @@ public fun ShortProgression.reversed(): ShortProgression { return ShortProgression.fromClosedRange(last, first, -increment) } -/** - * Returns a progression that goes over this range in reverse direction. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("DEPRECATION_ERROR") -public fun ByteRange.reversed(): ByteProgression { - return ByteProgression.fromClosedRange(last, first, -1) -} - -/** - * Returns a progression that goes over this range in reverse direction. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("DEPRECATION_ERROR") -public fun ShortRange.reversed(): ShortProgression { - return ShortProgression.fromClosedRange(last, first, -1) -} - /** * Returns a progression that goes over the same range with the given step. */ @@ -817,33 +721,6 @@ public infix fun LongProgression.step(step: Long): LongProgression { return LongProgression.fromClosedRange(first, last, if (increment > 0) step else -step) } -/** - * Returns a progression that goes over this range with given step. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public infix fun CharRange.step(step: Int): CharProgression { - checkStepIsPositive(step > 0, step) - return CharProgression.fromClosedRange(first, last, step) -} - -/** - * Returns a progression that goes over this range with given step. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public infix fun IntRange.step(step: Int): IntProgression { - checkStepIsPositive(step > 0, step) - return IntProgression.fromClosedRange(first, last, step) -} - -/** - * Returns a progression that goes over this range with given step. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public infix fun LongRange.step(step: Long): LongProgression { - checkStepIsPositive(step > 0, step) - return LongProgression.fromClosedRange(first, last, step) -} - /** * Returns a progression that goes over the same range with the given step. */ @@ -864,26 +741,6 @@ public infix fun ShortProgression.step(step: Int): ShortProgression { return ShortProgression.fromClosedRange(first, last, if (increment > 0) step else -step) } -/** - * Returns a progression that goes over this range with given step. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("DEPRECATION_ERROR") -public infix fun ByteRange.step(step: Int): ByteProgression { - checkStepIsPositive(step > 0, step) - return ByteProgression.fromClosedRange(first, last, step) -} - -/** - * Returns a progression that goes over this range with given step. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@Suppress("DEPRECATION_ERROR") -public infix fun ShortRange.step(step: Int): ShortProgression { - checkStepIsPositive(step > 0, step) - return ShortProgression.fromClosedRange(first, last, step) -} - /** * Returns a range from this value up to but excluding the specified [to] value. */ @@ -1335,23 +1192,3 @@ public fun Short.coerceIn(range: Range): Short { return if (this < range.start) range.start else if (this > range.end) range.end else this } -/** - * Ensures that this value lies in the specified [range]. - * @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun Double.coerceIn(range: Range): Double { - if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.") - return if (this < range.start) range.start else if (this > range.end) range.end else this -} - -/** - * Ensures that this value lies in the specified [range]. - * @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun Float.coerceIn(range: Range): Float { - if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.") - return if (this < range.start) range.start else if (this > range.end) range.end else this -} - diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index ecbb65129a9..7b093cd8129 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -1053,11 +1053,6 @@ public fun Sequence.joinTo(buffer: A, separator: CharSequ return buffer } -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun Sequence.joinTo(buffer: A, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): A { - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) -} - /** * Creates a string from all the elements separated using [separator] and using the given [prefix] and [postfix] if supplied. * If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit] @@ -1067,11 +1062,6 @@ public fun Sequence.joinToString(separator: CharSequence = ", ", prefix: return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() } -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun Sequence.joinToString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "...", transform: ((T) -> String)? = null): String { - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() -} - /** * Returns a sequence from the given collection. */ diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index f1fdeb80ceb..1f941b8a837 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -19,14 +19,6 @@ public fun CharSequence.elementAt(index: Int): Char { return get(index) } -/** - * Returns a character at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.elementAt(index: Int): Char { - return get(index) -} - /** * Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this char sequence. */ @@ -34,14 +26,6 @@ public inline fun CharSequence.elementAtOrElse(index: Int, defaultValue: (Int) - return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } -/** - * Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.elementAtOrElse(index: Int, defaultValue: (Int) -> Char): Char { - return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) -} - /** * Returns a character at the given [index] or `null` if the [index] is out of bounds of this char sequence. */ @@ -49,14 +33,6 @@ public fun CharSequence.elementAtOrNull(index: Int): Char? { return if (index >= 0 && index <= lastIndex) get(index) else null } -/** - * Returns a character at the given [index] or `null` if the [index] is out of bounds of this string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.elementAtOrNull(index: Int): Char? { - return if (index >= 0 && index <= lastIndex) get(index) else null -} - /** * Returns the first character matching the given [predicate], or `null` if no such character was found. */ @@ -64,14 +40,6 @@ public inline fun CharSequence.find(predicate: (Char) -> Boolean): Char? { return firstOrNull(predicate) } -/** - * Returns the first character matching the given [predicate], or `null` if no such character was found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.find(predicate: (Char) -> Boolean): Char? { - return firstOrNull(predicate) -} - /** * Returns the last character matching the given [predicate], or `null` if no such character was found. */ @@ -79,14 +47,6 @@ public inline fun CharSequence.findLast(predicate: (Char) -> Boolean): Char? { return lastOrNull(predicate) } -/** - * Returns the last character matching the given [predicate], or `null` if no such character was found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.findLast(predicate: (Char) -> Boolean): Char? { - return lastOrNull(predicate) -} - /** * Returns first character. * @throws [NoSuchElementException] if the char sequence is empty. @@ -97,17 +57,6 @@ public fun CharSequence.first(): Char { return this[0] } -/** - * Returns first character. - * @throws [NoSuchElementException] if the string is empty. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.first(): Char { - if (isEmpty()) - throw NoSuchElementException("Collection is empty.") - return this[0] -} - /** * Returns the first character matching the given [predicate]. * @throws [NoSuchElementException] if no such character is found. @@ -117,16 +66,6 @@ public inline fun CharSequence.first(predicate: (Char) -> Boolean): Char { throw NoSuchElementException("No element matching predicate was found.") } -/** - * Returns the first character matching the given [predicate]. - * @throws [NoSuchElementException] if no such character is found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.first(predicate: (Char) -> Boolean): Char { - for (element in this) if (predicate(element)) return element - throw NoSuchElementException("No element matching predicate was found.") -} - /** * Returns the first character, or `null` if the char sequence is empty. */ @@ -134,14 +73,6 @@ public fun CharSequence.firstOrNull(): Char? { return if (isEmpty()) null else this[0] } -/** - * Returns the first character, or `null` if the string is empty. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.firstOrNull(): Char? { - return if (isEmpty()) null else this[0] -} - /** * Returns the first character matching the given [predicate], or `null` if character was not found. */ @@ -150,15 +81,6 @@ public inline fun CharSequence.firstOrNull(predicate: (Char) -> Boolean): Char? return null } -/** - * Returns the first character matching the given [predicate], or `null` if character was not found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.firstOrNull(predicate: (Char) -> Boolean): Char? { - for (element in this) if (predicate(element)) return element - return null -} - /** * Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this char sequence. */ @@ -166,14 +88,6 @@ public inline fun CharSequence.getOrElse(index: Int, defaultValue: (Int) -> Char return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } -/** - * Returns a character at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.getOrElse(index: Int, defaultValue: (Int) -> Char): Char { - return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) -} - /** * Returns a character at the given [index] or `null` if the [index] is out of bounds of this char sequence. */ @@ -181,14 +95,6 @@ public fun CharSequence.getOrNull(index: Int): Char? { return if (index >= 0 && index <= lastIndex) get(index) else null } -/** - * Returns a character at the given [index] or `null` if the [index] is out of bounds of this string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.getOrNull(index: Int): Char? { - return if (index >= 0 && index <= lastIndex) get(index) else null -} - /** * Returns index of the first character matching the given [predicate], or -1 if the char sequence does not contain such character. */ @@ -201,19 +107,6 @@ public inline fun CharSequence.indexOfFirst(predicate: (Char) -> Boolean): Int { return -1 } -/** - * Returns index of the first character matching the given [predicate], or -1 if the string does not contain such character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.indexOfFirst(predicate: (Char) -> Boolean): Int { - for (index in indices) { - if (predicate(this[index])) { - return index - } - } - return -1 -} - /** * Returns index of the last character matching the given [predicate], or -1 if the char sequence does not contain such character. */ @@ -226,19 +119,6 @@ public inline fun CharSequence.indexOfLast(predicate: (Char) -> Boolean): Int { return -1 } -/** - * Returns index of the last character matching the given [predicate], or -1 if the string does not contain such character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.indexOfLast(predicate: (Char) -> Boolean): Int { - for (index in indices.reversed()) { - if (predicate(this[index])) { - return index - } - } - return -1 -} - /** * Returns the last character. * @throws [NoSuchElementException] if the char sequence is empty. @@ -249,17 +129,6 @@ public fun CharSequence.last(): Char { return this[lastIndex] } -/** - * Returns the last character. - * @throws [NoSuchElementException] if the string is empty. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.last(): Char { - if (isEmpty()) - throw NoSuchElementException("Collection is empty.") - return this[lastIndex] -} - /** * Returns the last character matching the given [predicate]. * @throws [NoSuchElementException] if no such character is found. @@ -272,19 +141,6 @@ public inline fun CharSequence.last(predicate: (Char) -> Boolean): Char { throw NoSuchElementException("Collection doesn't contain any element matching the predicate.") } -/** - * Returns the last character matching the given [predicate]. - * @throws [NoSuchElementException] if no such character is found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.last(predicate: (Char) -> Boolean): Char { - for (index in this.indices.reversed()) { - val element = this[index] - if (predicate(element)) return element - } - throw NoSuchElementException("Collection doesn't contain any element matching the predicate.") -} - /** * Returns the last character, or `null` if the char sequence is empty. */ @@ -292,14 +148,6 @@ public fun CharSequence.lastOrNull(): Char? { return if (isEmpty()) null else this[length - 1] } -/** - * Returns the last character, or `null` if the string is empty. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.lastOrNull(): Char? { - return if (isEmpty()) null else this[length - 1] -} - /** * Returns the last character matching the given [predicate], or `null` if no such character was found. */ @@ -311,18 +159,6 @@ public inline fun CharSequence.lastOrNull(predicate: (Char) -> Boolean): Char? { return null } -/** - * Returns the last character matching the given [predicate], or `null` if no such character was found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.lastOrNull(predicate: (Char) -> Boolean): Char? { - for (index in this.indices.reversed()) { - val element = this[index] - if (predicate(element)) return element - } - return null -} - /** * Returns the single character, or throws an exception if the char sequence is empty or has more than one character. */ @@ -334,18 +170,6 @@ public fun CharSequence.single(): Char { } } -/** - * Returns the single character, or throws an exception if the string is empty or has more than one character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.single(): Char { - return when (length) { - 0 -> throw NoSuchElementException("Collection is empty.") - 1 -> this[0] - else -> throw IllegalArgumentException("Collection has more than one element.") - } -} - /** * Returns the single character matching the given [predicate], or throws exception if there is no or more than one matching character. */ @@ -363,24 +187,6 @@ public inline fun CharSequence.single(predicate: (Char) -> Boolean): Char { return single as Char } -/** - * Returns the single character matching the given [predicate], or throws exception if there is no or more than one matching character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.single(predicate: (Char) -> Boolean): Char { - var single: Char? = null - var found = false - for (element in this) { - if (predicate(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.") - return single as Char -} - /** * Returns single character, or `null` if the char sequence is empty or has more than one character. */ @@ -388,14 +194,6 @@ public fun CharSequence.singleOrNull(): Char? { return if (length == 1) this[0] else null } -/** - * Returns single character, or `null` if the string is empty or has more than one character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.singleOrNull(): Char? { - return if (length == 1) this[0] else null -} - /** * Returns the single character matching the given [predicate], or `null` if character was not found or more than one character was found. */ @@ -413,24 +211,6 @@ public inline fun CharSequence.singleOrNull(predicate: (Char) -> Boolean): Char? return single } -/** - * Returns the single character matching the given [predicate], or `null` if character was not found or more than one character was found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.singleOrNull(predicate: (Char) -> Boolean): Char? { - var single: Char? = null - var found = false - for (element in this) { - if (predicate(element)) { - if (found) return null - single = element - found = true - } - } - if (!found) return null - return single -} - /** * Returns a subsequence of this char sequence with the first [n] characters removed. */ @@ -563,15 +343,6 @@ public inline fun CharSequence.filterNotTo(destination: C, pred return destination } -/** - * Appends all elements not matching the given [predicate] to the given [destination]. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.filterNotTo(destination: C, predicate: (Char) -> Boolean): C { - for (element in this) if (!predicate(element)) destination.append(element) - return destination -} - /** * Appends all characters matching the given [predicate] to the given [destination]. */ @@ -583,18 +354,6 @@ public inline fun CharSequence.filterTo(destination: C, predica return destination } -/** - * Appends all characters matching the given [predicate] to the given [destination]. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.filterTo(destination: C, predicate: (Char) -> Boolean): C { - for (index in 0..length - 1) { - val element = get(index) - if (predicate(element)) destination.append(element) - } - return destination -} - /** * Returns a char sequence containing characters of the original char sequence at the specified range of [indices]. */ @@ -738,14 +497,6 @@ public fun CharSequence.toArrayList(): ArrayList { return toCollection(ArrayList(length)) } -/** - * Returns an [ArrayList] of all characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.toArrayList(): ArrayList { - return toCollection(ArrayList(length)) -} - /** * Appends all characters to the given [destination] collection. */ @@ -756,17 +507,6 @@ public fun > CharSequence.toCollection(destinatio return destination } -/** - * Appends all characters to the given [destination] collection. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun > String.toCollection(destination: C): C { - for (item in this) { - destination.add(item) - } - return destination -} - /** * Returns a [HashSet] of all characters. */ @@ -774,14 +514,6 @@ public fun CharSequence.toHashSet(): HashSet { return toCollection(HashSet(mapCapacity(length))) } -/** - * Returns a [HashSet] of all characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.toHashSet(): HashSet { - return toCollection(HashSet(mapCapacity(length))) -} - /** * Returns a [LinkedList] containing all elements. */ @@ -797,24 +529,11 @@ public fun CharSequence.toList(): List { return this.toArrayList() } -/** - * Returns a [List] containing all characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.toList(): List { - return this.toArrayList() -} - @Deprecated("Use toMapBy instead.", ReplaceWith("toMapBy(selector)")) public inline fun CharSequence.toMap(selector: (Char) -> K): Map { return toMapBy(selector) } -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.toMap(selector: (Char) -> K): Map { - return toMapBy(selector) -} - /** * Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to characters of the given char sequence. * If any two characters would have the same key returned by [selector] the last one gets added to the map. @@ -828,20 +547,6 @@ public inline fun CharSequence.toMap(selector: (Char) -> K, transform: (C return result } -/** - * Returns Map containing the values provided by [transform] and indexed by [selector] functions applied to characters of the given string. - * If any two characters would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.toMap(selector: (Char) -> K, transform: (Char) -> V): Map { - val capacity = (length/.75f) + 1 - val result = LinkedHashMap(Math.max(capacity.toInt(), 16)) - for (element in this) { - result.put(selector(element), transform(element)) - } - return result -} - /** * Returns Map containing the characters from the given char sequence indexed by the key * returned from [selector] function applied to each character. @@ -856,21 +561,6 @@ public inline fun CharSequence.toMapBy(selector: (Char) -> K): Map return result } -/** - * Returns Map containing the characters from the given string indexed by the key - * returned from [selector] function applied to each character. - * If any two characters would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.toMapBy(selector: (Char) -> K): Map { - val capacity = (length/.75f) + 1 - val result = LinkedHashMap(Math.max(capacity.toInt(), 16)) - for (element in this) { - result.put(selector(element), element) - } - return result -} - /** * Returns a [Set] of all characters. */ @@ -878,14 +568,6 @@ public fun CharSequence.toSet(): Set { return toCollection(LinkedHashSet(mapCapacity(length))) } -/** - * Returns a [Set] of all characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.toSet(): Set { - return toCollection(LinkedHashSet(mapCapacity(length))) -} - /** * Returns a [SortedSet] of all characters. */ @@ -893,14 +575,6 @@ public fun CharSequence.toSortedSet(): SortedSet { return toCollection(TreeSet()) } -/** - * Returns a [SortedSet] of all characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.toSortedSet(): SortedSet { - return toCollection(TreeSet()) -} - /** * Returns a single list of all elements yielded from results of [transform] function being invoked on each character of original char sequence. */ @@ -908,14 +582,6 @@ public inline fun CharSequence.flatMap(transform: (Char) -> Iterable): Li return flatMapTo(ArrayList(), transform) } -/** - * Returns a single list of all elements yielded from results of [transform] function being invoked on each character of original string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.flatMap(transform: (Char) -> Iterable): List { - return flatMapTo(ArrayList(), transform) -} - /** * Appends all elements yielded from results of [transform] function being invoked on each character of original char sequence, to the given [destination]. */ @@ -927,18 +593,6 @@ public inline fun > CharSequence.flatMapTo(destin return destination } -/** - * Appends all elements yielded from results of [transform] function being invoked on each character of original string, to the given [destination]. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun > String.flatMapTo(destination: C, transform: (Char) -> Iterable): C { - for (element in this) { - val list = transform(element) - destination.addAll(list) - } - return destination -} - /** * Returns a map of the characters in original char sequence grouped by the key returned by the given [selector] function. */ @@ -946,14 +600,6 @@ public inline fun CharSequence.groupBy(selector: (Char) -> K): Map>(), selector) } -/** - * Returns a map of the characters in original string grouped by the key returned by the given [selector] function. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.groupBy(selector: (Char) -> K): Map> { - return groupByTo(LinkedHashMap>(), selector) -} - /** * Appends characters from original char sequence grouped by the key returned by the given [selector] function to the given [map]. */ @@ -966,19 +612,6 @@ public inline fun CharSequence.groupByTo(map: MutableMap String.groupByTo(map: MutableMap>, selector: (Char) -> K): Map> { - for (element in this) { - val key = selector(element) - val list = map.getOrPut(key) { ArrayList() } - list.add(element) - } - return map -} - /** * Returns a list containing the results of applying the given [transform] function * to each character in the original char sequence. @@ -987,15 +620,6 @@ public inline fun CharSequence.map(transform: (Char) -> R): List { return mapTo(ArrayList(length), transform) } -/** - * Returns a list containing the results of applying the given [transform] function - * to each character in the original string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.map(transform: (Char) -> R): List { - return mapTo(ArrayList(length), transform) -} - /** * Returns a list containing the results of applying the given [transform] function * to each character and its index in the original char sequence. @@ -1004,15 +628,6 @@ public inline fun CharSequence.mapIndexed(transform: (Int, Char) -> R): List return mapIndexedTo(ArrayList(length), transform) } -/** - * Returns a list containing the results of applying the given [transform] function - * to each character and its index in the original string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.mapIndexed(transform: (Int, Char) -> R): List { - return mapIndexedTo(ArrayList(length), transform) -} - /** * Returns a list containing only the non-null results of applying the given [transform] function * to each character and its index in the original char sequence. @@ -1041,18 +656,6 @@ public inline fun > CharSequence.mapIndexedTo(des return destination } -/** - * Applies the given [transform] function to each character and its index in the original string - * and appends the results to the given [destination]. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun > String.mapIndexedTo(destination: C, transform: (Int, Char) -> R): C { - var index = 0 - for (item in this) - destination.add(transform(index++, item)) - return destination -} - /** * Returns a list containing only the non-null results of applying the given [transform] function * to each character in the original char sequence. @@ -1080,17 +683,6 @@ public inline fun > CharSequence.mapTo(destinatio return destination } -/** - * Applies the given [transform] function to each character of the original string - * and appends the results to the given [destination]. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun > String.mapTo(destination: C, transform: (Char) -> R): C { - for (item in this) - destination.add(transform(item)) - return destination -} - /** * Returns a lazy [Iterable] of [IndexedValue] for each character of the original char sequence. */ @@ -1098,14 +690,6 @@ public fun CharSequence.withIndex(): Iterable> { return IndexingIterable { iterator() } } -/** - * Returns a lazy [Iterable] of [IndexedValue] for each character of the original string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.withIndex(): Iterable> { - return IndexingIterable { iterator() } -} - /** * Returns `true` if all characters match the given [predicate]. */ @@ -1114,15 +698,6 @@ public inline fun CharSequence.all(predicate: (Char) -> Boolean): Boolean { return true } -/** - * Returns `true` if all characters match the given [predicate]. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.all(predicate: (Char) -> Boolean): Boolean { - for (element in this) if (!predicate(element)) return false - return true -} - /** * Returns `true` if char sequence has at least one character. */ @@ -1131,15 +706,6 @@ public fun CharSequence.any(): Boolean { return false } -/** - * Returns `true` if string has at least one character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.any(): Boolean { - for (element in this) return true - return false -} - /** * Returns `true` if at least one character matches the given [predicate]. */ @@ -1148,15 +714,6 @@ public inline fun CharSequence.any(predicate: (Char) -> Boolean): Boolean { return false } -/** - * Returns `true` if at least one character matches the given [predicate]. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.any(predicate: (Char) -> Boolean): Boolean { - for (element in this) if (predicate(element)) return true - return false -} - /** * Returns the length of this char sequence. */ @@ -1164,14 +721,6 @@ public fun CharSequence.count(): Int { return length } -/** - * Returns the number of characters in this string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.count(): Int { - return length -} - /** * Returns the number of characters matching the given [predicate]. */ @@ -1181,16 +730,6 @@ public inline fun CharSequence.count(predicate: (Char) -> Boolean): Int { return count } -/** - * Returns the number of characters matching the given [predicate]. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.count(predicate: (Char) -> Boolean): Int { - var count = 0 - for (element in this) if (predicate(element)) count++ - return count -} - /** * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each character. */ @@ -1200,16 +739,6 @@ public inline fun CharSequence.fold(initial: R, operation: (R, Char) -> R): return accumulator } -/** - * Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.fold(initial: R, operation: (R, Char) -> R): R { - var accumulator = initial - for (element in this) accumulator = operation(accumulator, element) - return accumulator -} - /** * Accumulates value starting with [initial] value and applying [operation] from right to left to each character and current accumulator value. */ @@ -1222,19 +751,6 @@ public inline fun CharSequence.foldRight(initial: R, operation: (Char, R) -> return accumulator } -/** - * Accumulates value starting with [initial] value and applying [operation] from right to left to each character and current accumulator value. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.foldRight(initial: R, operation: (Char, R) -> R): R { - var index = lastIndex - var accumulator = initial - while (index >= 0) { - accumulator = operation(get(index--), accumulator) - } - return accumulator -} - /** * Performs the given [action] on each character. */ @@ -1242,14 +758,6 @@ public inline fun CharSequence.forEach(action: (Char) -> Unit): Unit { for (element in this) action(element) } -/** - * Performs the given [action] on each character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.forEach(action: (Char) -> Unit): Unit { - for (element in this) action(element) -} - /** * Performs the given [action] on each character, providing sequential index with the character. */ @@ -1258,15 +766,6 @@ public inline fun CharSequence.forEachIndexed(action: (Int, Char) -> Unit): Unit for (item in this) action(index++, item) } -/** - * Performs the given [action] on each character, providing sequential index with the character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.forEachIndexed(action: (Int, Char) -> Unit): Unit { - var index = 0 - for (item in this) action(index++, item) -} - /** * Returns the largest character or `null` if there are no characters. */ @@ -1280,20 +779,6 @@ public fun CharSequence.max(): Char? { return max } -/** - * Returns the largest character or `null` if there are no characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.max(): Char? { - if (isEmpty()) return null - var max = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (max < e) max = e - } - return max -} - /** * Returns the first character yielding the largest value of the given function or `null` if there are no characters. */ @@ -1312,25 +797,6 @@ public inline fun > CharSequence.maxBy(selector: (Char) -> R): return maxElem } -/** - * Returns the first character yielding the largest value of the given function or `null` if there are no characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun > String.maxBy(selector: (Char) -> R): Char? { - if (isEmpty()) return null - var maxElem = this[0] - var maxValue = selector(maxElem) - for (i in 1..lastIndex) { - val e = this[i] - val v = selector(e) - if (maxValue < v) { - maxElem = e - maxValue = v - } - } - return maxElem -} - /** * Returns the smallest character or `null` if there are no characters. */ @@ -1344,20 +810,6 @@ public fun CharSequence.min(): Char? { return min } -/** - * Returns the smallest character or `null` if there are no characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.min(): Char? { - if (isEmpty()) return null - var min = this[0] - for (i in 1..lastIndex) { - val e = this[i] - if (min > e) min = e - } - return min -} - /** * Returns the first character yielding the smallest value of the given function or `null` if there are no characters. */ @@ -1376,25 +828,6 @@ public inline fun > CharSequence.minBy(selector: (Char) -> R): return minElem } -/** - * Returns the first character yielding the smallest value of the given function or `null` if there are no characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun > String.minBy(selector: (Char) -> R): Char? { - if (isEmpty()) return null - var minElem = this[0] - var minValue = selector(minElem) - for (i in 1..lastIndex) { - val e = this[i] - val v = selector(e) - if (minValue > v) { - minElem = e - minValue = v - } - } - return minElem -} - /** * Returns `true` if the char sequence has no characters. */ @@ -1403,15 +836,6 @@ public fun CharSequence.none(): Boolean { return true } -/** - * Returns `true` if the string has no characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.none(): Boolean { - for (element in this) return false - return true -} - /** * Returns `true` if no characters match the given [predicate]. */ @@ -1420,15 +844,6 @@ public inline fun CharSequence.none(predicate: (Char) -> Boolean): Boolean { return true } -/** - * Returns `true` if no characters match the given [predicate]. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.none(predicate: (Char) -> Boolean): Boolean { - for (element in this) if (predicate(element)) return false - return true -} - /** * Accumulates value starting with the first character and applying [operation] from left to right to current accumulator value and each character. */ @@ -1442,20 +857,6 @@ public inline fun CharSequence.reduce(operation: (Char, Char) -> Char): Char { return accumulator } -/** - * Accumulates value starting with the first character and applying [operation] from left to right to current accumulator value and each character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.reduce(operation: (Char, Char) -> Char): Char { - val iterator = this.iterator() - if (!iterator.hasNext()) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = iterator.next() - while (iterator.hasNext()) { - accumulator = operation(accumulator, iterator.next()) - } - return accumulator -} - /** * Accumulates value starting with last character and applying [operation] from right to left to each character and current accumulator value. */ @@ -1469,20 +870,6 @@ public inline fun CharSequence.reduceRight(operation: (Char, Char) -> Char): Cha return accumulator } -/** - * Accumulates value starting with last character and applying [operation] from right to left to each character and current accumulator value. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.reduceRight(operation: (Char, Char) -> Char): Char { - var index = lastIndex - if (index < 0) throw UnsupportedOperationException("Empty iterable can't be reduced.") - var accumulator = get(index--) - while (index >= 0) { - accumulator = operation(get(index--), accumulator) - } - return accumulator -} - /** * Returns the sum of all values produced by [selector] function applied to each character in the char sequence. */ @@ -1494,18 +881,6 @@ public inline fun CharSequence.sumBy(selector: (Char) -> Int): Int { return sum } -/** - * Returns the sum of all values produced by [selector] function applied to each character in the string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.sumBy(selector: (Char) -> Int): Int { - var sum: Int = 0 - for (element in this) { - sum += selector(element) - } - return sum -} - /** * Returns the sum of all values produced by [selector] function applied to each character in the char sequence. */ @@ -1517,18 +892,6 @@ public inline fun CharSequence.sumByDouble(selector: (Char) -> Double): Double { return sum } -/** - * Returns the sum of all values produced by [selector] function applied to each character in the string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.sumByDouble(selector: (Char) -> Double): Double { - var sum: Double = 0.0 - for (element in this) { - sum += selector(element) - } - return sum -} - /** * Splits the original char sequence into pair of char sequences, * where *first* char sequence contains characters for which [predicate] yielded `true`, @@ -1572,14 +935,6 @@ public infix fun CharSequence.zip(other: String): List> { return zip(other) { c1, c2 -> c1 to c2 } } -/** - * Returns a list of pairs built from characters of both char sequences with same indexes. List has length of shortest char sequence. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public infix fun String.zip(other: String): List> { - return zip(other) { c1, c2 -> c1 to c2 } -} - /** * Returns a list of values built from characters of both char sequences with same indexes using provided [transform]. List has length of shortest char sequence. */ @@ -1592,19 +947,6 @@ public inline fun CharSequence.zip(other: String, transform: (Char, Char) -> return list } -/** - * Returns a list of values built from characters of both char sequences with same indexes using provided [transform]. List has length of shortest char sequence. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.zip(other: String, transform: (Char, Char) -> V): List { - val length = Math.min(this.length, other.length) - val list = ArrayList(length) - for (i in 0..length-1) { - list.add(transform(this[i], other[i])) - } - return list -} - /** * Returns a sequence from the given collection. */ @@ -1617,16 +959,3 @@ public fun CharSequence.asSequence(): Sequence { } } -/** - * Returns a sequence from the given collection. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.asSequence(): Sequence { - if (this is String && isEmpty()) return emptySequence() - return object : Sequence { - override fun iterator(): Iterator { - return this@asSequence.iterator() - } - } -} - diff --git a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt b/libraries/stdlib/src/kotlin/collections/MapsJVM.kt index e2b292c5ebd..1c04aa8d23f 100644 --- a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt +++ b/libraries/stdlib/src/kotlin/collections/MapsJVM.kt @@ -18,10 +18,6 @@ public operator fun MutableMap.set(key: K, value: V): Unit { put(key, value) } -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -@JvmName("set") -public fun MutableMap.set(key: K, value: V): V? = put(key, value) - /** * getOrPut is not supported on [ConcurrentMap] since it cannot be implemented correctly in terms of concurrency. * Use [concurrentGetOrPut] instead, or cast this to a [MutableMap] if you want to sacrifice the concurrent-safety. diff --git a/libraries/stdlib/src/kotlin/text/StringsDeprecated.kt b/libraries/stdlib/src/kotlin/text/StringsDeprecated.kt deleted file mode 100644 index 95be0ee6097..00000000000 --- a/libraries/stdlib/src/kotlin/text/StringsDeprecated.kt +++ /dev/null @@ -1,577 +0,0 @@ -@file:kotlin.jvm.JvmMultifileClass -@file:kotlin.jvm.JvmName("StringsKt") - - -package kotlin - -import java.util.NoSuchElementException -import kotlin.text.MatchResult -import kotlin.text.Regex - -/** Returns `true` if the string is not `null` and not empty */ -@Deprecated("Use !isNullOrEmpty() or isNullOrEmpty().not() for nullable strings.", ReplaceWith("this != null && this.isNotEmpty()"), DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("isNotEmptyNullable") -public fun CharSequence?.isNotEmpty(): Boolean = this != null && this.length() > 0 - - -/** Returns `true` if the string is not `null` and not empty */ -@Deprecated("Use !isNullOrEmpty() or isNullOrEmpty().not() for nullable strings.", ReplaceWith("this != null && this.isNotEmpty()"), DeprecationLevel.HIDDEN) -@kotlin.jvm.JvmName("isNotEmptyNullable") -public fun String?.isNotEmpty(): Boolean = this != null && this.length() > 0 - -/** - * Returns `true` if this nullable string is either `null` or empty. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String?.isNullOrEmpty(): Boolean = this == null || this.length() == 0 - -/** - * Returns `true` if this string is empty (contains no characters). - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.isEmpty(): Boolean = length() == 0 - -/** - * Returns `true` if this string is not empty. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.isNotEmpty(): Boolean = length() > 0 - -// implemented differently in JVM and JS -//public fun String.isBlank(): Boolean = length() == 0 || all { it.isWhitespace() } - - -/** - * Returns `true` if this string is not empty and contains some characters except of whitespace characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.isNotBlank(): Boolean = !isBlank() - -/** - * Returns `true` if this nullable string is either `null` or empty or consists solely of whitespace characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String?.isNullOrBlank(): Boolean = this == null || this.isBlank() - -/** - * Returns the range of valid character indices for this string. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public val String.indices: IntRange - get() = 0..length() - 1 - -/** - * Returns the index of the last character in the String or -1 if the String is empty. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public val String.lastIndex: Int - get() = this.length() - 1 - -/* -/** - * Returns a substring before the first occurrence of [delimiter]. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.substringBefore(delimiter: Char, missingDelimiterValue: String = this): String { - val index = indexOf(delimiter) - return if (index == -1) missingDelimiterValue else substring(0, index) -} - -/** - * Returns a substring before the first occurrence of [delimiter]. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.substringBefore(delimiter: String, missingDelimiterValue: String = this): String { - val index = indexOf(delimiter) - return if (index == -1) missingDelimiterValue else substring(0, index) -} - -/** - * Returns a substring after the first occurrence of [delimiter]. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.substringAfter(delimiter: Char, missingDelimiterValue: String = this): String { - val index = indexOf(delimiter) - return if (index == -1) missingDelimiterValue else substring(index + 1, length()) -} - -/** - * Returns a substring after the first occurrence of [delimiter]. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.substringAfter(delimiter: String, missingDelimiterValue: String = this): String { - val index = indexOf(delimiter) - return if (index == -1) missingDelimiterValue else substring(index + delimiter.length(), length()) -} - -/** - * Returns a substring before the last occurrence of [delimiter]. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.substringBeforeLast(delimiter: Char, missingDelimiterValue: String = this): String { - val index = lastIndexOf(delimiter) - return if (index == -1) missingDelimiterValue else substring(0, index) -} - -/** - * Returns a substring before the last occurrence of [delimiter]. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.substringBeforeLast(delimiter: String, missingDelimiterValue: String = this): String { - val index = lastIndexOf(delimiter) - return if (index == -1) missingDelimiterValue else substring(0, index) -} - -/** - * Returns a substring after the last occurrence of [delimiter]. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.substringAfterLast(delimiter: Char, missingDelimiterValue: String = this): String { - val index = lastIndexOf(delimiter) - return if (index == -1) missingDelimiterValue else substring(index + 1, length()) -} - -/** - * Returns a substring after the last occurrence of [delimiter]. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.substringAfterLast(delimiter: String, missingDelimiterValue: String = this): String { - val index = lastIndexOf(delimiter) - return if (index == -1) missingDelimiterValue else substring(index + delimiter.length(), length()) -} - - -/** - * Replace part of string before the first occurrence of given delimiter with the [replacement] string. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.replaceBefore(delimiter: Char, replacement: String, missingDelimiterValue: String = this): String { - val index = indexOf(delimiter) - return if (index == -1) missingDelimiterValue else replaceRange(0, index, replacement) -} - -/** - * Replace part of string before the first occurrence of given delimiter with the [replacement] string. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.replaceBefore(delimiter: String, replacement: String, missingDelimiterValue: String = this): String { - val index = indexOf(delimiter) - return if (index == -1) missingDelimiterValue else replaceRange(0, index, replacement) -} - -/** - * Replace part of string after the first occurrence of given delimiter with the [replacement] string. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.replaceAfter(delimiter: Char, replacement: String, missingDelimiterValue: String = this): String { - val index = indexOf(delimiter) - return if (index == -1) missingDelimiterValue else replaceRange(index + 1, length(), replacement) -} - -/** - * Replace part of string after the first occurrence of given delimiter with the [replacement] string. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.replaceAfter(delimiter: String, replacement: String, missingDelimiterValue: String = this): String { - val index = indexOf(delimiter) - return if (index == -1) missingDelimiterValue else replaceRange(index + delimiter.length(), length(), replacement) -} - -/** - * Replace part of string after the last occurrence of given delimiter with the [replacement] string. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.replaceAfterLast(delimiter: String, replacement: String, missingDelimiterValue: String = this): String { - val index = lastIndexOf(delimiter) - return if (index == -1) missingDelimiterValue else replaceRange(index + delimiter.length(), length(), replacement) -} - -/** - * Replace part of string after the last occurrence of given delimiter with the [replacement] string. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.replaceAfterLast(delimiter: Char, replacement: String, missingDelimiterValue: String = this): String { - val index = lastIndexOf(delimiter) - return if (index == -1) missingDelimiterValue else replaceRange(index + 1, length(), replacement) -} - -/** - * Replace part of string before the last occurrence of given delimiter with the [replacement] string. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.replaceBeforeLast(delimiter: Char, replacement: String, missingDelimiterValue: String = this): String { - val index = lastIndexOf(delimiter) - return if (index == -1) missingDelimiterValue else replaceRange(0, index, replacement) -} - -/** - * Replace part of string before the last occurrence of given delimiter with the [replacement] string. - * If the string does not contain the delimiter, returns [missingDelimiterValue] which defaults to the original string. - */ -public fun String.replaceBeforeLast(delimiter: String, replacement: String, missingDelimiterValue: String = this): String { - val index = lastIndexOf(delimiter) - return if (index == -1) missingDelimiterValue else replaceRange(0, index, replacement) -} -*/ - - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.replaceRange(firstIndex: Int, lastIndex: Int, replacement: String): String - = replaceRange(firstIndex, lastIndex, replacement) - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.replaceRange(range: IntRange, replacement: String): String - = replaceRange(range.start, range.end + 1, replacement) - - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.removePrefix(prefix: String): String = removePrefix(prefix) - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.removeSuffix(suffix: String): String = removeSuffix(suffix) - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.removeSurrounding(prefix: String, suffix: String): String = removeSurrounding(prefix, suffix) - -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.removeSurrounding(delimiter: String): String = removeSurrounding(delimiter, delimiter) - - - -/** - * Returns a new string obtained by replacing each substring of this string that matches the given regular expression - * with the given [replacement]. - * - * The [replacement] can consist of any combination of literal text and $-substitutions. To treat the replacement string - * literally escape it with the [kotlin.text.Regex.Companion.escapeReplacement] method. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.replace(regex: Regex, replacement: String): String = regex.replace(this, replacement) - -/** - * Returns a new string obtained by replacing each substring of this string that matches the given regular expression - * with the result of the given function [transform] that takes [MatchResult] and returns a string to be used as a - * replacement for that match. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.replace(regex: Regex, transform: (MatchResult) -> String): String = regex.replace(this, transform) - -/** - * Replaces the first occurrence of the given regular expression [regex] in this string with specified [replacement] expression. - * - * @param replacement A replacement expression that can include substitutions. See [Regex.replaceFirst] for details. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.replaceFirst(regex: Regex, replacement: String): String = regex.replaceFirst(this, replacement) - - -/** - * Returns `true` if this string matches the given regular expression. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.matches(regex: Regex): Boolean = regex.matches(this) - - -/** - * Returns `true` if this string starts with the specified character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.startsWith(char: Char, ignoreCase: Boolean = false): Boolean = - this.length() > 0 && this[0].equals(char, ignoreCase) - -/** - * Returns `true` if this string ends with the specified character. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.endsWith(char: Char, ignoreCase: Boolean = false): Boolean = - this.length() > 0 && this[lastIndex].equals(char, ignoreCase) - - - - - -// indexOfAny() - -private fun String.findAnyOf(chars: CharArray, startIndex: Int, ignoreCase: Boolean, last: Boolean): Pair? { - if (!ignoreCase && chars.size() == 1) { - val char = chars.single() - val index = if (!last) nativeIndexOf(char, startIndex) else nativeLastIndexOf(char, startIndex) - return if (index < 0) null else index to char - } - - val indices = if (!last) Math.max(startIndex, 0)..lastIndex else Math.min(startIndex, lastIndex) downTo 0 - for (index in indices) { - val charAtIndex = get(index) - val matchingCharIndex = chars.indexOfFirst { it.equals(charAtIndex, ignoreCase) } - if (matchingCharIndex >= 0) - return index to chars[matchingCharIndex] - } - - return null -} - -/** - * Finds the index of the first occurrence of any of the specified [chars] in this string, starting from the specified [startIndex] and - * optionally ignoring the case. - * - * @param ignoreCase `true` to ignore character case when matching a character. By default `false`. - * @returns An index of the first occurrence of matched character from [chars] or -1 if none of [chars] are found. - * - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.indexOfAny(chars: CharArray, startIndex: Int = 0, ignoreCase: Boolean = false): Int = - findAnyOf(chars, startIndex, ignoreCase, last = false)?.first ?: -1 - -/** - * Finds the index of the last occurrence of any of the specified [chars] in this string, starting from the specified [startIndex] and - * optionally ignoring the case. - * - * @param startIndex The index of character to start searching at. The search proceeds backward toward the beginning of the string. - * @param ignoreCase `true` to ignore character case when matching a character. By default `false`. - * @returns An index of the last occurrence of matched character from [chars] or -1 if none of [chars] are found. - * - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.lastIndexOfAny(chars: CharArray, startIndex: Int = lastIndex, ignoreCase: Boolean = false): Int = - findAnyOf(chars, startIndex, ignoreCase, last = true)?.first ?: -1 - - -private fun String.findAnyOf(strings: Collection, startIndex: Int, ignoreCase: Boolean, last: Boolean): Pair? { - if (!ignoreCase && strings.size() == 1) { - val string = strings.single() - val index = if (!last) nativeIndexOf(string, startIndex) else nativeLastIndexOf(string, startIndex) - return if (index < 0) null else index to string - } - - val indices = if (!last) Math.max(startIndex, 0)..length() else Math.min(startIndex, lastIndex) downTo 0 - for (index in indices) { - val matchingString = strings.firstOrNull { it.regionMatches(0, this, index, it.length(), ignoreCase) } - if (matchingString != null) - return index to matchingString - } - - return null -} - -/** - * Finds the first occurrence of any of the specified [strings] in this string, starting from the specified [startIndex] and - * optionally ignoring the case. - * - * @param ignoreCase `true` to ignore character case when matching a string. By default `false`. - * @returns A pair of an index of the first occurrence of matched string from [strings] and the string matched or `null` if none of [strings] are found. - * - * To avoid ambiguous results when strings in [strings] have characters in common, this method proceeds from - * the beginning to the end of this string, and finds at each position the first element in [strings] - * that matches this string at that position. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.findAnyOf(strings: Collection, startIndex: Int = 0, ignoreCase: Boolean = false): Pair? = - findAnyOf(strings, startIndex, ignoreCase, last = false) - -/** - * Finds the last occurrence of any of the specified [strings] in this string, starting from the specified [startIndex] and - * optionally ignoring the case. - * - * @param startIndex The index of character to start searching at. The search proceeds backward toward the beginning of the string. - * @param ignoreCase `true` to ignore character case when matching a string. By default `false`. - * @returns A pair of an index of the last occurrence of matched string from [strings] and the string matched or `null` if none of [strings] are found. - * - * To avoid ambiguous results when strings in [strings] have characters in common, this method proceeds from - * the end toward the beginning of this string, and finds at each position the first element in [strings] - * that matches this string at that position. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.findLastAnyOf(strings: Collection, startIndex: Int = lastIndex, ignoreCase: Boolean = false): Pair? = - findAnyOf(strings, startIndex, ignoreCase, last = true) - -/** - * Finds the index of the first occurrence of any of the specified [strings] in this string, starting from the specified [startIndex] and - * optionally ignoring the case. - * - * @param ignoreCase `true` to ignore character case when matching a string. By default `false`. - * @returns An index of the first occurrence of matched string from [strings] or -1 if none of [strings] are found. - * - * To avoid ambiguous results when strings in [strings] have characters in common, this method proceeds from - * the beginning to the end of this string, and finds at each position the first element in [strings] - * that matches this string at that position. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.indexOfAny(strings: Collection, startIndex: Int = 0, ignoreCase: Boolean = false): Int = - findAnyOf(strings, startIndex, ignoreCase, last = false)?.first ?: -1 - -/** - * Finds the index of the last occurrence of any of the specified [strings] in this string, starting from the specified [startIndex] and - * optionally ignoring the case. - * - * @param startIndex The index of character to start searching at. The search proceeds backward toward the beginning of the string. - * @param ignoreCase `true` to ignore character case when matching a string. By default `false`. - * @returns An index of the last occurrence of matched string from [strings] or -1 if none of [strings] are found. - * - * To avoid ambiguous results when strings in [strings] have characters in common, this method proceeds from - * the end toward the beginning of this string, and finds at each position the first element in [strings] - * that matches this string at that position. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.lastIndexOfAny(strings: Collection, startIndex: Int = lastIndex, ignoreCase: Boolean = false): Int = - findAnyOf(strings, startIndex, ignoreCase, last = true)?.first ?: -1 - - -// indexOf - -/** - * Returns the index within this string of the first occurrence of the specified character, starting from the specified [startIndex]. - * - * @param ignoreCase `true` to ignore character case when matching a character. By default `false`. - * @returns An index of the first occurrence of [char] or -1 if none is found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.indexOf(char: Char, startIndex: Int = 0, ignoreCase: Boolean = false): Int { - return if (ignoreCase) - indexOfAny(charArrayOf(char), startIndex, ignoreCase) - else - nativeIndexOf(char, startIndex) -} - -/** - * Returns the index within this string of the first occurrence of the specified [string], starting from the specified [startIndex]. - * - * @param ignoreCase `true` to ignore character case when matching a string. By default `false`. - * @returns An index of the first occurrence of [string] or -1 if none is found. - */ -@kotlin.jvm.JvmOverloads -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.indexOf(string: String, startIndex: Int = 0, ignoreCase: Boolean = false): Int { - return if (ignoreCase) - indexOfAny(listOf(string), startIndex, ignoreCase) - else - nativeIndexOf(string, startIndex) -} - -/** - * Returns the index within this string of the last occurrence of the specified character, starting from the specified [startIndex]. - * - * @param startIndex The index of character to start searching at. The search proceeds backward toward the beginning of the string. - * @param ignoreCase `true` to ignore character case when matching a character. By default `false`. - * @returns An index of the first occurrence of [char] or -1 if none is found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.lastIndexOf(char: Char, startIndex: Int = lastIndex, ignoreCase: Boolean = false): Int { - return if (ignoreCase) - lastIndexOfAny(charArrayOf(char), startIndex, ignoreCase) - else - nativeLastIndexOf(char, startIndex) -} - - -/** - * Returns the index within this string of the last occurrence of the specified [string], starting from the specified [startIndex]. - * - * @param startIndex The index of character to start searching at. The search proceeds backward toward the beginning of the string. - * @param ignoreCase `true` to ignore character case when matching a string. By default `false`. - * @returns An index of the first occurrence of [string] or -1 if none is found. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.lastIndexOf(string: String, startIndex: Int = lastIndex, ignoreCase: Boolean = false): Int { - return if (ignoreCase) - lastIndexOfAny(listOf(string), startIndex, ignoreCase) - else - nativeLastIndexOf(string, startIndex) -} - -/** - * Returns `true` if this string contains the specified sequence of characters as a substring. - * - * @param ignoreCase `true` to ignore character case when comparing strings. By default `false`. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public operator fun String.contains(seq: CharSequence, ignoreCase: Boolean = false): Boolean = - indexOf(seq.toString(), ignoreCase = ignoreCase) >= 0 - - -/** - * Returns `true` if this string contains the specified character. - * - * @param ignoreCase `true` to ignore character case when comparing characters. By default `false`. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public operator fun String.contains(char: Char, ignoreCase: Boolean = false): Boolean = - indexOf(char, ignoreCase = ignoreCase) >= 0 - - - - -// split - -/** - * Splits this string to a sequence of strings around occurrences of the specified [delimiters]. - * - * @param delimiters One or more strings to be used as delimiters. - * @param ignoreCase `true` to ignore character case when matching a delimiter. By default `false`. - * @param limit The maximum number of substrings to return. Zero by default means no limit is set. - * - * To avoid ambiguous results when strings in [delimiters] have characters in common, this method proceeds from - * the beginning to the end of this string, and finds at each position the first element in [delimiters] - * that matches this string at that position. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.splitToSequence(vararg delimiters: String, ignoreCase: Boolean = false, limit: Int = 0): Sequence = - splitToSequence(*delimiters, ignoreCase = ignoreCase, limit = limit) - -/** - * Splits this string to a list of strings around occurrences of the specified [delimiters]. - * - * @param delimiters One or more strings to be used as delimiters. - * @param ignoreCase `true` to ignore character case when matching a delimiter. By default `false`. - * @param limit The maximum number of substrings to return. Zero by default means no limit is set. - * - * To avoid ambiguous results when strings in [delimiters] have characters in common, this method proceeds from - * the beginning to the end of this string, and matches at each position the first element in [delimiters] - * that is equal to a delimiter in this instance at that position. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.split(vararg delimiters: String, ignoreCase: Boolean = false, limit: Int = 0): List = - splitToSequence(*delimiters, ignoreCase = ignoreCase, limit = limit).toList() - -/** - * Splits this string to a sequence of strings around occurrences of the specified [delimiters]. - * - * @param delimiters One or more characters to be used as delimiters. - * @param ignoreCase `true` to ignore character case when matching a delimiter. By default `false`. - * @param limit The maximum number of substrings to return. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.splitToSequence(vararg delimiters: Char, ignoreCase: Boolean = false, limit: Int = 0): Sequence = - splitToSequence(*delimiters, ignoreCase = ignoreCase, limit = limit) - -/** - * Splits this string to a list of strings around occurrences of the specified [delimiters]. - * - * @param delimiters One or more characters to be used as delimiters. - * @param ignoreCase `true` to ignore character case when matching a delimiter. By default `false`. - * @param limit The maximum number of substrings to return. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.split(vararg delimiters: Char, ignoreCase: Boolean = false, limit: Int = 0): List = - splitToSequence(*delimiters, ignoreCase = ignoreCase, limit = limit).toList() - -/** - * Splits this string around matches of the given regular expression. - * - * @param limit Non-negative value specifying the maximum number of substrings to return. - * Zero by default means no limit is set. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.split(pattern: Regex, limit: Int = 0): List = pattern.split(this, limit) - -/** - * Splits this string to a sequence of lines delimited by any of the following character sequences: CRLF, LF or CR. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.lineSequence(): Sequence = lineSequence() - -/** - * * Splits this string to a list of lines delimited by any of the following character sequences: CRLF, LF or CR. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.lines(): List = lineSequence().toList() - diff --git a/libraries/stdlib/src/kotlin/text/StringsDeprecatedJVM.kt b/libraries/stdlib/src/kotlin/text/StringsDeprecatedJVM.kt deleted file mode 100644 index d14f9654851..00000000000 --- a/libraries/stdlib/src/kotlin/text/StringsDeprecatedJVM.kt +++ /dev/null @@ -1,182 +0,0 @@ -@file:kotlin.jvm.JvmMultifileClass -@file:kotlin.jvm.JvmName("StringsKt") - -package kotlin - -import java.io.StringReader -import java.util.regex.Pattern -import java.nio.charset.Charset -import java.util.* - -/* -/** - * Returns `true` if this string is equal to [anotherString], optionally ignoring character case. - * - * @param ignoreCase `true` to ignore character case when comparing strings. By default `false`. - */ -public fun String.equals(anotherString: String, ignoreCase: Boolean = false): Boolean { - return if (!ignoreCase) - (this as java.lang.String).equals(anotherString) - else - (this as java.lang.String).equalsIgnoreCase(anotherString) -} - -/** - * Returns a new string with all occurrences of [oldChar] replaced with [newChar]. - */ -public fun String.replace(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String { - if (!ignoreCase) - return (this as java.lang.String).replace(oldChar, newChar) - else - return splitToSequence(oldChar, ignoreCase = ignoreCase).joinToString(separator = newChar.toString()) -} - -/** - * Returns a new string obtained by replacing all occurrences of the [oldValue] substring in this string - * with the specified [newValue] string. - */ -public fun String.replace(oldValue: String, newValue: String, ignoreCase: Boolean = false): String = - splitToSequence(oldValue, ignoreCase = ignoreCase).joinToString(separator = newValue) - - -/** - * Returns a new string with the first occurrence of [oldChar] replaced with [newChar]. - */ -public fun String.replaceFirst(oldChar: Char, newChar: Char, ignoreCase: Boolean = false): String { - val index = indexOf(oldChar, ignoreCase = ignoreCase) - return if (index < 0) this else this.replaceRange(index, index + 1, newChar.toString()) -} - -/** - * Returns a new string obtained by replacing the first occurrence of the [oldValue] substring in this string - * with the specified [newValue] string. - */ -public fun String.replaceFirst(oldValue: String, newValue: String, ignoreCase: Boolean = false): String { - val index = indexOf(oldValue, ignoreCase = ignoreCase) - return if (index < 0) this else this.replaceRange(index, index + oldValue.length(), newValue) -} - -*/ - -/** - * Splits this string around matches of the given regular expression. - - * @param limit Non-negative value specifying the maximum number of substrings to return. - * Zero by default means no limit is set. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.split(regex: Pattern, limit: Int = 0): List -{ - require(limit >= 0, { "Limit must be non-negative, but was $limit" } ) - return regex.split(this, if (limit == 0) -1 else limit).asList() -} - -/* - -/** - * Compares two strings lexicographically, optionally ignoring case differences. - */ -public fun String.compareTo(other: String, ignoreCase: Boolean = false): Int { - if (ignoreCase) - return (this as java.lang.String).compareToIgnoreCase(other) - else - return (this as java.lang.String).compareTo(other) -} - -/** - * Returns a new string obtained by concatenating this string and the specified string. - */ -public fun String.concat(str: String): String = (this as java.lang.String).concat(str) - -/** - * Returns `true` if this string is equal to the contents of the specified CharSequence. - */ -public fun String.contentEquals(cs: CharSequence): Boolean = (this as java.lang.String).contentEquals(cs) - -/** - * Returns `true` if this string is equal to the contents of the specified StringBuffer. - */ -public fun String.contentEquals(sb: StringBuffer): Boolean = (this as java.lang.String).contentEquals(sb) - -*/ -/** - * Returns `true` if this string is empty or consists solely of whitespace characters. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.isBlank(): Boolean = length() == 0 || all { it.isWhitespace() } - -/* - -/** - * Returns a subsequence of this sequence specified by given [range]. - */ -public fun CharSequence.slice(range: IntRange): CharSequence { - return subSequence(range.start, range.end + 1) // inclusive -} - -/** - * Returns a copy of this string having its first letter uppercased, or the original string, - * if it's empty or already starts with an upper case letter. - * - * @sample test.text.StringTest.capitalize - */ -public fun String.capitalize(): String { - return if (isNotEmpty() && charAt(0).isLowerCase()) substring(0, 1).toUpperCase() + substring(1) else this -} - -/** - * Returns a copy of this string having its first letter lowercased, or the original string, - * if it's empty or already starts with a lower case letter. - * - * @sample test.text.StringTest.decapitalize - */ -public fun String.decapitalize(): String { - return if (isNotEmpty() && charAt(0).isUpperCase()) substring(0, 1).toLowerCase() + substring(1) else this -} -*/ - -/** - * Repeats a given string [n] times. - * @throws [IllegalArgumentException] when n < 0. - * @sample test.text.StringJVMTest.repeat - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public fun String.repeat(n: Int): String { - if (n < 0) - throw IllegalArgumentException("Value should be non-negative, but was $n") - - val sb = StringBuilder() - for (i in 1..n) { - sb.append(this) - } - return sb.toString() -} - - -/** - * Appends the contents of this string, excluding the first characters that satisfy the given [predicate], - * to the given Appendable. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.dropWhileTo(result: T, predicate: (Char) -> Boolean): T { - var start = true - for (element in this) { - if (start && predicate(element)) { - // ignore - } else { - start = false - result.append(element) - } - } - return result -} - -/** - * Appends the first characters from this string that satisfy the given [predicate] to the given Appendable. - */ -@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN) -public inline fun String.takeWhileTo(result: T, predicate: (Char) -> Boolean): T { - for (c in this) if (predicate(c)) result.append(c) else break - return result -} - diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt index 195d84a5250..23ba27e9150 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt @@ -15,8 +15,7 @@ fun aggregates(): List { return true """ } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("none(predicate: (T) -> Boolean)") { @@ -30,8 +29,7 @@ fun aggregates(): List { return true """ } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("none()") { @@ -43,8 +41,7 @@ fun aggregates(): List { return true """ } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("any(predicate: (T) -> Boolean)") { @@ -58,8 +55,7 @@ fun aggregates(): List { return false """ } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("any()") { @@ -71,8 +67,7 @@ fun aggregates(): List { return false """ } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("count(predicate: (T) -> Boolean)") { @@ -87,8 +82,7 @@ fun aggregates(): List { return count """ } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("count()") { @@ -101,9 +95,8 @@ fun aggregates(): List { return count """ } - deprecate(Strings) { forBinaryCompatibility } doc(CharSequences) { "Returns the length of this char sequence."} - body(CharSequences, Strings) { + body(CharSequences) { "return length" } body(Maps, Collections, ArraysOfObjects, ArraysOfPrimitives) { @@ -113,8 +106,7 @@ fun aggregates(): List { templates add f("sumBy(selector: (T) -> Int)") { inline(true) - include(CharSequences, Strings) - deprecate(Strings) { forBinaryCompatibility } + include(CharSequences) doc { f -> "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." } returns("Int") body { @@ -130,8 +122,7 @@ fun aggregates(): List { templates add f("sumByDouble(selector: (T) -> Double)") { inline(true) - include(CharSequences, Strings) - deprecate(Strings) { forBinaryCompatibility } + include(CharSequences) doc { f -> "Returns the sum of all values produced by [selector] function applied to each ${f.element} in the ${f.collection}." } returns("Double") body { @@ -163,8 +154,7 @@ fun aggregates(): List { return min """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) { + body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) { """ if (isEmpty()) return null var min = this[0] @@ -202,8 +192,7 @@ fun aggregates(): List { return minElem """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) { + body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) { """ if (isEmpty()) return null @@ -268,8 +257,7 @@ fun aggregates(): List { """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) { + body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) { """ if (isEmpty()) return null @@ -308,8 +296,7 @@ fun aggregates(): List { return maxElem """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings, ArraysOfObjects, ArraysOfPrimitives) { + body(CharSequences, ArraysOfObjects, ArraysOfPrimitives) { """ if (isEmpty()) return null @@ -358,8 +345,7 @@ fun aggregates(): List { templates add f("fold(initial: R, operation: (R, T) -> R)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Accumulates value starting with [initial] value and applying [operation] from left to right to current accumulator value and each ${f.element}." } typeParam("R") returns("R") @@ -375,8 +361,7 @@ fun aggregates(): List { templates add f("foldRight(initial: R, operation: (T, R) -> R)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - only(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) + only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) doc { f -> "Accumulates value starting with [initial] value and applying [operation] from right to left to each ${f.element} and current accumulator value." } typeParam("R") returns("R") @@ -395,8 +380,7 @@ fun aggregates(): List { templates add f("reduce(operation: (T, T) -> T)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) exclude(ArraysOfObjects, Iterables, Sequences) doc { f -> "Accumulates value starting with the first ${f.element} and applying [operation] from left to right to current accumulator value and each ${f.element}." } @@ -440,8 +424,7 @@ fun aggregates(): List { templates add f("reduceRight(operation: (T, T) -> T)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - only(CharSequences, Strings, ArraysOfPrimitives) + only(CharSequences, ArraysOfPrimitives) doc { f -> "Accumulates value starting with last ${f.element} and applying [operation] from right to left to each ${f.element} and current accumulator value." } returns("T") body { @@ -492,14 +475,12 @@ fun aggregates(): List { for (element in this) action(element) """ } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("forEachIndexed(action: (Int, T) -> Unit)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Performs the given [action] on each ${f.element}, providing sequential index with the ${f.element}." } returns("Unit") body { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt index 86f8bad8d61..ac9fe54cadc 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt @@ -69,27 +69,6 @@ fun comparables(): List { } } - templates add f("coerceIn(range: Range)") { - sourceFile(SourceFile.Ranges) - only(Primitives) - only(numericPrimitives.filterNot { it.isIntegral() }) - returns("SELF") - deprecate { forBinaryCompatibility } // force use generic overload instead - doc { - """ - Ensures that this value lies in the specified [range]. - - @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end. - """ - } - body { - """ - if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: ${'$'}range.") - return if (this < range.start) range.start else if (this > range.end) range.end else this - """ - } - } - templates add f("coerceIn(range: ClosedRange)") { sourceFile(SourceFile.Ranges) only(Primitives, Generic) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index 1192ddacb5d..ecbb46d09ee 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -226,8 +226,7 @@ fun elements(): List { """ } - deprecate(Strings) { forBinaryCompatibility } - body(Lists, CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects) { + body(Lists, CharSequences, ArraysOfPrimitives, ArraysOfObjects) { """ for (index in indices) { if (predicate(this[index])) { @@ -257,8 +256,7 @@ fun elements(): List { """ } - deprecate(Strings) { forBinaryCompatibility } - body(Lists, CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects) { + body(Lists, CharSequences, ArraysOfPrimitives, ArraysOfObjects) { """ for (index in indices.reversed()) { if (predicate(this[index])) { @@ -287,8 +285,7 @@ fun elements(): List { return elementAtOrElse(index) { throw IndexOutOfBoundsException("Sequence doesn't contain element at index $index.") } """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) { + body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ return get(index) """ @@ -328,9 +325,8 @@ fun elements(): List { return defaultValue(index) """ } - deprecate(Strings) { forBinaryCompatibility } - inline(true, CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) - body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) { + inline(true, CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) + body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) """ @@ -341,8 +337,7 @@ fun elements(): List { doc { f -> "Returns ${f.element.prefixWithArticle()} at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this ${f.collection}." } returns("T") inline(true) - deprecate(Strings) { forBinaryCompatibility } - only(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) + only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) body { """ return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) @@ -384,8 +379,7 @@ fun elements(): List { return null """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) { + body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ return if (index >= 0 && index <= lastIndex) get(index) else null """ @@ -395,8 +389,7 @@ fun elements(): List { templates add f("getOrNull(index: Int)") { doc { f -> "Returns ${f.element.prefixWithArticle()} at the given [index] or `null` if the [index] is out of bounds of this ${f.collection}." } returns("T?") - deprecate(Strings) { forBinaryCompatibility } - only(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) + only(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) body { """ return if (index >= 0 && index <= lastIndex) get(index) else null @@ -428,8 +421,7 @@ fun elements(): List { } """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) { + body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ if (isEmpty()) throw NoSuchElementException("Collection is empty.") @@ -466,8 +458,7 @@ fun elements(): List { } """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) { + body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ return if (isEmpty()) null else this[0] """ @@ -485,8 +476,7 @@ fun elements(): List { templates add f("first(predicate: (T) -> Boolean)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> """Returns the first ${f.element} matching the given [predicate]. @throws [NoSuchElementException] if no such ${f.element} is found.""" } returns("T") @@ -501,8 +491,7 @@ fun elements(): List { templates add f("firstOrNull(predicate: (T) -> Boolean)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Returns the first ${f.element} matching the given [predicate], or `null` if ${f.element} was not found." } returns("T?") body { @@ -515,8 +504,7 @@ fun elements(): List { templates add f("find(predicate: (T) -> Boolean)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Returns the first ${f.element} matching the given [predicate], or `null` if no such ${f.element} was found." } returns("T?") body { "return firstOrNull(predicate)"} @@ -558,8 +546,7 @@ fun elements(): List { return last """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings, Lists, ArraysOfObjects, ArraysOfPrimitives) { + body(CharSequences, Lists, ArraysOfObjects, ArraysOfPrimitives) { """ if (isEmpty()) throw NoSuchElementException("Collection is empty.") @@ -598,8 +585,7 @@ fun elements(): List { return last """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { + body(CharSequences) { """ return if (isEmpty()) null else this[length - 1] """ @@ -614,8 +600,7 @@ fun elements(): List { templates add f("last(predicate: (T) -> Boolean)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> """Returns the last ${f.element} matching the given [predicate]. @throws [NoSuchElementException] if no such ${f.element} is found.""" } returns("T") @@ -640,7 +625,7 @@ fun elements(): List { """ } - body(CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects, Lists) { + body(CharSequences, ArraysOfPrimitives, ArraysOfObjects, Lists) { """ for (index in this.indices.reversed()) { val element = this[index] @@ -653,8 +638,7 @@ fun elements(): List { templates add f("lastOrNull(predicate: (T) -> Boolean)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Returns the last ${f.element} matching the given [predicate], or `null` if no such ${f.element} was found." } returns("T?") body { f -> @@ -675,7 +659,7 @@ fun elements(): List { """ } - body(CharSequences, Strings, ArraysOfPrimitives, ArraysOfObjects, Lists) { + body(CharSequences, ArraysOfPrimitives, ArraysOfObjects, Lists) { """ for (index in this.indices.reversed()) { val element = this[index] @@ -688,8 +672,7 @@ fun elements(): List { templates add f("findLast(predicate: (T) -> Boolean)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(Lists, CharSequences, Strings) + include(Lists, CharSequences) doc { f -> "Returns the last ${f.element} matching the given [predicate], or `null` if no such ${f.element} was found." } returns("T?") body { "return lastOrNull(predicate)"} @@ -729,8 +712,7 @@ fun elements(): List { return single """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { + body(CharSequences) { """ return when (length) { 0 -> throw NoSuchElementException("Collection is empty.") @@ -780,8 +762,7 @@ fun elements(): List { return single """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { + body(CharSequences) { """ return if (length == 1) this[0] else null """ @@ -795,8 +776,7 @@ fun elements(): List { templates add f("single(predicate: (T) -> Boolean)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Returns the single ${f.element} matching the given [predicate], or throws exception if there is no or more than one matching ${f.element}." } returns("T") body { @@ -818,8 +798,7 @@ fun elements(): List { templates add f("singleOrNull(predicate: (T) -> Boolean)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Returns the single ${f.element} matching the given [predicate], or `null` if ${f.element} was not found or more than one ${f.element} was found." } returns("T?") body { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt index 12767e5fecf..9f5495a3e91 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Filtering.kt @@ -384,8 +384,7 @@ fun filtering(): List { """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { + body(CharSequences) { """ for (index in 0..length - 1) { val element = get(index) @@ -480,9 +479,8 @@ fun filtering(): List { """ } - deprecate(Strings) { forBinaryCompatibility } doc(CharSequences) { "Appends all characters not matching the given [predicate] to the given [destination]." } - body(CharSequences, Strings) { + body(CharSequences) { """ for (element in this) if (!predicate(element)) destination.append(element) return destination diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt index 9f1e3add9d3..2987527f58a 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Generators.kt @@ -556,8 +556,7 @@ fun generators(): List { } templates add f("zip(other: String, transform: (Char, Char) -> V)") { - deprecate(Strings) { forBinaryCompatibility } - only(CharSequences, Strings) + only(CharSequences) doc { """ Returns a list of values built from characters of both char sequences with same indexes using provided [transform]. List has length of shortest char sequence. @@ -599,8 +598,7 @@ fun generators(): List { templates add f("zip(other: String)") { infix(true) - deprecate(Strings) { forBinaryCompatibility } - only(CharSequences, Strings) + only(CharSequences) doc { """ Returns a list of pairs built from characters of both char sequences with same indexes. List has length of shortest char sequence. diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt index 41d05eea1d4..f3c4f311470 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt @@ -6,8 +6,7 @@ fun mapping(): List { val templates = arrayListOf() templates add f("withIndex()") { - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Returns a ${if (f == Sequences) f.mapResult else "lazy [Iterable]"} of [IndexedValue] for each ${f.element} of the original ${f.collection}." } returns("Iterable>") body { @@ -41,8 +40,7 @@ fun mapping(): List { body(ArraysOfObjects, ArraysOfPrimitives) { "return mapIndexedTo(ArrayList(size), transform)" } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { + body(CharSequences) { "return mapIndexedTo(ArrayList(length), transform)" } inline(false, Sequences) @@ -69,8 +67,7 @@ fun mapping(): List { body(ArraysOfObjects, ArraysOfPrimitives, Maps) { "return mapTo(ArrayList(size), transform)" } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { + body(CharSequences) { "return mapTo(ArrayList(length), transform)" } @@ -149,8 +146,7 @@ fun mapping(): List { return destination """ } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("mapIndexedTo(destination: C, transform: (Int, T) -> R)") { @@ -174,9 +170,8 @@ fun mapping(): List { return destination """ } - deprecate(Strings) { forBinaryCompatibility } deprecate(Maps) { Deprecation("Use entries.mapIndexedTo instead.", replaceWith = "this.entries.mapIndexedTo(destination, transform)") } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("mapNotNullTo(destination: C, transform: (T) -> R?)") { @@ -231,8 +226,7 @@ fun mapping(): List { body { "return flatMapTo(ArrayList(), transform)" } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("flatMap(transform: (T) -> Sequence)") { @@ -261,8 +255,7 @@ fun mapping(): List { return destination """ } - deprecate(Strings) { forBinaryCompatibility } - include(Maps, CharSequences, Strings) + include(Maps, CharSequences) } templates add f("flatMapTo(destination: C, transform: (T) -> Sequence)") { @@ -287,8 +280,7 @@ fun mapping(): List { templates add f("groupBy(selector: (T) -> K)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Returns a map of the ${f.element}s in original ${f.collection} grouped by the key returned by the given [selector] function." } typeParam("K") returns("Map>") @@ -298,8 +290,7 @@ fun mapping(): List { templates add f("groupByTo(map: MutableMap>, selector: (T) -> K)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) typeParam("K") doc { f -> "Appends ${f.element}s from original ${f.collection} grouped by the key returned by the given [selector] function to the given [map]." } returns("Map>") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt index a63c874e0fd..e59e89bee39 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt @@ -14,32 +14,22 @@ fun ranges(): List { fun Collection.permutations(): List> = flatMap { a -> map { b -> a to b } } templates add f("reversed()") { - only(RangesOfPrimitives, ProgressionsOfPrimitives) + only(ProgressionsOfPrimitives) only(rangePrimitives) 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") - deprecate(RangesOfPrimitives) { forBinaryCompatibility } - body(RangesOfPrimitives) { - "return TProgression.fromClosedRange(last, first, -ONE)" - } body(ProgressionsOfPrimitives) { "return TProgression.fromClosedRange(last, first, -increment)" } } templates add f("reversed()") { - only(RangesOfPrimitives, ProgressionsOfPrimitives) + only(ProgressionsOfPrimitives) only(defaultPrimitives - PrimitiveType.Boolean - rangePrimitives - floatingPointPrimitives) 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") deprecate(Deprecation("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)) - deprecate(RangesOfPrimitives) { forBinaryCompatibility } annotations("""@Suppress("DEPRECATION_ERROR")""") - body(RangesOfPrimitives) { - "return TProgression.fromClosedRange(last, first, -ONE)" - } body(ProgressionsOfPrimitives) { "return TProgression.fromClosedRange(last, first, -increment)" } @@ -48,18 +38,10 @@ fun ranges(): List { templates add f("step(step: SUM)") { infix(true) - only(RangesOfPrimitives, ProgressionsOfPrimitives) + only(ProgressionsOfPrimitives) only(rangePrimitives) 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") - deprecate(RangesOfPrimitives) { forBinaryCompatibility } - body(RangesOfPrimitives) { - """ - checkStepIsPositive(step > 0, step) - return TProgression.fromClosedRange(first, last, step) - """ - } body(ProgressionsOfPrimitives) { """ checkStepIsPositive(step > 0, step) @@ -71,27 +53,12 @@ fun ranges(): List { templates add f("step(step: SUM)") { infix(true) - only(RangesOfPrimitives, ProgressionsOfPrimitives) + only(ProgressionsOfPrimitives) only(defaultPrimitives - PrimitiveType.Boolean - rangePrimitives - floatingPointPrimitives) 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") deprecate(Deprecation("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)) - deprecate(RangesOfPrimitives) { forBinaryCompatibility } annotations("""@Suppress("DEPRECATION_ERROR")""") - body(RangesOfPrimitives) { - """ - checkStepIsPositive(step > 0, step) - return TProgression.fromClosedRange(first, last, step) - """ - } - bodyForTypes(RangesOfPrimitives, PrimitiveType.Float, PrimitiveType.Double) { - """ - if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN.") - checkStepIsPositive(step > 0, step) - return TProgression.fromClosedRange(start, end, step) - """ - } body(ProgressionsOfPrimitives) { """ checkStepIsPositive(step > 0, step) @@ -135,34 +102,12 @@ fun ranges(): List { body { "return $progressionType.fromClosedRange($fromExpr, $toExpr, $incrementExpr)" } } - fun downToDeprecated(fromType: PrimitiveType, toType: PrimitiveType) = f("`-downTo`(to: $toType)") { - deprecate { forBinaryCompatibility } - sourceFile(SourceFile.Ranges) - only(Primitives) - only(fromType) - val elementType = maxByCapacity(fromType, toType) - val progressionType = elementType.name + "Progression" - returns(progressionType) - annotations("""@[kotlin.jvm.JvmName("downTo") kotlin.jvm.JvmVersion]""") - val fromExpr = if (elementType == fromType) "this" else "this.to$elementType()" - val toExpr = if (elementType == toType) "to" else "to.to$elementType()" - val incrementExpr = when (elementType) { - PrimitiveType.Long -> "-1L" - PrimitiveType.Float -> "-1.0F" - PrimitiveType.Double -> "-1.0" - else -> "-1" - } - - body { "return $progressionType.fromClosedRange($fromExpr, $toExpr, $incrementExpr)" } - } - val numericPrimitives = PrimitiveType.numericPrimitives val numericPermutations = numericPrimitives.permutations() val primitivePermutations = numericPermutations + (PrimitiveType.Char to PrimitiveType.Char) val integralPermutations = primitivePermutations.filter { it.first.isIntegral() && it.second.isIntegral() } templates addAll integralPermutations.map { downTo(it.first, it.second) } - templates addAll listOf(PrimitiveType.Byte, PrimitiveType.Short).permutations().map { downToDeprecated(it.first, it.second) } fun until(fromType: PrimitiveType, toType: PrimitiveType) = f("until(to: $toType)") { infix(true) @@ -207,36 +152,7 @@ fun ranges(): List { } } - fun untilDeprecated(fromType: PrimitiveType, toType: PrimitiveType) = f("`-until`(to: $toType)") { - deprecate { forBinaryCompatibility } - - sourceFile(SourceFile.Ranges) - only(Primitives) - only(fromType) - val elementType = maxByCapacity(fromType, toType) - val progressionType = elementType.name + "Range" - returns(progressionType) - annotations("""@[kotlin.jvm.JvmName("until") kotlin.jvm.JvmVersion]""") - - val fromExpr = if (elementType == fromType) "this" else "this.to$elementType()" - - if (elementType == toType) { - // hack to work around incorrect char overflow behavior in JVM and int overflow behavior in JS - val toExpr = "to" - body { - """ - val to_ = ($toExpr - 1).to$elementType() - if (to_ > to) throw IllegalArgumentException("The to argument value '${'$'}to' was too small.") - return $progressionType($fromExpr, to_) - """ - } - } else { - body { "return $progressionType($fromExpr, (to.to$elementType() - 1).to$elementType())" } - } - } - templates addAll integralPermutations.map { until(it.first, it.second) } - templates addAll listOf(PrimitiveType.Byte, PrimitiveType.Short).permutations().map { untilDeprecated(it.first, it.second) } fun containsDeprecated(rangeType: PrimitiveType, itemType: PrimitiveType) = f("contains(item: $itemType)") { operator(true) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt index 38f03c0e70e..ea1cdfec0ba 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Sequence.kt @@ -30,8 +30,7 @@ fun sequences(): List { """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { + body(CharSequences) { """ if (this is String && isEmpty()) return emptySequence() return object : Sequence { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt index f2e26e2fc35..00dec1a06bb 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt @@ -6,8 +6,7 @@ fun snapshots(): List { val templates = arrayListOf() templates add f("toCollection(destination: C)") { - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Appends all ${f.element}s to the given [destination] collection." } returns("C") typeParam("C : MutableCollection") @@ -26,8 +25,7 @@ fun snapshots(): List { returns("Set") body { "return toCollection(LinkedHashSet(mapCapacity(collectionSizeOrDefault(12))))" } body(Sequences) { "return toCollection(LinkedHashSet())" } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { "return toCollection(LinkedHashSet(mapCapacity(length)))" } + body(CharSequences) { "return toCollection(LinkedHashSet(mapCapacity(length)))" } body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(LinkedHashSet(mapCapacity(size)))" } } @@ -36,14 +34,12 @@ fun snapshots(): List { returns("HashSet") body { "return toCollection(HashSet(mapCapacity(collectionSizeOrDefault(12))))" } body(Sequences) { "return toCollection(HashSet())" } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { "return toCollection(HashSet(mapCapacity(length)))" } + body(CharSequences) { "return toCollection(HashSet(mapCapacity(length)))" } body(ArraysOfObjects, ArraysOfPrimitives) { "return toCollection(HashSet(mapCapacity(size)))" } } templates add f("toSortedSet()") { - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) typeParam("T: Comparable") doc { f -> "Returns a [SortedSet] of all ${f.element}s." } returns("SortedSet") @@ -76,8 +72,7 @@ fun snapshots(): List { """ } body(Collections) { "return ArrayList(this)" } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { "return toCollection(ArrayList(length))" } + body(CharSequences) { "return toCollection(ArrayList(length))" } body(ArraysOfObjects) { "return ArrayList(this.asCollection())" } body(ArraysOfPrimitives) { """ @@ -103,8 +98,7 @@ fun snapshots(): List { } templates add f("toList()") { - deprecate(Strings) { forBinaryCompatibility } - include(CharSequences, Strings) + include(CharSequences) doc { f -> "Returns a [List] containing all ${f.element}s." } returns("List") body { "return this.toArrayList()" } @@ -119,9 +113,7 @@ fun snapshots(): List { templates add f("toMap(selector: (T) -> K)") { inline(true) - deprecate(Strings) { forBinaryCompatibility } - body(Strings) { "return toMapBy(selector)" } - include(CharSequences, Strings) + include(CharSequences) typeParam("K") returns("Map") deprecate(Deprecation("Use toMapBy instead.", replaceWith = "toMapBy(selector)")) @@ -163,8 +155,7 @@ fun snapshots(): List { return result """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { + body(CharSequences) { """ val capacity = (length/.75f) + 1 val result = LinkedHashMap(Math.max(capacity.toInt(), 16)) @@ -222,8 +213,7 @@ fun snapshots(): List { return result """ } - deprecate(Strings) { forBinaryCompatibility } - body(CharSequences, Strings) { + body(CharSequences) { """ val capacity = (length/.75f) + 1 val result = LinkedHashMap(Math.max(capacity.toInt(), 16)) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt index 7b75b8c24a1..1ab836e2232 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Strings.kt @@ -55,17 +55,6 @@ fun strings(): List { } } - templates add f("joinTo(buffer: A, separator: String = \", \", prefix: String = \"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\", transform: ((T) -> String)? = null)") { - deprecate { forBinaryCompatibility } - typeParam("A : Appendable") - returns { "A" } - body { - """ - return joinTo(buffer, separator, prefix, postfix, limit, truncated, transform) - """ - } - } - templates add f("joinToString(separator: CharSequence = \", \", prefix: CharSequence = \"\", postfix: CharSequence = \"\", limit: Int = -1, truncated: CharSequence = \"...\", transform: ((T) -> CharSequence)? = null)") { doc { """ @@ -85,15 +74,5 @@ fun strings(): List { } } - templates add f("joinToString(separator: String = \", \", prefix: String = \"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\", transform: ((T) -> String)? = null)") { - deprecate { forBinaryCompatibility } - returns("String") - body { - """ - return joinTo(StringBuilder(), separator, prefix, postfix, limit, truncated, transform).toString() - """ - } - } - return templates } \ No newline at end of file