Rearrange stdlib between files and folders, rename files to better represent their content.
Fix package part name in testData
This commit is contained in:
@@ -22,7 +22,7 @@ fun main(args: Array<String>) {
|
|||||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evDelegatedProperty.kt, 9)
|
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evDelegatedProperty.kt, 9)
|
||||||
local = a: evDelegatedProperty.A = {evDelegatedProperty.A@uniqueID} (sp = evDelegatedProperty.kt, 10)
|
local = a: evDelegatedProperty.A = {evDelegatedProperty.A@uniqueID} (sp = evDelegatedProperty.kt, 10)
|
||||||
field = prop$delegate: kotlin.properties.ReadWriteProperty = {kotlin.properties.NotNullVar@uniqueID} (sp = evDelegatedProperty.kt, 6)
|
field = prop$delegate: kotlin.properties.ReadWriteProperty = {kotlin.properties.NotNullVar@uniqueID} (sp = evDelegatedProperty.kt, 6)
|
||||||
field = value: java.lang.Object = {java.lang.Integer@uniqueID}1 (sp = Delegation.!EXT!)
|
field = value: java.lang.Object = {java.lang.Integer@uniqueID}1 (sp = Delegates.!EXT!)
|
||||||
field = value: int = 1 (sp = Integer.!EXT!)
|
field = value: int = 1 (sp = Integer.!EXT!)
|
||||||
field = prop: int = 1 (sp = evDelegatedProperty.kt, 6)
|
field = prop: int = 1 (sp = evDelegatedProperty.kt, 6)
|
||||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
package kotlin.collections
|
package kotlin.collections
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream
|
|
||||||
import java.nio.charset.Charset
|
import java.nio.charset.Charset
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+5
-57
@@ -133,39 +133,13 @@ public inline fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList()
|
|||||||
public inline fun <T> Enumeration<T>.toList(): List<T> = Collections.list(this)
|
public inline fun <T> Enumeration<T>.toList(): List<T> = Collections.list(this)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the size of this iterable if it is known, or `null` otherwise.
|
* Checks if all elements in the specified collection are contained in this collection.
|
||||||
|
*
|
||||||
|
* Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`.
|
||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineExposed
|
@kotlin.internal.InlineOnly
|
||||||
internal fun <T> Iterable<T>.collectionSizeOrNull(): Int? = if (this is Collection<*>) this.size else null
|
public inline fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(elements: Collection<T>): Boolean = this.containsAll(elements)
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the size of this iterable if it is known, or the specified [default] value otherwise.
|
|
||||||
*/
|
|
||||||
@kotlin.internal.InlineExposed
|
|
||||||
internal fun <T> Iterable<T>.collectionSizeOrDefault(default: Int): Int = if (this is Collection<*>) this.size else default
|
|
||||||
|
|
||||||
/** Returns true when it's safe to convert this collection to a set without changing contains method behavior. */
|
|
||||||
private fun <T> Collection<T>.safeToConvertToSet() = size > 2 && this is ArrayList
|
|
||||||
|
|
||||||
/** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */
|
|
||||||
internal fun <T> Iterable<T>.convertToSetForSetOperationWith(source: Iterable<T>): Collection<T> =
|
|
||||||
when(this) {
|
|
||||||
is Set -> this
|
|
||||||
is Collection ->
|
|
||||||
when {
|
|
||||||
source is Collection && source.size < 2 -> this
|
|
||||||
else -> if (this.safeToConvertToSet()) toHashSet() else this
|
|
||||||
}
|
|
||||||
else -> toHashSet()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */
|
|
||||||
internal fun <T> Iterable<T>.convertToSetForSetOperation(): Collection<T> =
|
|
||||||
when(this) {
|
|
||||||
is Set -> this
|
|
||||||
is Collection -> if (this.safeToConvertToSet()) toHashSet() else this
|
|
||||||
else -> toHashSet()
|
|
||||||
}
|
|
||||||
|
|
||||||
// copies typed varargs array to array of objects
|
// copies typed varargs array to array of objects
|
||||||
@JvmVersion
|
@JvmVersion
|
||||||
@@ -278,30 +252,4 @@ private fun rangeCheck(size: Int, fromIndex: Int, toIndex: Int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a single list of all elements from all collections in the given collection.
|
|
||||||
*/
|
|
||||||
public fun <T> Iterable<Iterable<T>>.flatten(): List<T> {
|
|
||||||
val result = ArrayList<T>()
|
|
||||||
for (element in this) {
|
|
||||||
result.addAll(element)
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a pair of lists, where
|
|
||||||
* *first* list is built from the first values of each pair from this collection,
|
|
||||||
* *second* list is built from the second values of each pair from this collection.
|
|
||||||
*/
|
|
||||||
public fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> {
|
|
||||||
val expectedSize = collectionSizeOrDefault(10)
|
|
||||||
val listT = ArrayList<T>(expectedSize)
|
|
||||||
val listR = ArrayList<R>(expectedSize)
|
|
||||||
for (pair in this) {
|
|
||||||
listT.add(pair.first)
|
|
||||||
listR.add(pair.second)
|
|
||||||
}
|
|
||||||
return listT to listR
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package kotlin.collections
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data class representing a value from a collection or sequence, along with its index in that collection or sequence.
|
||||||
|
*
|
||||||
|
* @property value the underlying value.
|
||||||
|
* @property index the index of the value in the collection or sequence.
|
||||||
|
*/
|
||||||
|
public data class IndexedValue<out T>(public val index: Int, public val value: T)
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package kotlin.collections
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data class representing a value from a collection or sequence, along with its index in that collection or sequence.
|
|
||||||
*
|
|
||||||
* @property value the underlying value.
|
|
||||||
* @property index the index of the value in the collection or sequence.
|
|
||||||
*/
|
|
||||||
public data class IndexedValue<out T>(public val index: Int, public val value: T)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A wrapper over another [Iterable] (or any other object that can produce an [Iterator]) that returns
|
|
||||||
* an indexing iterator.
|
|
||||||
*/
|
|
||||||
internal class IndexingIterable<out T>(private val iteratorFactory: () -> Iterator<T>) : Iterable<IndexedValue<T>> {
|
|
||||||
override fun iterator(): Iterator<IndexedValue<T>> = IndexingIterator(iteratorFactory())
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Iterator transforming original `iterator` into iterator of [IndexedValue], counting index from zero.
|
|
||||||
*/
|
|
||||||
internal class IndexingIterator<out T>(private val iterator: Iterator<T>) : Iterator<IndexedValue<T>> {
|
|
||||||
private var index = 0
|
|
||||||
final override fun hasNext(): Boolean = iterator.hasNext()
|
|
||||||
final override fun next(): IndexedValue<T> = IndexedValue(index++, iterator.next())
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
@file:kotlin.jvm.JvmMultifileClass
|
||||||
|
@file:kotlin.jvm.JvmName("CollectionsKt")
|
||||||
|
package kotlin.collections
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A wrapper over another [Iterable] (or any other object that can produce an [Iterator]) that returns
|
||||||
|
* an indexing iterator.
|
||||||
|
*/
|
||||||
|
internal class IndexingIterable<out T>(private val iteratorFactory: () -> Iterator<T>) : Iterable<IndexedValue<T>> {
|
||||||
|
override fun iterator(): Iterator<IndexedValue<T>> = IndexingIterator(iteratorFactory())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of this iterable if it is known, or `null` otherwise.
|
||||||
|
*/
|
||||||
|
@kotlin.internal.InlineExposed
|
||||||
|
internal fun <T> Iterable<T>.collectionSizeOrNull(): Int? = if (this is Collection<*>) this.size else null
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the size of this iterable if it is known, or the specified [default] value otherwise.
|
||||||
|
*/
|
||||||
|
@kotlin.internal.InlineExposed
|
||||||
|
internal fun <T> Iterable<T>.collectionSizeOrDefault(default: Int): Int = if (this is Collection<*>) this.size else default
|
||||||
|
|
||||||
|
/** Returns true when it's safe to convert this collection to a set without changing contains method behavior. */
|
||||||
|
private fun <T> Collection<T>.safeToConvertToSet() = size > 2 && this is ArrayList
|
||||||
|
|
||||||
|
/** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */
|
||||||
|
internal fun <T> Iterable<T>.convertToSetForSetOperationWith(source: Iterable<T>): Collection<T> =
|
||||||
|
when(this) {
|
||||||
|
is Set -> this
|
||||||
|
is Collection ->
|
||||||
|
when {
|
||||||
|
source is Collection && source.size < 2 -> this
|
||||||
|
else -> if (this.safeToConvertToSet()) toHashSet() else this
|
||||||
|
}
|
||||||
|
else -> toHashSet()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Converts this collection to a set, when it's worth so and it doesn't change contains method behavior. */
|
||||||
|
internal fun <T> Iterable<T>.convertToSetForSetOperation(): Collection<T> =
|
||||||
|
when(this) {
|
||||||
|
is Set -> this
|
||||||
|
is Collection -> if (this.safeToConvertToSet()) toHashSet() else this
|
||||||
|
else -> toHashSet()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a single list of all elements from all collections in the given collection.
|
||||||
|
*/
|
||||||
|
public fun <T> Iterable<Iterable<T>>.flatten(): List<T> {
|
||||||
|
val result = ArrayList<T>()
|
||||||
|
for (element in this) {
|
||||||
|
result.addAll(element)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a pair of lists, where
|
||||||
|
* *first* list is built from the first values of each pair from this collection,
|
||||||
|
* *second* list is built from the second values of each pair from this collection.
|
||||||
|
*/
|
||||||
|
public fun <T, R> Iterable<Pair<T, R>>.unzip(): Pair<List<T>, List<R>> {
|
||||||
|
val expectedSize = collectionSizeOrDefault(10)
|
||||||
|
val listT = ArrayList<T>(expectedSize)
|
||||||
|
val listR = ArrayList<R>(expectedSize)
|
||||||
|
for (pair in this) {
|
||||||
|
listT.add(pair.first)
|
||||||
|
listR.add(pair.second)
|
||||||
|
}
|
||||||
|
return listT to listR
|
||||||
|
}
|
||||||
@@ -33,3 +33,11 @@ public inline fun <T> Iterator<T>.forEach(operation: (T) -> Unit) : Unit {
|
|||||||
for (element in this) operation(element)
|
for (element in this) operation(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterator transforming original `iterator` into iterator of [IndexedValue], counting index from zero.
|
||||||
|
*/
|
||||||
|
internal class IndexingIterator<out T>(private val iterator: Iterator<T>) : Iterator<IndexedValue<T>> {
|
||||||
|
private var index = 0
|
||||||
|
final override fun hasNext(): Boolean = iterator.hasNext()
|
||||||
|
final override fun next(): IndexedValue<T> = IndexedValue(index++, iterator.next())
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,14 +5,6 @@ package kotlin.collections
|
|||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if all elements in the specified collection are contained in this collection.
|
|
||||||
*
|
|
||||||
* Allows to overcome type-safety restriction of `containsAll` that requires to pass a collection of type `Collection<E>`.
|
|
||||||
*/
|
|
||||||
@kotlin.internal.InlineOnly
|
|
||||||
public inline fun <@kotlin.internal.OnlyInputTypes T> Collection<T>.containsAll(elements: Collection<T>): Boolean = this.containsAll(elements)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a single instance of the specified element from this
|
* Removes a single instance of the specified element from this
|
||||||
* collection, if it is present.
|
* collection, if it is present.
|
||||||
|
|||||||
-35
@@ -1,6 +1,5 @@
|
|||||||
package kotlin.properties
|
package kotlin.properties
|
||||||
|
|
||||||
import java.util.NoSuchElementException
|
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,37 +53,3 @@ private class NotNullVar<T: Any>() : ReadWriteProperty<Any?, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements the core logic of a property delegate for a read/write property that calls callback functions when changed.
|
|
||||||
* @param initialValue the initial value of the property.
|
|
||||||
*/
|
|
||||||
public abstract class ObservableProperty<T>(initialValue: T) : ReadWriteProperty<Any?, T> {
|
|
||||||
private var value = initialValue
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The callback which is called before a change to the property value is attempted.
|
|
||||||
* The value of the property hasn't been changed yet, when this callback is invoked.
|
|
||||||
* If the callback returns `true` the value of the property is being set to the new value,
|
|
||||||
* and if the callback returns `false` the new value is discarded and the property remains its old value.
|
|
||||||
*/
|
|
||||||
protected open fun beforeChange(property: KProperty<*>, oldValue: T, newValue: T): Boolean = true
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The callback which is called after the change of the property is made. The value of the property
|
|
||||||
* has already been changed when this callback is invoked.
|
|
||||||
*/
|
|
||||||
protected open fun afterChange (property: KProperty<*>, oldValue: T, newValue: T): Unit {}
|
|
||||||
|
|
||||||
public override fun getValue(thisRef: Any?, property: KProperty<*>): T {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
public override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
|
|
||||||
val oldValue = this.value
|
|
||||||
if (!beforeChange(property, oldValue, value)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.value = value
|
|
||||||
afterChange(property, oldValue, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package kotlin.properties
|
||||||
|
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the core logic of a property delegate for a read/write property that calls callback functions when changed.
|
||||||
|
* @param initialValue the initial value of the property.
|
||||||
|
*/
|
||||||
|
public abstract class ObservableProperty<T>(initialValue: T) : ReadWriteProperty<Any?, T> {
|
||||||
|
private var value = initialValue
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The callback which is called before a change to the property value is attempted.
|
||||||
|
* The value of the property hasn't been changed yet, when this callback is invoked.
|
||||||
|
* If the callback returns `true` the value of the property is being set to the new value,
|
||||||
|
* and if the callback returns `false` the new value is discarded and the property remains its old value.
|
||||||
|
*/
|
||||||
|
protected open fun beforeChange(property: KProperty<*>, oldValue: T, newValue: T): Boolean = true
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The callback which is called after the change of the property is made. The value of the property
|
||||||
|
* has already been changed when this callback is invoked.
|
||||||
|
*/
|
||||||
|
protected open fun afterChange (property: KProperty<*>, oldValue: T, newValue: T): Unit {}
|
||||||
|
|
||||||
|
public override fun getValue(thisRef: Any?, property: KProperty<*>): T {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
|
||||||
|
val oldValue = this.value
|
||||||
|
if (!beforeChange(property, oldValue, value)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.value = value
|
||||||
|
afterChange(property, oldValue, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
@file:JvmVersion
|
||||||
package kotlin.text
|
package kotlin.text
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
@file:JvmVersion
|
||||||
package kotlin.text
|
package kotlin.text
|
||||||
|
|
||||||
/**
|
/**
|
||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
@file:JvmName("CharsetsKt")
|
@file:JvmName("CharsetsKt")
|
||||||
|
@file:JvmVersion
|
||||||
package kotlin.text
|
package kotlin.text
|
||||||
|
|
||||||
import java.nio.charset.*
|
import java.nio.charset.*
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
@file:kotlin.jvm.JvmMultifileClass
|
@file:kotlin.jvm.JvmMultifileClass
|
||||||
@file:kotlin.jvm.JvmName("StringsKt")
|
@file:kotlin.jvm.JvmName("StringsKt")
|
||||||
|
@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||||
|
|
||||||
package kotlin.text
|
package kotlin.text
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
@file:JvmVersion
|
||||||
package kotlin.text
|
package kotlin.text
|
||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|||||||
+1
@@ -1,5 +1,6 @@
|
|||||||
@file:kotlin.jvm.JvmMultifileClass
|
@file:kotlin.jvm.JvmMultifileClass
|
||||||
@file:kotlin.jvm.JvmName("ExceptionsKt")
|
@file:kotlin.jvm.JvmName("ExceptionsKt")
|
||||||
|
@file:kotlin.jvm.JvmVersion
|
||||||
@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||||
package kotlin
|
package kotlin
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
@file:kotlin.jvm.JvmMultifileClass
|
|
||||||
@file:kotlin.jvm.JvmName("StandardKt")
|
|
||||||
package kotlin
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes the given function [action] specified number of [times].
|
|
||||||
*
|
|
||||||
* A zero-based index of current iteration is passed as a parameter to [action].
|
|
||||||
*/
|
|
||||||
@kotlin.internal.InlineOnly
|
|
||||||
public inline fun repeat(times: Int, action: (Int) -> Unit) {
|
|
||||||
for (index in 0..times - 1) {
|
|
||||||
action(index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -53,3 +53,16 @@ public inline fun <T> T.apply(block: T.() -> Unit): T { block(); return this }
|
|||||||
*/
|
*/
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun <T, R> T.let(block: (T) -> R): R = block(this)
|
public inline fun <T, R> T.let(block: (T) -> R): R = block(this)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the given function [action] specified number of [times].
|
||||||
|
*
|
||||||
|
* A zero-based index of current iteration is passed as a parameter to [action].
|
||||||
|
*/
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public inline fun repeat(times: Int, action: (Int) -> Unit) {
|
||||||
|
for (index in 0..times - 1) {
|
||||||
|
action(index)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user