Deprecate join (use joinToString instead)
#KT-6909
This commit is contained in:
@@ -312,7 +312,7 @@ public fun NodeList?.toXmlString(xmlDeclaration: Boolean = false): String {
|
|||||||
|
|
||||||
/** Converts the collection of nodes to an XML String */
|
/** Converts the collection of nodes to an XML String */
|
||||||
public fun nodesToXmlString(nodes: Iterable<Node>, xmlDeclaration: Boolean = false): String {
|
public fun nodesToXmlString(nodes: Iterable<Node>, xmlDeclaration: Boolean = false): String {
|
||||||
return nodes.map { it.toXmlString(xmlDeclaration) }.join()
|
return nodes.map { it.toXmlString(xmlDeclaration) }.joinToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Syntax sugar
|
// Syntax sugar
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ public val Node.innerHTML: String
|
|||||||
* Returns the HTML representation of the nodes
|
* Returns the HTML representation of the nodes
|
||||||
*/
|
*/
|
||||||
public val NodeList.outerHTML: String
|
public val NodeList.outerHTML: String
|
||||||
get() = toList().map { it.innerHTML }.join("")
|
get() = toList().map { it.innerHTML }.joinToString("")
|
||||||
|
|
||||||
/** Returns an [Iterator] of all the next [Element] siblings */
|
/** Returns an [Iterator] of all the next [Element] siblings */
|
||||||
public fun Node.nextElements(): List<Element> = nextSiblings().filterIsInstance<Element>()
|
public fun Node.nextElements(): List<Element> = nextSiblings().filterIsInstance<Element>()
|
||||||
@@ -183,7 +183,7 @@ public var Element.classSet: MutableSet<String>
|
|||||||
return answer
|
return answer
|
||||||
}
|
}
|
||||||
set(value) {
|
set(value) {
|
||||||
this.classes = value.join(" ")
|
this.classes = value.joinToString(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ public fun String.substring(range: IntRange): String = substring(range.start, ra
|
|||||||
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
* If the collection could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
||||||
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Use joinToString instead.", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
|
||||||
public fun Iterable<String>.join(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
public fun Iterable<String>.join(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||||
return joinToString(separator, prefix, postfix, limit, truncated)
|
return joinToString(separator, prefix, postfix, limit, truncated)
|
||||||
}
|
}
|
||||||
@@ -239,6 +240,7 @@ public fun Iterable<String>.join(separator: String = ", ", prefix: String = "",
|
|||||||
* If the array could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
* If the array could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
||||||
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Use joinToString instead.", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
|
||||||
public fun Array<String>.join(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
public fun Array<String>.join(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||||
return joinToString(separator, prefix, postfix, limit, truncated)
|
return joinToString(separator, prefix, postfix, limit, truncated)
|
||||||
}
|
}
|
||||||
@@ -248,6 +250,7 @@ public fun Array<String>.join(separator: String = ", ", prefix: String = "", pos
|
|||||||
* If the stream could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
* If the stream could be huge, you can specify a non-negative value of [limit], in which case only the first [limit]
|
||||||
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
* elements will be appended, followed by the [truncated] string (which defaults to "...").
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Use joinToString instead.", ReplaceWith("joinToString(separator, prefix, postfix, limit, truncated)"))
|
||||||
public fun Sequence<String>.join(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
public fun Sequence<String>.join(separator: String = ", ", prefix: String = "", postfix: String = "", limit: Int = -1, truncated: String = "..."): String {
|
||||||
return joinToString(separator, prefix, postfix, limit, truncated)
|
return joinToString(separator, prefix, postfix, limit, truncated)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ class CollectionTest {
|
|||||||
assertEquals("{foo-bar}", buffer.toString())
|
assertEquals("{foo-bar}", buffer.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
@test fun join() {
|
@test fun joinToString() {
|
||||||
val data = listOf("foo", "bar")
|
val data = listOf("foo", "bar")
|
||||||
val text = data.join("-", "<", ">")
|
val text = data.joinToString("-", "<", ">")
|
||||||
assertEquals("<foo-bar>", text)
|
assertEquals("<foo-bar>", text)
|
||||||
|
|
||||||
val big = listOf("a", "b", "c", "d", "e", "f")
|
val big = listOf("a", "b", "c", "d", "e", "f")
|
||||||
val text2 = big.join(limit = 3, truncated = "*")
|
val text2 = big.joinToString(limit = 3, truncated = "*")
|
||||||
assertEquals("a, b, c, *", text2)
|
assertEquals("a, b, c, *", text2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class ListSpecificTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(3, list.size())
|
assertEquals(3, list.size())
|
||||||
assertEquals("beverage,location,name", list.join(","))
|
assertEquals("beverage,location,name", list.joinToString(","))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class MapTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(6, list.size())
|
assertEquals(6, list.size())
|
||||||
assertEquals("beverage,beer,location,Mells,name,James", list.join(","))
|
assertEquals("beverage,beer,location,Mells,name,James", list.joinToString(","))
|
||||||
}
|
}
|
||||||
|
|
||||||
@test fun stream() {
|
@test fun stream() {
|
||||||
@@ -101,7 +101,7 @@ class MapTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(6, list.size())
|
assertEquals(6, list.size())
|
||||||
assertEquals("beverage,beer,location,Mells,name,James", list.join(","))
|
assertEquals("beverage,beer,location,Mells,name,James", list.joinToString(","))
|
||||||
}
|
}
|
||||||
|
|
||||||
@test fun iterateWithExtraction() {
|
@test fun iterateWithExtraction() {
|
||||||
@@ -113,7 +113,7 @@ class MapTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertEquals(6, list.size())
|
assertEquals(6, list.size())
|
||||||
assertEquals("beverage,beer,location,Mells,name,James", list.join(","))
|
assertEquals("beverage,beer,location,Mells,name,James", list.joinToString(","))
|
||||||
}
|
}
|
||||||
|
|
||||||
@test fun contains() {
|
@test fun contains() {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ fun customerTemplate(customer: Customer) = """
|
|||||||
<body>
|
<body>
|
||||||
<h1>Hello ${customer.name}</h1>
|
<h1>Hello ${customer.name}</h1>
|
||||||
<ul>
|
<ul>
|
||||||
${customer.products.map{ productSnippet(it) }.join("\n")}
|
${customer.products.map{ productSnippet(it) }.joinToString("\n")}
|
||||||
</ul>
|
</ul>
|
||||||
<p>lets do some kool stuff</p>
|
<p>lets do some kool stuff</p>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -251,11 +251,11 @@ class StringJVMTest {
|
|||||||
|
|
||||||
@test fun join() {
|
@test fun join() {
|
||||||
val data = "abcd".map { it.toString() }
|
val data = "abcd".map { it.toString() }
|
||||||
val result = data.join("_", "(", ")")
|
val result = data.joinToString("_", "(", ")")
|
||||||
assertEquals("(a_b_c_d)", result)
|
assertEquals("(a_b_c_d)", result)
|
||||||
|
|
||||||
val data2 = "verylongstring".map { it.toString() }
|
val data2 = "verylongstring".map { it.toString() }
|
||||||
val result2 = data2.join("-", "[", "]", 11, "oops")
|
val result2 = data2.joinToString("-", "[", "]", 11, "oops")
|
||||||
assertEquals("[v-e-r-y-l-o-n-g-s-t-r-oops]", result2)
|
assertEquals("[v-e-r-y-l-o-n-g-s-t-r-oops]", result2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -278,7 +278,7 @@ public open class Kotlin2JsCompile() : AbstractKotlinCompile<K2JSCompilerArgumen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().debug("${getName()} set libraryFiles to ${args.libraryFiles.join(",")}")
|
getLogger().debug("${getName()} set libraryFiles to ${args.libraryFiles.joinToString(",")}")
|
||||||
getLogger().debug("${getName()} set outputFile to ${args.outputFile}")
|
getLogger().debug("${getName()} set outputFile to ${args.outputFile}")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -139,7 +139,7 @@ abstract class BaseGradleIT {
|
|||||||
listOf("/bin/bash", "./gradlew") + tailParameters
|
listOf("/bin/bash", "./gradlew") + tailParameters
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.normalize() = this.lineSequence().join(SYSTEM_LINE_SEPARATOR)
|
private fun String.normalize() = this.lineSequence().joinToString(SYSTEM_LINE_SEPARATOR)
|
||||||
|
|
||||||
private fun isWindows(): Boolean {
|
private fun isWindows(): Boolean {
|
||||||
return System.getProperty("os.name")!!.contains("Windows")
|
return System.getProperty("os.name")!!.contains("Windows")
|
||||||
|
|||||||
+1
-1
@@ -78,7 +78,7 @@ public class SeleniumQUnit(val driver: WebDriver) {
|
|||||||
|
|
||||||
for (message in failMessages)
|
for (message in failMessages)
|
||||||
println("FAILED: $message")
|
println("FAILED: $message")
|
||||||
fail(failMessages.join("\n"))
|
fail(failMessages.joinToString("\n"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ class GenericFunction(val signature: String, val keyword: String = "fun") {
|
|||||||
|
|
||||||
val types = effectiveTypeParams()
|
val types = effectiveTypeParams()
|
||||||
if (!types.isEmpty()) {
|
if (!types.isEmpty()) {
|
||||||
builder.append(types.join(separator = ", ", prefix = "<", postfix = "> ").renderType())
|
builder.append(types.joinToString(separator = ", ", prefix = "<", postfix = "> ").renderType())
|
||||||
}
|
}
|
||||||
|
|
||||||
val receiverType = (if (toNullableT) receiver.replace("T>", "T?>") else receiver).renderType()
|
val receiverType = (if (toNullableT) receiver.replace("T>", "T?>") else receiver).renderType()
|
||||||
|
|||||||
Reference in New Issue
Block a user