Clarify parameter order of lambda function parameter of *Indexed functions.

#KT-10953 Fixed
This commit is contained in:
Ilya Gorbunov
2016-02-17 06:56:05 +03:00
parent 0e0455daeb
commit b19c0363fd
7 changed files with 276 additions and 4 deletions
@@ -360,6 +360,8 @@ fun aggregates(): List<GenericFunction> {
"""
Accumulates value starting with [initial] value and applying [operation] from left to right
to current accumulator value and each ${f.element} with its index in the original ${f.collection}.
@param [operation] function that takes the index of ${f.element.prefixWithArticle()}, current accumulator value
and the ${f.element} itself, and calculates the next accumulator value.
"""
}
typeParam("R")
@@ -382,6 +384,8 @@ fun aggregates(): List<GenericFunction> {
"""
Accumulates value starting with [initial] value and applying [operation] from right to left
to each ${f.element} with its index in the original ${f.collection} and current accumulator value.
@param [operation] function that takes the index of ${f.element.prefixWithArticle()}, the ${f.element} itself
and current accumulator value, and calculates the next accumulator value.
"""
}
typeParam("R")
@@ -442,6 +446,8 @@ fun aggregates(): List<GenericFunction> {
"""
Accumulates value starting with the first ${f.element} and applying [operation] from left to right
to current accumulator value and each ${f.element} with its index in the original ${f.collection}.
@param [operation] function that takes the index of ${f.element.prefixWithArticle()}, current accumulator value
and the ${f.element} itself and calculates the next accumulator value.
"""
}
returns("T")
@@ -467,6 +473,8 @@ fun aggregates(): List<GenericFunction> {
"""
Accumulates value starting with the first ${f.element} and applying [operation] from left to right
to current accumulator value and each ${f.element} with its index in the original ${f.collection}.
@param [operation] function that takes the index of ${f.element.prefixWithArticle()}, current accumulator value
and the ${f.element} itself and calculates the next accumulator value.
"""
}
typeParam("S")
@@ -507,6 +515,8 @@ fun aggregates(): List<GenericFunction> {
"""
Accumulates value starting with last ${f.element} and applying [operation] from right to left
to each ${f.element} with its index in the original ${f.collection} and current accumulator value.
@param [operation] function that takes the index of ${f.element.prefixWithArticle()}, the ${f.element} itself
and current accumulator value, and calculates the next accumulator value.
"""
}
returns("T")
@@ -534,6 +544,8 @@ fun aggregates(): List<GenericFunction> {
"""
Accumulates value starting with last ${f.element} and applying [operation] from right to left
to each ${f.element} with its index in the original ${f.collection} and current accumulator value.
@param [operation] function that takes the index of ${f.element.prefixWithArticle()}, the ${f.element} itself
and current accumulator value, and calculates the next accumulator value.
"""
}
typeParam("S")
@@ -670,7 +682,12 @@ fun aggregates(): List<GenericFunction> {
templates add f("forEachIndexed(action: (Int, T) -> Unit)") {
inline(true)
include(CharSequences)
doc { f -> "Performs the given [action] on each ${f.element}, providing sequential index with the ${f.element}." }
doc { f ->
"""
Performs the given [action] on each ${f.element}, providing sequential index with the ${f.element}.
@param [action] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself
and performs the desired action on the ${f.element}.
""" }
returns("Unit")
body {
"""
@@ -406,7 +406,13 @@ fun filtering(): List<GenericFunction> {
templates add f("filterIndexed(predicate: (Int, T) -> Boolean)") {
inline(true)
doc { f -> "Returns a ${f.mapResult} containing only ${f.element.pluralize()} matching the given [predicate]." }
doc { f ->
"""
Returns a ${f.mapResult} containing only ${f.element.pluralize()} matching the given [predicate].
@param [predicate] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself
and returns the result of predicate evaluation on the ${f.element}.
"""
}
returns("List<T>")
body {
"""
@@ -414,7 +420,13 @@ fun filtering(): List<GenericFunction> {
"""
}
doc(CharSequences, Strings) { f -> "Returns a ${f.collection} containing only those characters from the original ${f.collection} that match the given [predicate]." }
doc(CharSequences, Strings) { f ->
"""
Returns a ${f.collection} containing only those characters from the original ${f.collection} that match the given [predicate].
@param [predicate] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself
and returns the result of predicate evaluation on the ${f.element}.
"""
}
returns(CharSequences, Strings) { "SELF" }
body(CharSequences, Strings) { f -> """return filterIndexedTo(StringBuilder(), predicate)${toResult(f)}""" }
@@ -434,7 +446,12 @@ fun filtering(): List<GenericFunction> {
include(CharSequences)
doc { f -> "Appends all ${f.element.pluralize()} matching the given [predicate] to the given [destination]." }
doc { f ->
"""
Appends all ${f.element.pluralize()} matching the given [predicate] to the given [destination].
@param [predicate] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself
and returns the result of predicate evaluation on the ${f.element}.
""" }
typeParam("C : TCollection")
returns("C")
@@ -30,6 +30,8 @@ fun mapping(): List<GenericFunction> {
"""
Returns a ${f.mapResult} containing the results of applying the given [transform] function
to each ${f.element} and its index in the original ${f.collection}.
@param [transform] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself
and returns the result of the transform applied to the ${f.element}.
"""
}
typeParam("R")
@@ -115,6 +117,8 @@ fun mapping(): List<GenericFunction> {
"""
Returns a ${f.mapResult} containing only the non-null results of applying the given [transform] function
to each ${f.element} and its index in the original ${f.collection}.
@param [transform] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself
and returns the result of the transform applied to the ${f.element}.
"""
}
body {
@@ -158,6 +162,8 @@ fun mapping(): List<GenericFunction> {
"""
Applies the given [transform] function to each ${f.element} and its index in the original ${f.collection}
and appends the results to the given [destination].
@param [transform] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself
and returns the result of the transform applied to the ${f.element}.
"""
}
typeParam("R")
@@ -207,6 +213,8 @@ fun mapping(): List<GenericFunction> {
"""
Applies the given [transform] function to each ${f.element} and its index in the original ${f.collection}
and appends only the non-null results to the given [destination].
@param [transform] function that takes the index of ${f.element.prefixWithArticle()} and the ${f.element} itself
and returns the result of the transform applied to the ${f.element}.
"""
}
body {