From b868e6f8da47881b4d9f038574e69a632e2cb027 Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Fri, 13 Dec 2019 03:54:27 +0300 Subject: [PATCH] Rename Appendable methods parameters --- .../stdlib/js/src/kotlin/text/AppendableJs.kt | 26 +++++------ .../js/src/kotlin/text/StringBuilderJs.kt | 10 ++--- .../stdlib/src/kotlin/text/Appendable.kt | 43 +++++++++++++------ .../stdlib/src/kotlin/text/StringBuilder.kt | 6 +-- .../kotlin-stdlib-runtime-merged.txt | 1 + 5 files changed, 52 insertions(+), 34 deletions(-) diff --git a/libraries/stdlib/js/src/kotlin/text/AppendableJs.kt b/libraries/stdlib/js/src/kotlin/text/AppendableJs.kt index dee565e2e05..3609cc09d7c 100644 --- a/libraries/stdlib/js/src/kotlin/text/AppendableJs.kt +++ b/libraries/stdlib/js/src/kotlin/text/AppendableJs.kt @@ -10,28 +10,28 @@ package kotlin.text */ public actual interface Appendable { /** - * Appends the specified character [c] to this Appendable and returns this instance. + * Appends the specified character [value] to this Appendable and returns this instance. * - * @param c the character to append. + * @param value the character to append. */ - public actual fun append(c: Char): Appendable + public actual fun append(value: Char): Appendable /** - * Appends the specified character sequence [csq] to this Appendable and returns this instance. + * Appends the specified character sequence [value] to this Appendable and returns this instance. * - * @param csq the character sequence to append. If [csq] is `null`, then the four characters `"null"` are appended to this Appendable. + * @param value the character sequence to append. If [value] is `null`, then the four characters `"null"` are appended to this Appendable. */ - public actual fun append(csq: CharSequence?): Appendable + public actual fun append(value: CharSequence?): Appendable /** - * Appends a subsequence of the specified character sequence [csq] to this Appendable and returns this instance. + * Appends a subsequence of the specified character sequence [value] to this Appendable and returns this instance. * - * @param csq the character sequence from which a subsequence is appended. If [csq] is `null`, - * then characters are appended as if [csq] contained the four characters `"null"`. - * @param start the beginning (inclusive) of the subsequence to append. - * @param end the end (exclusive) of the subsequence to append. + * @param value the character sequence from which a subsequence is appended. If [value] is `null`, + * then characters are appended as if [value] contained the four characters `"null"`. + * @param startIndex the beginning (inclusive) of the subsequence to append. + * @param endIndex the end (exclusive) of the subsequence to append. * - * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [start] or [end] is out of range of the [csq] character sequence indices or when `start > end`. + * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`. */ - public actual fun append(csq: CharSequence?, start: Int, end: Int): Appendable + public actual fun append(value: CharSequence?, startIndex: Int, endIndex: Int): Appendable } \ No newline at end of file diff --git a/libraries/stdlib/js/src/kotlin/text/StringBuilderJs.kt b/libraries/stdlib/js/src/kotlin/text/StringBuilderJs.kt index cfbce659039..29e0675d26f 100644 --- a/libraries/stdlib/js/src/kotlin/text/StringBuilderJs.kt +++ b/libraries/stdlib/js/src/kotlin/text/StringBuilderJs.kt @@ -36,18 +36,18 @@ public actual class StringBuilder actual constructor(content: String) : Appendab actual override fun subSequence(startIndex: Int, endIndex: Int): CharSequence = string.substring(startIndex, endIndex) - actual override fun append(c: Char): StringBuilder { - string += c + actual override fun append(value: Char): StringBuilder { + string += value return this } - actual override fun append(csq: CharSequence?): StringBuilder { - string += csq.toString() + actual override fun append(value: CharSequence?): StringBuilder { + string += value.toString() return this } @UseExperimental(ExperimentalStdlibApi::class) - actual override fun append(csq: CharSequence?, start: Int, end: Int): StringBuilder = this.appendRange(csq, start, end) + actual override fun append(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder = this.appendRange(value, startIndex, endIndex) /** * Reverses the contents of this string builder and returns this instance. diff --git a/libraries/stdlib/src/kotlin/text/Appendable.kt b/libraries/stdlib/src/kotlin/text/Appendable.kt index 742cda8971f..6d26fd12ced 100644 --- a/libraries/stdlib/src/kotlin/text/Appendable.kt +++ b/libraries/stdlib/src/kotlin/text/Appendable.kt @@ -13,30 +13,47 @@ package kotlin.text */ expect interface Appendable { /** - * Appends the specified character [c] to this Appendable and returns this instance. + * Appends the specified character [value] to this Appendable and returns this instance. * - * @param c the character to append. + * @param value the character to append. */ - fun append(c: Char): Appendable + fun append(value: Char): Appendable /** - * Appends the specified character sequence [csq] to this Appendable and returns this instance. + * Appends the specified character sequence [value] to this Appendable and returns this instance. * - * @param csq the character sequence to append. If [csq] is `null`, then the four characters `"null"` are appended to this Appendable. + * @param value the character sequence to append. If [value] is `null`, then the four characters `"null"` are appended to this Appendable. */ - fun append(csq: CharSequence?): Appendable + fun append(value: CharSequence?): Appendable /** - * Appends a subsequence of the specified character sequence [csq] to this Appendable and returns this instance. + * Appends a subsequence of the specified character sequence [value] to this Appendable and returns this instance. * - * @param csq the character sequence from which a subsequence is appended. If [csq] is `null`, - * then characters are appended as if [csq] contained the four characters `"null"`. - * @param start the beginning (inclusive) of the subsequence to append. - * @param end the end (exclusive) of the subsequence to append. + * @param value the character sequence from which a subsequence is appended. If [value] is `null`, + * then characters are appended as if [value] contained the four characters `"null"`. + * @param startIndex the beginning (inclusive) of the subsequence to append. + * @param endIndex the end (exclusive) of the subsequence to append. * - * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [start] or [end] is out of range of the [csq] character sequence indices or when `start > end`. + * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`. */ - fun append(csq: CharSequence?, start: Int, end: Int): Appendable + fun append(value: CharSequence?, startIndex: Int, endIndex: Int): Appendable +} + +/** + * Appends a subsequence of the specified character sequence [value] to this Appendable and returns this instance. + * + * @param value the character sequence from which a subsequence is appended. If [value] is `null`, + * then characters are appended as if [value] contained the four characters `"null"`. + * @param startIndex the beginning (inclusive) of the subsequence to append. + * @param endIndex the end (exclusive) of the subsequence to append. + * + * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`. + */ +@SinceKotlin("1.3") +@ExperimentalStdlibApi +public fun T.appendRange(value: CharSequence?, startIndex: Int, endIndex: Int): T { + @Suppress("UNCHECKED_CAST") + return append(value, startIndex, endIndex) as T } /** diff --git a/libraries/stdlib/src/kotlin/text/StringBuilder.kt b/libraries/stdlib/src/kotlin/text/StringBuilder.kt index 8e4c203e6f9..c91b16f3708 100644 --- a/libraries/stdlib/src/kotlin/text/StringBuilder.kt +++ b/libraries/stdlib/src/kotlin/text/StringBuilder.kt @@ -34,9 +34,9 @@ expect class StringBuilder : Appendable, CharSequence { override fun subSequence(startIndex: Int, endIndex: Int): CharSequence - override fun append(c: Char): StringBuilder - override fun append(csq: CharSequence?): StringBuilder - override fun append(csq: CharSequence?, start: Int, end: Int): StringBuilder + override fun append(value: Char): StringBuilder + override fun append(value: CharSequence?): StringBuilder + override fun append(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder /** * Reverses the contents of this string builder and returns this instance. diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt index d7fc167eeae..9c0fd8a730a 100644 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt +++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt @@ -4904,6 +4904,7 @@ public final class kotlin/text/StringsKt { public static final fun append (Ljava/lang/Appendable;[Ljava/lang/CharSequence;)Ljava/lang/Appendable; public static final fun append (Ljava/lang/StringBuilder;[Ljava/lang/Object;)Ljava/lang/StringBuilder; public static final fun append (Ljava/lang/StringBuilder;[Ljava/lang/String;)Ljava/lang/StringBuilder; + public static final fun appendRange (Ljava/lang/Appendable;Ljava/lang/CharSequence;II)Ljava/lang/Appendable; public static final fun appendln (Ljava/lang/Appendable;)Ljava/lang/Appendable; public static final fun appendln (Ljava/lang/StringBuilder;)Ljava/lang/StringBuilder; public static final fun asIterable (Ljava/lang/CharSequence;)Ljava/lang/Iterable;