StdLib cleanup: drop deprecated iterators and streams.
This commit is contained in:
@@ -148,24 +148,6 @@ class GenericFunction(val signature: String, val keyword: String = "fun") : Comp
|
||||
}
|
||||
|
||||
fun build(builder: StringBuilder, f: Family, primitive: PrimitiveType?) {
|
||||
if (f == Sequences) {
|
||||
val text = StringBuilder {
|
||||
doBuild(this, f, primitive)
|
||||
}.toString()
|
||||
builder.append(text)
|
||||
builder.appendln()
|
||||
if (deprecate[f] == null) // (deprecates[f] == null && deprecate.isEmpty())
|
||||
builder.appendln("deprecated(\"Migrate to using Sequence<T> and respective functions\")")
|
||||
val streamText = text
|
||||
.replace("Sequence", "Stream")
|
||||
.replace("sequence", "stream")
|
||||
.replace("MultiStream", "Multistream")
|
||||
builder.append(streamText)
|
||||
} else
|
||||
doBuild(builder, f, primitive)
|
||||
}
|
||||
|
||||
fun doBuild(builder: StringBuilder, f: Family, primitive: PrimitiveType?) {
|
||||
val returnType = returns[f] ?: throw RuntimeException("No return type specified for $signature")
|
||||
|
||||
val isAsteriskOrT = if (receiverAsterisk) "*" else "T"
|
||||
|
||||
@@ -86,7 +86,7 @@ fun generators(): List<GenericFunction> {
|
||||
returns("Sequence<T>")
|
||||
body {
|
||||
"""
|
||||
return sequenceOf(this, collection.sequence()).flatten()
|
||||
return sequenceOf(this, collection.asSequence()).flatten()
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,26 +5,6 @@ import templates.Family.*
|
||||
fun sequences(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
templates add f("stream()") {
|
||||
include(Maps)
|
||||
exclude(Sequences)
|
||||
deprecate { "Use asSequence() instead" }
|
||||
doc { "Returns a sequence from the given collection" }
|
||||
deprecateReplacement { "asSequence()" }
|
||||
returns("Stream<T>")
|
||||
body {
|
||||
"""
|
||||
val sequence = asSequence()
|
||||
return object : Stream<T> {
|
||||
override fun iterator(): Iterator<T> {
|
||||
return sequence.iterator()
|
||||
}
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
templates add f("sequence()") {
|
||||
include(Maps)
|
||||
exclude(Sequences)
|
||||
|
||||
Reference in New Issue
Block a user