Added inline flag to templates

This commit is contained in:
Mikhael Bogdanov
2013-11-20 12:04:28 +04:00
parent eb3edeb527
commit 40d7841892
4 changed files with 29 additions and 1 deletions
@@ -8,6 +8,7 @@ fun collections(): List<GenericFunction> {
val templates = ArrayList<GenericFunction>()
templates add f("requireNoNulls()") {
isInline = false
absentFor(PrimitiveArrays) // Those are inherently non-nulls
doc = "Returns a original Iterable containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements"
typeParam("T:Any")
@@ -84,6 +84,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("filterNotNullTo(result: C)") {
isInline = false
absentFor(PrimitiveArrays) // Those are inherently non-nulls
doc = "Filters all non-*null* elements into the given list"
typeParam("T:Any")
@@ -273,6 +274,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("drop(n: Int)") {
isInline = false
doc = "Returns a list containing everything but the first *n* elements"
returns("List<T>")
body {
@@ -324,6 +326,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("toCollection(result: C)") {
isInline = false
doc = "Copies all elements into the given collection"
typeParam("C: MutableCollection<in T>")
returns("C")
@@ -337,6 +340,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("reverse()") {
isInline = false
doc = "Reverses the order the elements into a list"
returns("List<T>")
body {
@@ -349,6 +353,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("toLinkedList()") {
isInline = false
doc = "Copies all elements into a [[LinkedList]]"
returns("LinkedList<T>")
@@ -356,6 +361,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("toList()") {
isInline = false
doc = "Copies all elements into a [[List]]"
returns("List<T>")
@@ -363,6 +369,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("toSet()") {
isInline = false
doc = "Copies all elements into a [[Set]]"
returns("Set<T>")
@@ -370,6 +377,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("toSortedSet()") {
isInline = false
doc = "Copies all elements into a [[SortedSet]]"
returns("SortedSet<T>")
@@ -377,6 +385,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("withIndices()") {
isInline = false
doc = "Returns an iterator of Pairs(index, data)"
returns("Iterator<Pair<Int, T>>")
@@ -446,6 +455,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("appendString(buffer: Appendable, separator: String = \", \", prefix: String =\"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\")") {
isInline = false
doc =
"""
Appends the string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied
@@ -473,6 +483,7 @@ fun commons(): ArrayList<GenericFunction> {
}
templates add f("makeString(separator: String = \", \", prefix: String = \"\", postfix: String = \"\", limit: Int = -1, truncated: String = \"...\")") {
isInline = false
doc = """
Creates a string from all the elements separated using the *separator* and using the given *prefix* and *postfix* if supplied.
@@ -31,6 +31,7 @@ fun iterables(): ArrayList<GenericFunction> {
}
templates add f("filterNotNull()") {
isInline = false
absentFor(PrimitiveArrays) // Those are inherently non-nulls
doc = "Returns a list containing all the non-*null* elements"
typeParam("T:Any")
@@ -63,6 +64,7 @@ fun iterables(): ArrayList<GenericFunction> {
}
templates add f("take(n: Int)") {
isInline = false
doc = "Returns a list containing the first *n* elements"
returns("List<T>")
body {
@@ -80,6 +82,7 @@ fun iterables(): ArrayList<GenericFunction> {
}
templates add f("requireNoNulls()") {
isInline = false
absentFor(PrimitiveArrays) // Those are inherently non-nulls
doc = "Returns a original Iterable containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements"
typeParam("T:Any")
@@ -101,6 +104,7 @@ fun iterables(): ArrayList<GenericFunction> {
}
templates add f("plus(element: T)") {
isInline = false
doc = "Creates an [[Iterator]] which iterates over this iterator then the given element at the end"
returns("List<T>")
@@ -116,6 +120,7 @@ fun iterables(): ArrayList<GenericFunction> {
}
templates add f("plus(iterator: Iterator<T>)") {
isInline = false
doc = "Creates an [[Iterator]] which iterates over this iterator then the following iterator"
returns("List<T>")
@@ -132,6 +137,7 @@ fun iterables(): ArrayList<GenericFunction> {
}
templates add f("plus(collection: Iterable<T>)") {
isInline = false
doc = "Creates an [[Iterator]] which iterates over this iterator then the following collection"
returns("List<T>")
@@ -7,8 +7,9 @@ fun iterators(): List<GenericFunction> {
val templates = commons()
templates add f("filter(predicate: (T) -> Boolean)") {
isInline = false
doc = "Returns an iterator over elements which match the given *predicate*"
returns("Iterator<T>")
body {
"return FilterIterator<T>(this, predicate)"
@@ -25,6 +26,7 @@ fun iterators(): List<GenericFunction> {
}
templates add f("filterNotNull()") {
isInline = false
doc = "Returns an iterator over non-*null* elements"
typeParam("T:Any")
toNullableT = true
@@ -36,6 +38,7 @@ fun iterators(): List<GenericFunction> {
}
templates add f("map(transform : (T) -> R)") {
isInline = false
doc = "Returns an iterator obtained by applying *transform*, a function transforming an object of type *T* into an object of type *R*"
typeParam("R")
returns("Iterator<R>")
@@ -46,6 +49,7 @@ fun iterators(): List<GenericFunction> {
}
templates add f("flatMap(transform: (T) -> Iterator<R>)") {
isInline = false
doc = "Returns an iterator over the concatenated results of transforming each element to one or more values"
typeParam("R")
returns("Iterator<R>")
@@ -56,6 +60,7 @@ fun iterators(): List<GenericFunction> {
}
templates add f("requireNoNulls()") {
isInline = false
doc = "Returns a original Iterable containing all the non-*null* elements, throwing an [[IllegalArgumentException]] if there are any null elements"
typeParam("T:Any")
toNullableT = true
@@ -73,6 +78,7 @@ fun iterators(): List<GenericFunction> {
templates add f("take(n: Int)") {
isInline = false
doc = "Returns an iterator restricted to the first *n* elements"
returns("Iterator<T>")
body {
@@ -84,6 +90,7 @@ fun iterators(): List<GenericFunction> {
}
templates add f("takeWhile(predicate: (T) -> Boolean)") {
isInline = false
doc = "Returns an iterator restricted to the first elements that match the given *predicate*"
returns("Iterator<T>")
@@ -95,6 +102,7 @@ fun iterators(): List<GenericFunction> {
// TODO: drop(n), dropWhile
templates add f("plus(element: T)") {
isInline = false
doc = "Creates an [[Iterator]] which iterates over this iterator then the given element at the end"
returns("Iterator<T>")
@@ -105,6 +113,7 @@ fun iterators(): List<GenericFunction> {
}
templates add f("plus(iterator: Iterator<T>)") {
isInline = false
doc = "Creates an [[Iterator]] which iterates over this iterator then the following iterator"
returns("Iterator<T>")
@@ -114,6 +123,7 @@ fun iterators(): List<GenericFunction> {
}
templates add f("plus(collection: Iterable<T>)") {
isInline = false
doc = "Creates an [[Iterator]] which iterates over this iterator then the following collection"
returns("Iterator<T>")