diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index d4da6b525fa..9f07da8aaf8 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -90,7 +90,7 @@ public fun Iterable.elementAt(index: Int): T { } /** - * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this collection. + * Returns an element at the given [index] or throws an [IndexOutOfBoundsException] if the [index] is out of bounds of this list. */ public fun List.elementAt(index: Int): T { return get(index) @@ -115,7 +115,7 @@ public fun Iterable.elementAtOrElse(index: Int, defaultValue: (Int) -> T) } /** - * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list. */ public inline fun List.elementAtOrElse(index: Int, defaultValue: (Int) -> T): T { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) @@ -140,7 +140,7 @@ public fun Iterable.elementAtOrNull(index: Int): T? { } /** - * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list. */ public fun List.elementAtOrNull(index: Int): T? { return if (index >= 0 && index <= lastIndex) get(index) else null @@ -190,7 +190,7 @@ public fun Iterable.first(): T { /** * Returns first element. - * @throws [NoSuchElementException] if the collection is empty. + * @throws [NoSuchElementException] if the list is empty. */ public fun List.first(): T { if (isEmpty()) @@ -228,7 +228,7 @@ public fun Iterable.firstOrNull(): T? { } /** - * Returns the first element, or `null` if the collection is empty. + * Returns the first element, or `null` if the list is empty. */ public fun List.firstOrNull(): T? { return if (isEmpty()) null else this[0] @@ -243,14 +243,14 @@ public inline fun Iterable.firstOrNull(predicate: (T) -> Boolean): T? { } /** - * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this collection. + * Returns an element at the given [index] or the result of calling the [defaultValue] function if the [index] is out of bounds of this list. */ public inline fun List.getOrElse(index: Int, defaultValue: (Int) -> T): T { return if (index >= 0 && index <= lastIndex) get(index) else defaultValue(index) } /** - * Returns an element at the given [index] or `null` if the [index] is out of bounds of this collection. + * Returns an element at the given [index] or `null` if the [index] is out of bounds of this list. */ public fun List.getOrNull(index: Int): T? { return if (index >= 0 && index <= lastIndex) get(index) else null @@ -295,7 +295,7 @@ public inline fun Iterable.indexOfFirst(predicate: (T) -> Boolean): Int { } /** - * Returns index of the first element matching the given [predicate], or -1 if the collection does not contain such element. + * Returns index of the first element matching the given [predicate], or -1 if the list does not contain such element. */ public inline fun List.indexOfFirst(predicate: (T) -> Boolean): Int { for (index in indices) { @@ -321,7 +321,7 @@ public inline fun Iterable.indexOfLast(predicate: (T) -> Boolean): Int { } /** - * Returns index of the last element matching the given [predicate], or -1 if the collection does not contain such element. + * Returns index of the last element matching the given [predicate], or -1 if the list does not contain such element. */ public inline fun List.indexOfLast(predicate: (T) -> Boolean): Int { for (index in indices.reversed()) { @@ -342,7 +342,7 @@ public inline fun Iterable<*>.indexOfRaw(element: Any?): Int { } /** - * Returns first index of [element], or -1 if the collection does not contain element. + * Returns first index of [element], or -1 if the list does not contain element. * Allows to overcome type-safety restriction of `indexOf` that requires to pass an element of type `T`. */ @Suppress("NOTHING_TO_INLINE") @@ -376,7 +376,7 @@ public fun Iterable.last(): T { /** * Returns the last element. - * @throws [NoSuchElementException] if the collection is empty. + * @throws [NoSuchElementException] if the list is empty. */ public fun List.last(): T { if (isEmpty()) @@ -451,7 +451,7 @@ public inline fun Iterable<*>.lastIndexOfRaw(element: Any?): Int { } /** - * Returns last index of [element], or -1 if the collection does not contain element. + * Returns last index of [element], or -1 if the list does not contain element. * Allows to overcome type-safety restriction of `lastIndexOf` that requires to pass an element of type `T`. */ @Suppress("NOTHING_TO_INLINE") @@ -478,7 +478,7 @@ public fun Iterable.lastOrNull(): T? { } /** - * Returns the last element, or `null` if the collection is empty. + * Returns the last element, or `null` if the list is empty. */ public fun List.lastOrNull(): T? { return if (isEmpty()) null else this[size() - 1] @@ -533,7 +533,7 @@ public fun Iterable.single(): T { } /** - * Returns the single element, or throws an exception if the collection is empty or has more than one element. + * Returns the single element, or throws an exception if the list is empty or has more than one element. */ public fun List.single(): T { return when (size()) { @@ -579,7 +579,7 @@ public fun Iterable.singleOrNull(): T? { } /** - * Returns single element, or `null` if the collection is empty or has more than one element. + * Returns single element, or `null` if the list is empty or has more than one element. */ public fun List.singleOrNull(): T? { return if (size() == 1) this[0] else null diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/DocExtensions.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/DocExtensions.kt index bff2e551955..00acb6a202b 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/DocExtensions.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/DocExtensions.kt @@ -14,10 +14,8 @@ object DocExtensions { val Family.collection: String get() = when (this) { CharSequences -> "char sequence" - Strings -> "string" - Sequences -> "sequence" - Maps -> "map" ArraysOfObjects, ArraysOfPrimitives, InvariantArraysOfObjects -> "array" + Strings, Sequences, Maps, Lists, Sets, Ranges -> name.singularize().decapitalize() else -> "collection" } @@ -27,6 +25,8 @@ object DocExtensions { else -> "list" } + private fun String.singularize() = removeSuffix("s") + fun String.prefixWithArticle() = (if ("aeiou".any { this.startsWith(it, ignoreCase = true) }) "an " else "a ").concat(this) }