StdLib cleanup: drop deprecated iterators and streams.

This commit is contained in:
Ilya Gorbunov
2015-06-26 00:09:38 +03:00
parent 6d4e48ab9a
commit 4660b07687
23 changed files with 7 additions and 2320 deletions
@@ -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)