From 871c5c66b49a6d490d1d99ef79fca2080aa3a655 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sun, 13 Dec 2015 18:03:20 +0300 Subject: [PATCH] Move code between packages (JS) --- js/js.libraries/src/core/char.kt | 2 +- js/js.libraries/src/core/collections.kt | 37 +++++++++++++++++++ js/js.libraries/src/core/kotlin.kt | 20 ---------- js/js.libraries/src/core/kotlin_special.kt | 2 +- js/js.libraries/src/core/sequence.kt | 2 +- js/js.libraries/src/core/string.kt | 2 +- js/js.libraries/src/core/stringsCode.kt | 3 +- .../src/generators/GenerateStandardLib.kt | 2 +- 8 files changed, 43 insertions(+), 27 deletions(-) create mode 100644 js/js.libraries/src/core/collections.kt diff --git a/js/js.libraries/src/core/char.kt b/js/js.libraries/src/core/char.kt index c87f28050b4..4a6de4a3856 100644 --- a/js/js.libraries/src/core/char.kt +++ b/js/js.libraries/src/core/char.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package kotlin +package kotlin.text // actually \s is enough to match all whitespace, but \xA0 added because of different regexp behavior of Rhino used in Selenium tests public fun Char.isWhitespace(): Boolean = toString().matches("[\\s\\xA0]") diff --git a/js/js.libraries/src/core/collections.kt b/js/js.libraries/src/core/collections.kt new file mode 100644 index 00000000000..3e8e5b36c97 --- /dev/null +++ b/js/js.libraries/src/core/collections.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2015 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. + */ +package kotlin.collections + + +@library("copyToArray") +public fun Collection.toTypedArray(): Array = noImpl + + +/** + * Returns an immutable list containing only the specified object [element]. + */ +public fun listOf(element: T): List = arrayListOf(element) + +/** + * Returns an immutable set containing only the specified object [element]. + */ +public fun setOf(element: T): Set = hashSetOf(element) + +/** + * Returns an immutable map, mapping only the specified key to the + * specified value. + */ +public fun mapOf(pair: Pair): Map = hashMapOf(pair) diff --git a/js/js.libraries/src/core/kotlin.kt b/js/js.libraries/src/core/kotlin.kt index 414292356e2..e154a415c36 100644 --- a/js/js.libraries/src/core/kotlin.kt +++ b/js/js.libraries/src/core/kotlin.kt @@ -31,26 +31,6 @@ public fun byteArrayOf(vararg elements: Byte): ByteArray = noImpl @library public fun booleanArrayOf(vararg elements: Boolean): BooleanArray = noImpl -@library("copyToArray") -public fun Collection.toTypedArray(): Array = noImpl - - -/** - * Returns an immutable list containing only the specified object [element]. - */ -public fun listOf(element: T): List = arrayListOf(element) - -/** - * Returns an immutable set containing only the specified object [element]. - */ -public fun setOf(element: T): Set = hashSetOf(element) - -/** - * Returns an immutable map, mapping only the specified key to the - * specified value. - */ -public fun mapOf(pair: Pair): Map = hashMapOf(pair) - /** * Creates a new instance of the [Lazy] that uses the specified initialization function [initializer]. */ diff --git a/js/js.libraries/src/core/kotlin_special.kt b/js/js.libraries/src/core/kotlin_special.kt index c0c4cc98102..d4e1a531f4b 100644 --- a/js/js.libraries/src/core/kotlin_special.kt +++ b/js/js.libraries/src/core/kotlin_special.kt @@ -1,4 +1,4 @@ -package kotlin +package kotlin.collections // // NOTE THIS FILE IS AUTO-GENERATED by the GenerateStandardLib.kt diff --git a/js/js.libraries/src/core/sequence.kt b/js/js.libraries/src/core/sequence.kt index 8325edbbe68..cb3877d9b7c 100644 --- a/js/js.libraries/src/core/sequence.kt +++ b/js/js.libraries/src/core/sequence.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package kotlin +package kotlin.sequences internal class ConstrainedOnceSequence(sequence: Sequence) : Sequence { @Volatile private var sequenceRef: Sequence? = sequence diff --git a/js/js.libraries/src/core/string.kt b/js/js.libraries/src/core/string.kt index 1a3c886c684..daf2037e73e 100644 --- a/js/js.libraries/src/core/string.kt +++ b/js/js.libraries/src/core/string.kt @@ -1,4 +1,4 @@ -package kotlin +package kotlin.text import kotlin.text.js.RegExp diff --git a/js/js.libraries/src/core/stringsCode.kt b/js/js.libraries/src/core/stringsCode.kt index 4d4d3b7e7d5..23264b4db98 100644 --- a/js/js.libraries/src/core/stringsCode.kt +++ b/js/js.libraries/src/core/stringsCode.kt @@ -1,6 +1,5 @@ -package kotlin +package kotlin.text -import kotlin.text.Regex import kotlin.text.js.RegExp internal inline fun String.nativeIndexOf(ch : Char, fromIndex : Int) : Int = nativeIndexOf(ch.toString(), fromIndex) diff --git a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt index 0ead795d6b2..d4d707300e2 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/generators/GenerateStandardLib.kt @@ -35,7 +35,7 @@ fun List.writeTo(file: File, builder: GenericFunction.() -> Str val its = FileWriter(file) its.use { - its.append("package kotlin\n\n") + its.append("package kotlin.collections\n\n") its.append("$COMMON_AUTOGENERATED_WARNING\n\n") its.append("import java.util.*\n\n") its.append("import java.util.Collections // TODO: it's temporary while we have java.util.Collections in js\n\n")