diff --git a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt index a4a77729aa4..c4311339aee 100644 --- a/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/ArraysFromJLangIterables.kt @@ -28,9 +28,12 @@ public inline fun Array.any(predicate: (T) -> Boolean) : Boolean { /** * Appends the string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * * @includeFunctionBody ../../test/CollectionTest.kt appendString */ -public inline fun Array.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1): Unit { +public inline fun Array.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -40,7 +43,7 @@ public inline fun Array.appendString(buffer: Appendable, separator: Strin buffer.append(text) } else break } - if (limit >= 0 && count > limit) buffer.append("...") + if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) } @@ -152,13 +155,16 @@ public inline fun Array.groupBy(result: Map> = HashMap Array.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1): String { +public inline fun Array.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() - appendString(buffer, separator, prefix, postfix, limit) + appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString().sure() } diff --git a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt index a147f2efe82..be372c4cbd9 100644 --- a/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/JUtilIteratorsFromJLangIterables.kt @@ -26,9 +26,12 @@ public inline fun java.util.Iterator.any(predicate: (T) -> Boolean) : Boo /** * Appends the string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * * @includeFunctionBody ../../test/CollectionTest.kt appendString */ -public inline fun java.util.Iterator.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1): Unit { +public inline fun java.util.Iterator.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -38,7 +41,7 @@ public inline fun java.util.Iterator.appendString(buffer: Appendable, sep buffer.append(text) } else break } - if (limit >= 0 && count > limit) buffer.append("...") + if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) } @@ -150,13 +153,16 @@ public inline fun java.util.Iterator.groupBy(result: Map> = } /** - * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied + * Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied. + * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." * * @includeFunctionBody ../../test/CollectionTest.kt appendString */ -public inline fun java.util.Iterator.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1): String { +public inline fun java.util.Iterator.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() - appendString(buffer, separator, prefix, postfix, limit) + appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString().sure() } diff --git a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt index 29a82738db7..a07ee5d7a3a 100644 --- a/libraries/stdlib/src/generated/StandardFromJLangIterables.kt +++ b/libraries/stdlib/src/generated/StandardFromJLangIterables.kt @@ -28,9 +28,12 @@ public inline fun Iterable.any(predicate: (T) -> Boolean) : Boolean { /** * Appends the string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied * + * If a collection could be huge you can specify a non-negative value of *limit* which will only show a subset of the collection then it will + * a special *truncated* separator (which defaults to "..." + * * @includeFunctionBody ../../test/CollectionTest.kt appendString */ -public inline fun Iterable.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1): Unit { +public inline fun Iterable.appendString(buffer: Appendable, separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): Unit { buffer.append(prefix) var count = 0 for (element in this) { @@ -40,7 +43,7 @@ public inline fun Iterable.appendString(buffer: Appendable, separator: St buffer.append(text) } else break } - if (limit >= 0 && count > limit) buffer.append("...") + if (limit >= 0 && count > limit) buffer.append(truncated) buffer.append(postfix) } @@ -152,13 +155,16 @@ public inline fun Iterable.groupBy(result: Map> = HashMap Iterable.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1): String { +public inline fun Iterable.makeString(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String { val buffer = StringBuilder() - appendString(buffer, separator, prefix, postfix, limit) + appendString(buffer, separator, prefix, postfix, limit, truncated) return buffer.toString().sure() } diff --git a/libraries/stdlib/test/CollectionTest.kt b/libraries/stdlib/test/CollectionTest.kt index 59c2a2909f2..3d0f60b3567 100644 --- a/libraries/stdlib/test/CollectionTest.kt +++ b/libraries/stdlib/test/CollectionTest.kt @@ -231,7 +231,6 @@ class CollectionTest { } - test fun makeString() { val data = arrayList("foo", "bar") val text = data.makeString("-", "<", ">")