From c239d346f7a788762955d069eb81c82fa5075e51 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 20 Apr 2018 23:10:47 +0300 Subject: [PATCH] Correctly indent upper bound separator in the generated stdlib code --- .../stdlib/common/src/generated/_Arrays.kt | 10 +++++----- .../common/src/generated/_Collections.kt | 8 ++++---- .../common/src/generated/_Comparisons.kt | 8 ++++---- .../stdlib/common/src/generated/_Ranges.kt | 10 +++++----- .../stdlib/common/src/generated/_Sequences.kt | 4 ++-- libraries/stdlib/js/src/generated/_ArraysJs.kt | 2 +- .../stdlib/js/src/generated/_ComparisonsJs.kt | 8 ++++---- .../stdlib/jvm/src/generated/_ArraysJvm.kt | 4 ++-- .../jvm/src/generated/_CollectionsJvm.kt | 2 +- .../jvm/src/generated/_ComparisonsJvm.kt | 8 ++++---- .../stdlib/jvm/src/generated/_SequencesJvm.kt | 2 +- .../src/templates/Aggregates.kt | 8 ++++---- .../kotlin-stdlib-gen/src/templates/Arrays.kt | 2 +- .../src/templates/Comparables.kt | 18 +++++++++--------- .../src/templates/Snapshots.kt | 2 +- 15 files changed, 48 insertions(+), 48 deletions(-) diff --git a/libraries/stdlib/common/src/generated/_Arrays.kt b/libraries/stdlib/common/src/generated/_Arrays.kt index 03d569595e4..0e3d039c717 100644 --- a/libraries/stdlib/common/src/generated/_Arrays.kt +++ b/libraries/stdlib/common/src/generated/_Arrays.kt @@ -6139,7 +6139,7 @@ public expect fun CharArray.sort(): Unit /** * Sorts the array in-place according to the natural order of its elements. */ -public expect fun > Array.sort(): Unit +public expect fun > Array.sort(): Unit /** * Sorts the array in-place according to the order specified by the given [comparator]. @@ -11304,7 +11304,7 @@ public inline fun CharArray.none(predicate: (Char) -> Boolean): Boolean { /** * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. */ -public inline fun Array.reduce(operation: (acc: S, T) -> S): S { +public inline fun Array.reduce(operation: (acc: S, T) -> S): S { if (isEmpty()) throw UnsupportedOperationException("Empty array can't be reduced.") var accumulator: S = this[0] @@ -11424,7 +11424,7 @@ public inline fun CharArray.reduce(operation: (acc: Char, Char) -> Char): Char { * @param [operation] function that takes the index of an element, current accumulator value * and the element itself and calculates the next accumulator value. */ -public inline fun Array.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S { +public inline fun Array.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S { if (isEmpty()) throw UnsupportedOperationException("Empty array can't be reduced.") var accumulator: S = this[0] @@ -11565,7 +11565,7 @@ public inline fun CharArray.reduceIndexed(operation: (index: Int, acc: Char, Cha /** * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. */ -public inline fun Array.reduceRight(operation: (T, acc: S) -> S): S { +public inline fun Array.reduceRight(operation: (T, acc: S) -> S): S { var index = lastIndex if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.") var accumulator: S = get(index--) @@ -11685,7 +11685,7 @@ public inline fun CharArray.reduceRight(operation: (Char, acc: Char) -> Char): C * @param [operation] function that takes the index of an element, the element itself * and current accumulator value, and calculates the next accumulator value. */ -public inline fun Array.reduceRightIndexed(operation: (index: Int, T, acc: S) -> S): S { +public inline fun Array.reduceRightIndexed(operation: (index: Int, T, acc: S) -> S): S { var index = lastIndex if (index < 0) throw UnsupportedOperationException("Empty array can't be reduced.") var accumulator: S = get(index--) diff --git a/libraries/stdlib/common/src/generated/_Collections.kt b/libraries/stdlib/common/src/generated/_Collections.kt index 582d0da9552..e4b5e2c5131 100644 --- a/libraries/stdlib/common/src/generated/_Collections.kt +++ b/libraries/stdlib/common/src/generated/_Collections.kt @@ -1698,7 +1698,7 @@ public inline fun > C.onEach(action: (T) -> Unit): C { /** * Accumulates value starting with the first element and applying [operation] from left to right to current accumulator value and each element. */ -public inline fun Iterable.reduce(operation: (acc: S, T) -> S): S { +public inline fun Iterable.reduce(operation: (acc: S, T) -> S): S { val iterator = this.iterator() if (!iterator.hasNext()) throw UnsupportedOperationException("Empty collection can't be reduced.") var accumulator: S = iterator.next() @@ -1714,7 +1714,7 @@ public inline fun Iterable.reduce(operation: (acc: S, T) -> S): S { * @param [operation] function that takes the index of an element, current accumulator value * and the element itself and calculates the next accumulator value. */ -public inline fun Iterable.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S { +public inline fun Iterable.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S { val iterator = this.iterator() if (!iterator.hasNext()) throw UnsupportedOperationException("Empty collection can't be reduced.") var index = 1 @@ -1728,7 +1728,7 @@ public inline fun Iterable.reduceIndexed(operation: (index: Int, ac /** * Accumulates value starting with last element and applying [operation] from right to left to each element and current accumulator value. */ -public inline fun List.reduceRight(operation: (T, acc: S) -> S): S { +public inline fun List.reduceRight(operation: (T, acc: S) -> S): S { val iterator = listIterator(size) if (!iterator.hasPrevious()) throw UnsupportedOperationException("Empty list can't be reduced.") @@ -1745,7 +1745,7 @@ public inline fun List.reduceRight(operation: (T, acc: S) -> S): S * @param [operation] function that takes the index of an element, the element itself * and current accumulator value, and calculates the next accumulator value. */ -public inline fun List.reduceRightIndexed(operation: (index: Int, T, acc: S) -> S): S { +public inline fun List.reduceRightIndexed(operation: (index: Int, T, acc: S) -> S): S { val iterator = listIterator(size) if (!iterator.hasPrevious()) throw UnsupportedOperationException("Empty list can't be reduced.") diff --git a/libraries/stdlib/common/src/generated/_Comparisons.kt b/libraries/stdlib/common/src/generated/_Comparisons.kt index de68cee4a85..b05ef1eb44b 100644 --- a/libraries/stdlib/common/src/generated/_Comparisons.kt +++ b/libraries/stdlib/common/src/generated/_Comparisons.kt @@ -17,7 +17,7 @@ import kotlin.comparisons.* * If values are equal, returns the first one. */ @SinceKotlin("1.1") -public expect fun > maxOf(a: T, b: T): T +public expect fun > maxOf(a: T, b: T): T /** * Returns the greater of two values. @@ -65,7 +65,7 @@ public expect inline fun maxOf(a: Double, b: Double): Double * Returns the greater of three values. */ @SinceKotlin("1.1") -public expect fun > maxOf(a: T, b: T, c: T): T +public expect fun > maxOf(a: T, b: T, c: T): T /** * Returns the greater of three values. @@ -131,7 +131,7 @@ public fun maxOf(a: T, b: T, comparator: Comparator): T { * If values are equal, returns the first one. */ @SinceKotlin("1.1") -public expect fun > minOf(a: T, b: T): T +public expect fun > minOf(a: T, b: T): T /** * Returns the smaller of two values. @@ -179,7 +179,7 @@ public expect inline fun minOf(a: Double, b: Double): Double * Returns the smaller of three values. */ @SinceKotlin("1.1") -public expect fun > minOf(a: T, b: T, c: T): T +public expect fun > minOf(a: T, b: T, c: T): T /** * Returns the smaller of three values. diff --git a/libraries/stdlib/common/src/generated/_Ranges.kt b/libraries/stdlib/common/src/generated/_Ranges.kt index c152fc14dc4..d164d5c2003 100644 --- a/libraries/stdlib/common/src/generated/_Ranges.kt +++ b/libraries/stdlib/common/src/generated/_Ranges.kt @@ -707,7 +707,7 @@ public infix fun Short.until(to: Short): IntRange { * * @sample samples.comparisons.ComparableOps.coerceAtLeastComparable */ -public fun > T.coerceAtLeast(minimumValue: T): T { +public fun > T.coerceAtLeast(minimumValue: T): T { return if (this < minimumValue) minimumValue else this } @@ -784,7 +784,7 @@ public fun Double.coerceAtLeast(minimumValue: Double): Double { * * @sample samples.comparisons.ComparableOps.coerceAtMostComparable */ -public fun > T.coerceAtMost(maximumValue: T): T { +public fun > T.coerceAtMost(maximumValue: T): T { return if (this > maximumValue) maximumValue else this } @@ -861,7 +861,7 @@ public fun Double.coerceAtMost(maximumValue: Double): Double { * * @sample samples.comparisons.ComparableOps.coerceInComparable */ -public fun > T.coerceIn(minimumValue: T?, maximumValue: T?): T { +public fun > T.coerceIn(minimumValue: T?, maximumValue: T?): T { if (minimumValue !== null && maximumValue !== null) { if (minimumValue > maximumValue) throw IllegalArgumentException("Cannot coerce value to an empty range: maximum $maximumValue is less than minimum $minimumValue.") if (this < minimumValue) return minimumValue @@ -966,7 +966,7 @@ public fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double { * @sample samples.comparisons.ComparableOps.coerceInFloatingPointRange */ @SinceKotlin("1.1") -public fun > T.coerceIn(range: ClosedFloatingPointRange): T { +public fun > T.coerceIn(range: ClosedFloatingPointRange): T { if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.") return when { // this < start equiv to this <= start && !(this >= start) @@ -984,7 +984,7 @@ public fun > T.coerceIn(range: ClosedFloatingPointRange): T * * @sample samples.comparisons.ComparableOps.coerceInComparable */ -public fun > T.coerceIn(range: ClosedRange): T { +public fun > T.coerceIn(range: ClosedRange): T { if (range is ClosedFloatingPointRange) { return this.coerceIn(range) } diff --git a/libraries/stdlib/common/src/generated/_Sequences.kt b/libraries/stdlib/common/src/generated/_Sequences.kt index 43e19f1acf8..2e664c58505 100644 --- a/libraries/stdlib/common/src/generated/_Sequences.kt +++ b/libraries/stdlib/common/src/generated/_Sequences.kt @@ -1264,7 +1264,7 @@ public fun Sequence.onEach(action: (T) -> Unit): Sequence { * * The operation is _terminal_. */ -public inline fun Sequence.reduce(operation: (acc: S, T) -> S): S { +public inline fun Sequence.reduce(operation: (acc: S, T) -> S): S { val iterator = this.iterator() if (!iterator.hasNext()) throw UnsupportedOperationException("Empty sequence can't be reduced.") var accumulator: S = iterator.next() @@ -1282,7 +1282,7 @@ public inline fun Sequence.reduce(operation: (acc: S, T) -> S): S { * * The operation is _terminal_. */ -public inline fun Sequence.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S { +public inline fun Sequence.reduceIndexed(operation: (index: Int, acc: S, T) -> S): S { val iterator = this.iterator() if (!iterator.hasNext()) throw UnsupportedOperationException("Empty sequence can't be reduced.") var index = 1 diff --git a/libraries/stdlib/js/src/generated/_ArraysJs.kt b/libraries/stdlib/js/src/generated/_ArraysJs.kt index e59bc2f669e..b0e45391012 100644 --- a/libraries/stdlib/js/src/generated/_ArraysJs.kt +++ b/libraries/stdlib/js/src/generated/_ArraysJs.kt @@ -879,7 +879,7 @@ public actual fun CharArray.sort(): Unit { /** * Sorts the array in-place according to the natural order of its elements. */ -public actual fun > Array.sort(): Unit { +public actual fun > Array.sort(): Unit { if (size > 1) sort { a: T, b: T -> a.compareTo(b) } } diff --git a/libraries/stdlib/js/src/generated/_ComparisonsJs.kt b/libraries/stdlib/js/src/generated/_ComparisonsJs.kt index ca49c474a66..3855e402848 100644 --- a/libraries/stdlib/js/src/generated/_ComparisonsJs.kt +++ b/libraries/stdlib/js/src/generated/_ComparisonsJs.kt @@ -18,7 +18,7 @@ import kotlin.comparisons.* * If values are equal, returns the first one. */ @SinceKotlin("1.1") -public actual fun > maxOf(a: T, b: T): T { +public actual fun > maxOf(a: T, b: T): T { return if (a >= b) a else b } @@ -80,7 +80,7 @@ public actual inline fun maxOf(a: Double, b: Double): Double { * Returns the greater of three values. */ @SinceKotlin("1.1") -public actual fun > maxOf(a: T, b: T, c: T): T { +public actual fun > maxOf(a: T, b: T, c: T): T { return maxOf(a, maxOf(b, c)) } @@ -143,7 +143,7 @@ public actual inline fun maxOf(a: Double, b: Double, c: Double): Double { * If values are equal, returns the first one. */ @SinceKotlin("1.1") -public actual fun > minOf(a: T, b: T): T { +public actual fun > minOf(a: T, b: T): T { return if (a <= b) a else b } @@ -205,7 +205,7 @@ public actual inline fun minOf(a: Double, b: Double): Double { * Returns the smaller of three values. */ @SinceKotlin("1.1") -public actual fun > minOf(a: T, b: T, c: T): T { +public actual fun > minOf(a: T, b: T, c: T): T { return minOf(a, minOf(b, c)) } diff --git a/libraries/stdlib/jvm/src/generated/_ArraysJvm.kt b/libraries/stdlib/jvm/src/generated/_ArraysJvm.kt index 4df8353083e..a4307307ae7 100644 --- a/libraries/stdlib/jvm/src/generated/_ArraysJvm.kt +++ b/libraries/stdlib/jvm/src/generated/_ArraysJvm.kt @@ -1212,7 +1212,7 @@ public actual fun CharArray.sort(): Unit { * Sorts the array in-place according to the natural order of its elements. */ @kotlin.internal.InlineOnly -public actual inline fun > Array.sort(): Unit { +public actual inline fun > Array.sort(): Unit { @Suppress("UNCHECKED_CAST") (this as Array).sort() } @@ -1387,7 +1387,7 @@ public actual fun CharArray.toTypedArray(): Array { /** * Returns a [SortedSet][java.util.SortedSet] of all elements. */ -public fun > Array.toSortedSet(): java.util.SortedSet { +public fun > Array.toSortedSet(): java.util.SortedSet { return toCollection(java.util.TreeSet()) } diff --git a/libraries/stdlib/jvm/src/generated/_CollectionsJvm.kt b/libraries/stdlib/jvm/src/generated/_CollectionsJvm.kt index 56bf6b51668..7dfddca8092 100644 --- a/libraries/stdlib/jvm/src/generated/_CollectionsJvm.kt +++ b/libraries/stdlib/jvm/src/generated/_CollectionsJvm.kt @@ -39,7 +39,7 @@ public actual fun MutableList.reverse(): Unit { /** * Returns a [SortedSet][java.util.SortedSet] of all elements. */ -public fun > Iterable.toSortedSet(): java.util.SortedSet { +public fun > Iterable.toSortedSet(): java.util.SortedSet { return toCollection(java.util.TreeSet()) } diff --git a/libraries/stdlib/jvm/src/generated/_ComparisonsJvm.kt b/libraries/stdlib/jvm/src/generated/_ComparisonsJvm.kt index ebf7801e9bc..6920f23e745 100644 --- a/libraries/stdlib/jvm/src/generated/_ComparisonsJvm.kt +++ b/libraries/stdlib/jvm/src/generated/_ComparisonsJvm.kt @@ -18,7 +18,7 @@ import kotlin.comparisons.* * If values are equal, returns the first one. */ @SinceKotlin("1.1") -public actual fun > maxOf(a: T, b: T): T { +public actual fun > maxOf(a: T, b: T): T { return if (a >= b) a else b } @@ -80,7 +80,7 @@ public actual inline fun maxOf(a: Double, b: Double): Double { * Returns the greater of three values. */ @SinceKotlin("1.1") -public actual fun > maxOf(a: T, b: T, c: T): T { +public actual fun > maxOf(a: T, b: T, c: T): T { return maxOf(a, maxOf(b, c)) } @@ -143,7 +143,7 @@ public actual inline fun maxOf(a: Double, b: Double, c: Double): Double { * If values are equal, returns the first one. */ @SinceKotlin("1.1") -public actual fun > minOf(a: T, b: T): T { +public actual fun > minOf(a: T, b: T): T { return if (a <= b) a else b } @@ -205,7 +205,7 @@ public actual inline fun minOf(a: Double, b: Double): Double { * Returns the smaller of three values. */ @SinceKotlin("1.1") -public actual fun > minOf(a: T, b: T, c: T): T { +public actual fun > minOf(a: T, b: T, c: T): T { return minOf(a, minOf(b, c)) } diff --git a/libraries/stdlib/jvm/src/generated/_SequencesJvm.kt b/libraries/stdlib/jvm/src/generated/_SequencesJvm.kt index 955c8225f64..0364f6d3d0c 100644 --- a/libraries/stdlib/jvm/src/generated/_SequencesJvm.kt +++ b/libraries/stdlib/jvm/src/generated/_SequencesJvm.kt @@ -40,7 +40,7 @@ public fun , R> Sequence<*>.filterIsInstanceTo(desti * * The operation is _terminal_. */ -public fun > Sequence.toSortedSet(): java.util.SortedSet { +public fun > Sequence.toSortedSet(): java.util.SortedSet { return toCollection(java.util.TreeSet()) } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt index 2e3977db19b..2c76ee6bed8 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt @@ -625,7 +625,7 @@ object Aggregates : TemplateGroupBase() { """ } typeParam("S") - typeParam("T: S") + typeParam("T : S") returns("S") body { """ @@ -698,7 +698,7 @@ object Aggregates : TemplateGroupBase() { """ } typeParam("S") - typeParam("T: S") + typeParam("T : S") returns("S") body { """ @@ -759,7 +759,7 @@ object Aggregates : TemplateGroupBase() { doc { "Accumulates value starting with the first ${f.element} and applying [operation] from left to right to current accumulator value and each ${f.element}." } typeParam("S") - typeParam("T: S") + typeParam("T : S") returns("S") body { """ @@ -815,7 +815,7 @@ object Aggregates : TemplateGroupBase() { inline() doc { "Accumulates value starting with last ${f.element} and applying [operation] from right to left to each ${f.element} and current accumulator value." } typeParam("S") - typeParam("T: S") + typeParam("T : S") returns("S") body { """ diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt index 3caa3811964..edb730c34d5 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Arrays.kt @@ -496,7 +496,7 @@ object ArrayOps : TemplateGroupBase() { include(ArraysOfPrimitives, PrimitiveType.numericPrimitives + PrimitiveType.Char) include(ArraysOfObjects) } builder { - typeParam("T: Comparable") + typeParam("T : Comparable") doc { "Sorts the array in-place according to the natural order of its elements." } specialFor(ArraysOfPrimitives) { doc { "Sorts the array in-place." } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt index 64a8a1cb1d5..6b19faf8ef1 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt @@ -30,7 +30,7 @@ object ComparableOps : TemplateGroupBase() { } builder { sourceFile(SourceFile.Ranges) returns("SELF") - typeParam("T: Comparable") + typeParam("T : Comparable") doc { """ Ensures that this value is not less than the specified [minimumValue]. @@ -52,7 +52,7 @@ object ComparableOps : TemplateGroupBase() { } builder { sourceFile(SourceFile.Ranges) returns("SELF") - typeParam("T: Comparable") + typeParam("T : Comparable") doc { """ Ensures that this value is not greater than the specified [maximumValue]. @@ -74,7 +74,7 @@ object ComparableOps : TemplateGroupBase() { } builder { sourceFile(SourceFile.Ranges) returns("SELF") - typeParam("T: Comparable") + typeParam("T : Comparable") doc { """ Ensures that this value lies in the specified [range]. @@ -117,7 +117,7 @@ object ComparableOps : TemplateGroupBase() { sourceFile(SourceFile.Ranges) since("1.1") returns("SELF") - typeParam("T: Comparable") + typeParam("T : Comparable") doc { """ Ensures that this value lies in the specified [range]. @@ -147,7 +147,7 @@ object ComparableOps : TemplateGroupBase() { } builder { sourceFile(SourceFile.Comparisons) since("1.1") - typeParam("T: Comparable") + typeParam("T : Comparable") returns("T") receiver("") doc { @@ -191,7 +191,7 @@ object ComparableOps : TemplateGroupBase() { } builder { sourceFile(SourceFile.Comparisons) since("1.1") - typeParam("T: Comparable") + typeParam("T : Comparable") returns("T") receiver("") specialFor(Primitives) { inlineOnly() } @@ -261,7 +261,7 @@ object ComparableOps : TemplateGroupBase() { } builder { sourceFile(SourceFile.Comparisons) since("1.1") - typeParam("T: Comparable") + typeParam("T : Comparable") returns("T") receiver("") doc { @@ -305,7 +305,7 @@ object ComparableOps : TemplateGroupBase() { } builder { sourceFile(SourceFile.Comparisons) since("1.1") - typeParam("T: Comparable") + typeParam("T : Comparable") returns("T") receiver("") specialFor(Primitives) { inlineOnly() } @@ -377,7 +377,7 @@ object ComparableOps : TemplateGroupBase() { sourceFile(SourceFile.Ranges) specialFor(Generic) { signature("coerceIn(minimumValue: SELF?, maximumValue: SELF?)", notForSorting = true) } - typeParam("T: Comparable") + typeParam("T : Comparable") returns("SELF") doc { """ diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt index bf7dbaa6ceb..7e5e1ce31cb 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt @@ -99,7 +99,7 @@ object Snapshots : TemplateGroupBase() { include(CharSequences) platforms(Platform.JVM) } builder { - typeParam("T: Comparable") + typeParam("T : Comparable") doc { "Returns a [SortedSet][java.util.SortedSet] of all ${f.element.pluralize()}." } returns("java.util.SortedSet") body { "return toCollection(java.util.TreeSet())" }