diff --git a/compiler/testData/cli/js/folderAsLib/LibraryExample.js b/compiler/testData/cli/js/folderAsLib/LibraryExample.js new file mode 100644 index 00000000000..68154be1e35 --- /dev/null +++ b/compiler/testData/cli/js/folderAsLib/LibraryExample.js @@ -0,0 +1,44 @@ +if (typeof kotlin === 'undefined') { + throw new Error("Error loading module 'LibraryExample'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'LibraryExample'."); +} +var LibraryExample = function (_, Kotlin) { + 'use strict'; + function pairAdd(p) { + return p.first + p.second | 0; + } + function pairMul(p) { + return Kotlin.imul(p.first, p.second); + } + function IntHolder(value) { + this.value = value; + } + IntHolder.$metadata$ = { + kind: Kotlin.Kind.CLASS, + simpleName: 'IntHolder', + interfaces: [] + }; + IntHolder.prototype.component1 = function () { + return this.value; + }; + IntHolder.prototype.copy_za3lpa$ = function (value) { + return new IntHolder(value === void 0 ? this.value : value); + }; + IntHolder.prototype.toString = function () { + return 'IntHolder(value=' + Kotlin.toString(this.value) + ')'; + }; + IntHolder.prototype.hashCode = function () { + var result = 0; + result = result * 31 + Kotlin.hashCode(this.value) | 0; + return result; + }; + IntHolder.prototype.equals = function (other) { + return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value)))); + }; + var package$library = _.library || (_.library = {}); + var package$sample = package$library.sample || (package$library.sample = {}); + package$sample.pairAdd_1fzo63$ = pairAdd; + package$sample.pairMul_1fzo63$ = pairMul; + package$sample.IntHolder = IntHolder; + Kotlin.defineModule('LibraryExample', _); + return _; +}(typeof LibraryExample === 'undefined' ? {} : LibraryExample, kotlin); diff --git a/compiler/testData/cli/js/folderAsLib/LibraryExample.meta.js b/compiler/testData/cli/js/folderAsLib/LibraryExample.meta.js new file mode 100644 index 00000000000..5dd2ffc566e --- /dev/null +++ b/compiler/testData/cli/js/folderAsLib/LibraryExample.meta.js @@ -0,0 +1 @@ +// Kotlin.kotlin_module_metadata(1, "LibraryExample", "H4sIAAAAAAAAAJVW227TQBB1fF1Pb64LJTUgRBEgbiWkCIEESC19KJWQgIoPcJ1tsqmzG9ZO0v4Ar0h9QP2UfAGf0N+BcS5O0tRu6gfvaHdmzlzOjq2490FxFa94Rv4Nn0LXHsmnRHE9sMD49oOz2NVBdRTPPCNK11aSs4cwD+aRiEPGQWXChUQBdKI4hUQNffVcvIabqZol6WFIgxjUeuQ6I318Fxw1sVK7tjp0rtf9tg96K2ZhlvOXsJo6n6fHTSpZg/LYzzToBV3/2aLyBNQWy1J7BzdAE7IKWmczAK0iGqAFUeSuXowZ36qjJaZa19YS0yfgpCGZ0udVGmWh7MNGqgqBkAJT5TSazASA8VgyHrFgJvwNWBoP/bgm8yv9CBbSIJJEr1OSlgxnCakIRs90mkO3gQzbMX34AGCEmBXWxhi95gLRaPqSRYJn1vw5rKT6dkQRmgfZHXqBSacdakqBbYlZtvqFYMKE6ywnmAn3IwLkXaVeQayjmhRcRGB06EE1zG/wZY2L2tVZGvcebl00NWkbaTkTEycGRD0zqx4H+mrTHNgcq1AP3zhosbCSn/FTWJ4aOVnobyZSnMMGHwrZ8JEU+RjPwE0xCN5QKnn21NmC9asvej7ebw3+FMAK2YH0cXaZkd9ohhTszzzeFWGFylGZtvgJGG0/bFHQ8DhBbDQFR5BXoAeiidbIez+MwNoWIqQ+B0PENXRBan5U+yQqFEgs9pOpUwVzsFpNn8mtSgUKTdC/otzf+dIK3Y9jgZtJ4EUFdzSUNUdHOVnNwQqDdXGwLhcVb8e76yx5askou47jLbq6i3L/XSJdouCxm3Pcr/M6I79IUS2rJX2buKZjJBZ7tmMl6+5fbW/FISiqZYI8NfqbBdy0UTTLxJnz9GKhpO+ea2g03zs/L6C4gKKF4veBSwQ8JSpMDdpkdM7OygMpOhGVWYR5C2tjvhe4iNkhC/z+MMlFKSHKyNI4pHFQy7d4DIuTUyUrqERxmIAe0+PMOzXxSam3Mz8pd8BOGT199T9A8eLwQcbJCMk4y/Qp46AfmVsdIY+ovGbxWEivsFgDs/+fMh3/Dty79MdnbFzMkMbEJ8LnyIQeCzJK6g1U/wOSAB0W3QkAAA=="); diff --git a/compiler/testData/cli/js/folderAsLib/LibraryExample/library/sample/sample.kjsm b/compiler/testData/cli/js/folderAsLib/LibraryExample/library/sample/sample.kjsm new file mode 100644 index 00000000000..f53578c8ac0 Binary files /dev/null and b/compiler/testData/cli/js/folderAsLib/LibraryExample/library/sample/sample.kjsm differ diff --git a/compiler/testData/cli/js/lib/LibraryExample.jar b/compiler/testData/cli/js/lib/LibraryExample.jar new file mode 100644 index 00000000000..8f4c227bcb9 Binary files /dev/null and b/compiler/testData/cli/js/lib/LibraryExample.jar differ diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt b/compiler/testData/cli/js/lib/LibraryExample.kt similarity index 100% rename from compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt rename to compiler/testData/cli/js/lib/LibraryExample.kt diff --git a/compiler/testData/cli/js/lib/ReadMe.md b/compiler/testData/cli/js/lib/ReadMe.md new file mode 100644 index 00000000000..b419e48b014 --- /dev/null +++ b/compiler/testData/cli/js/lib/ReadMe.md @@ -0,0 +1,5 @@ +# jslib + +Path to sources: `compiler/testData/cli/js/jslib` + +`folderAsLib/LibraryExample.js`, `folderAsLib/LibraryExample.meta.js` and `LibraryExample.jar` should be updated after changing some files in source folder. \ No newline at end of file diff --git a/compiler/testData/cli/js/notValidLibraryDir.args b/compiler/testData/cli/js/notValidLibraryDir.args index 70460c4bb3e..f98249d929f 100644 --- a/compiler/testData/cli/js/notValidLibraryDir.args +++ b/compiler/testData/cli/js/notValidLibraryDir.args @@ -1,5 +1,5 @@ $TESTDATA_DIR$/withLib.kt -libraries -compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib +compiler/testData/integration/ant/js/simpleWithStdlibAndJsFileAsAnotherLib -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/notValidLibraryDir.out b/compiler/testData/cli/js/notValidLibraryDir.out index a6ee07778a5..66f4bd3305c 100644 --- a/compiler/testData/cli/js/notValidLibraryDir.out +++ b/compiler/testData/cli/js/notValidLibraryDir.out @@ -1,4 +1,4 @@ -warning: 'compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib' is not a valid Kotlin Javascript library +warning: 'compiler/testData/integration/ant/js/simpleWithStdlibAndJsFileAsAnotherLib' is not a valid Kotlin Javascript library compiler/testData/cli/js/withLib.kt:2:8: error: unresolved reference: library import library.sample.* ^ diff --git a/compiler/testData/cli/js/withFolderAsLib.args b/compiler/testData/cli/js/withFolderAsLib.args index 2bf9dc145ea..e7dfc230efc 100644 --- a/compiler/testData/cli/js/withFolderAsLib.args +++ b/compiler/testData/cli/js/withFolderAsLib.args @@ -1,5 +1,5 @@ $TESTDATA_DIR$/withLib.kt -libraries -compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example +$TESTDATA_DIR$/folderAsLib -output $TEMP_DIR$/out.js diff --git a/compiler/testData/cli/js/withLib.args b/compiler/testData/cli/js/withLib.args index 1192909df99..5b34229ab63 100644 --- a/compiler/testData/cli/js/withLib.args +++ b/compiler/testData/cli/js/withLib.args @@ -1,5 +1,5 @@ $TESTDATA_DIR$/withLib.kt -libraries -compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar +$TESTDATA_DIR$/lib/LibraryExample.jar -output $TEMP_DIR$/out.js diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/build.log.expected b/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/build.log.expected deleted file mode 100644 index ef2906cf7b6..00000000000 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/build.log.expected +++ /dev/null @@ -1,11 +0,0 @@ -OUT: -Buildfile: [TestData]/build.xml - -build: -[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] - [unzip] Expanding: [TestData]/jslib-example.jar into [Temp] - -BUILD SUCCESSFUL -Total time: [time] - -Return code: 0 diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/build.xml b/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/build.xml deleted file mode 100644 index e6853081fc0..00000000000 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/build.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar b/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar deleted file mode 100644 index 9e5f07c06b9..00000000000 Binary files a/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar and /dev/null differ diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/root1/foo.kt b/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/root1/foo.kt deleted file mode 100644 index c6da571924b..00000000000 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/root1/foo.kt +++ /dev/null @@ -1,14 +0,0 @@ -package foo - -import library.sample.* - -var ok = "FAIL" - -fun main(args: Array) { - val p = Pair(10, 20) - val x = pairAdd(p) - ok = "OK" - println("x=$x") -} - -fun box(): String = ok diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.log.expected b/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.log.expected deleted file mode 100644 index f1a7a8e9413..00000000000 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.log.expected +++ /dev/null @@ -1,11 +0,0 @@ -OUT: -Buildfile: [TestData]/build.xml - -build: -[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] - [copy] Copying 1 file to [Temp] - -BUILD SUCCESSFUL -Total time: [time] - -Return code: 0 diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.xml b/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.xml deleted file mode 100644 index 5c132935d2b..00000000000 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/build.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF b/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF deleted file mode 100644 index 00281ee90c5..00000000000 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF +++ /dev/null @@ -1,9 +0,0 @@ -Manifest-Version: 1.0 -Ant-Version: Apache Ant 1.9.1 -Created-By: 1.7.0_72-b14 (Oracle Corporation) -Built-By: JetBrains -Implementation-Vendor: JetBrains -Implementation-Version: snapshot -Specification-Title: Kotlin JavaScript Lib -Kotlin-JS-Module-Name: jslib-example - diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/ReadMe.md b/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/ReadMe.md deleted file mode 100644 index 714dece829f..00000000000 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/ReadMe.md +++ /dev/null @@ -1,6 +0,0 @@ -# jslib-example - -Path to sources: compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example - -The archive compiler/testData/integration/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar should be updated after -changing some files in source folder. diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/jslib-example.js b/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/jslib-example.js deleted file mode 100644 index 74647a38a35..00000000000 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example/jslib-example.js +++ /dev/null @@ -1,38 +0,0 @@ -this['jslib-example'] = function (Kotlin) { - 'use strict'; - var _ = Kotlin.defineRootPackage(null, /** @lends _ */ { - library: Kotlin.definePackage(null, /** @lends _.library */ { - sample: Kotlin.definePackage(null, /** @lends _.library.sample */ { - pairAdd_bunuun$: function (p) { - return p.first + p.second; - }, - pairMul_bunuun$: function (p) { - return p.first * p.second; - }, - IntHolder: Kotlin.createClass(null, function (value) { - this.value = value; - }, /** @lends _.library.sample.IntHolder.prototype */ { - component1: function () { - return this.value; - }, - copy_za3lpa$: function (value) { - return new _.library.sample.IntHolder(value === void 0 ? this.value : value); - }, - toString: function () { - return 'IntHolder(value=' + Kotlin.toString(this.value) + ')'; - }, - hashCode: function () { - var result = 0; - result = result * 31 + Kotlin.hashCode(this.value) | 0; - return result; - }, - equals_za3rmp$: function (other) { - return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value)))); - } - }) - }) - }) - }); - Kotlin.defineModule('jslib-example', _); - return _; -}(kotlin); diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/root1/foo.kt b/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/root1/foo.kt deleted file mode 100644 index c6da571924b..00000000000 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndFolderAsAnotherLib/root1/foo.kt +++ /dev/null @@ -1,14 +0,0 @@ -package foo - -import library.sample.* - -var ok = "FAIL" - -fun main(args: Array) { - val p = Pair(10, 20) - val x = pairAdd(p) - ok = "OK" - println("x=$x") -} - -fun box(): String = ok diff --git a/compiler/util/src/org/jetbrains/kotlin/utils/LibraryUtils.kt b/compiler/util/src/org/jetbrains/kotlin/utils/LibraryUtils.kt index 22c63e3e6a3..d9b793cd25d 100644 --- a/compiler/util/src/org/jetbrains/kotlin/utils/LibraryUtils.kt +++ b/compiler/util/src/org/jetbrains/kotlin/utils/LibraryUtils.kt @@ -27,17 +27,13 @@ import java.util.jar.Manifest object LibraryUtils { private val LOG = Logger.getInstance(LibraryUtils::class.java) - val KOTLIN_JS_MODULE_NAME: String = "Kotlin-JS-Module-Name" private var TITLE_KOTLIN_JAVASCRIPT_STDLIB: String - private var TITLE_KOTLIN_JAVASCRIPT_LIB: String val META_INF = "META-INF/" private val MANIFEST_PATH = "${META_INF}MANIFEST.MF" - private val KOTLIN_JS_MODULE_ATTRIBUTE_NAME = Attributes.Name(KOTLIN_JS_MODULE_NAME) init { var jsStdLib = "" - var jsLib = "" val manifestProperties = LibraryUtils::class.java.getResourceAsStream("/kotlinManifest.properties") if (manifestProperties != null) { @@ -45,7 +41,6 @@ object LibraryUtils { val properties = Properties() properties.load(manifestProperties) jsStdLib = properties.getPropertyOrFail("manifest.impl.title.kotlin.javascript.stdlib") - jsLib = properties.getPropertyOrFail("manifest.spec.title.kotlin.javascript.lib") } catch (e: IOException) { LOG.error(e) @@ -57,27 +52,14 @@ object LibraryUtils { } TITLE_KOTLIN_JAVASCRIPT_STDLIB = jsStdLib - TITLE_KOTLIN_JAVASCRIPT_LIB = jsLib } @JvmStatic fun getJarFile(classesRoots: List, jarName: String): VirtualFile? { return classesRoots.firstOrNull { it.name == jarName } } - @JvmStatic fun getKotlinJsModuleName(library: File): String? { - return getManifestMainAttributesFromJarOrDirectory(library)?.getValue(KOTLIN_JS_MODULE_ATTRIBUTE_NAME) - } - - @JvmStatic fun isOldKotlinJavascriptLibrary(library: File): Boolean = - checkAttributeValue(library, TITLE_KOTLIN_JAVASCRIPT_LIB, Attributes.Name.SPECIFICATION_TITLE) && - getKotlinJsModuleName(library) != null - - @JvmStatic fun isKotlinJavascriptLibraryWithMetadata(library: File): Boolean = - KotlinJavascriptMetadataUtils.loadMetadata(library).isNotEmpty() - @Suppress("unused") // used in K2JSCompilerMojo - @JvmStatic fun isKotlinJavascriptLibrary(library: File): Boolean = - isOldKotlinJavascriptLibrary(library) || isKotlinJavascriptLibraryWithMetadata(library) + @JvmStatic fun isKotlinJavascriptLibrary(library: File): Boolean = KotlinJavascriptMetadataUtils.loadMetadata(library).isNotEmpty() @JvmStatic fun isKotlinJavascriptStdLibrary(library: File): Boolean { return checkAttributeValue(library, TITLE_KOTLIN_JAVASCRIPT_STDLIB, Attributes.Name.IMPLEMENTATION_TITLE) diff --git a/idea/src/META-INF/extensions/kotlin2js.xml b/idea/src/META-INF/extensions/kotlin2js.xml index e42e3fc04ba..99248642ec3 100644 --- a/idea/src/META-INF/extensions/kotlin2js.xml +++ b/idea/src/META-INF/extensions/kotlin2js.xml @@ -8,6 +8,5 @@ - diff --git a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt index b065e8962a4..3fbf62c0c2c 100644 --- a/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt +++ b/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -98,8 +98,7 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { private val EXPECTED_JS_FILES_IN_OUTPUT_NO_COPY = hashSetOf( "$PROJECT_NAME.js", "$PROJECT_NAME.meta.js", - "$PROJECT_NAME/root-package.kjsm", - "$PROJECT_NAME/library/sample/sample.kjsm" + "$PROJECT_NAME/root-package.kjsm" ) private val EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_DEFAULT_DIR = hashSetOf( "$PROJECT_NAME.js", @@ -107,13 +106,13 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { "lib/kotlin.js", "lib/kotlin.meta.js", "lib/jslib-example.js", + "lib/jslib-example.meta.js", "lib/file0.js", "lib/dir/file1.js", "lib/META-INF-ex/file2.js", "lib/res0.js", "lib/resdir/res1.js", - "$PROJECT_NAME/root-package.kjsm", - "$PROJECT_NAME/library/sample/sample.kjsm" + "$PROJECT_NAME/root-package.kjsm" ) private val EXPECTED_JS_FILES_IN_OUTPUT_WITH_ADDITIONAL_LIB_AND_CUSTOM_DIR = hashSetOf( "$PROJECT_NAME.js", @@ -121,13 +120,13 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { "custom/kotlin.js", "custom/kotlin.meta.js", "custom/jslib-example.js", + "custom/jslib-example.meta.js", "custom/file0.js", "custom/dir/file1.js", "custom/META-INF-ex/file2.js", "custom/res0.js", "custom/resdir/res1.js", - "$PROJECT_NAME/root-package.kjsm", - "$PROJECT_NAME/library/sample/sample.kjsm" + "$PROJECT_NAME/root-package.kjsm" ) private fun k2jsOutput(vararg moduleNames: String): Array { diff --git a/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/MANIFEST.MF b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/MANIFEST.MF index 00281ee90c5..5d1ec1e9192 100644 --- a/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/MANIFEST.MF +++ b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/META-INF/MANIFEST.MF @@ -5,5 +5,4 @@ Built-By: JetBrains Implementation-Vendor: JetBrains Implementation-Version: snapshot Specification-Title: Kotlin JavaScript Lib -Kotlin-JS-Module-Name: jslib-example diff --git a/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/ReadMe.md b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/ReadMe.md index 6c269930b08..9e82278e756 100644 --- a/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/ReadMe.md +++ b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/ReadMe.md @@ -1,6 +1,6 @@ # jslib-example -Path to sources: compiler/integration-tests/testData/ant/js/simpleWithStdlibAndFolderAsAnotherLib/jslib-example +Path to sources: `compiler/testData/cli/js/jslib` The archive compiler/integration-tests/testData/ant/js/simpleWithStdlibAndAnotherLib/jslib-example.jar should be updated after changing some files in source folder. \ No newline at end of file diff --git a/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.js b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.js index 8fb2ce81d48..68154be1e35 100644 --- a/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.js +++ b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.js @@ -1,37 +1,44 @@ -(function (Kotlin) { +if (typeof kotlin === 'undefined') { + throw new Error("Error loading module 'LibraryExample'. Its dependency 'kotlin' was not found. Please, check whether 'kotlin' is loaded prior to 'LibraryExample'."); +} +var LibraryExample = function (_, Kotlin) { 'use strict'; - var _ = Kotlin.defineRootPackage(null, /** @lends _ */ { - library: Kotlin.definePackage(null, /** @lends _.library */ { - sample: Kotlin.definePackage(null, /** @lends _.library.sample */ { - pairAdd_bunuun$: function (p) { - return p.first + p.second; - }, - pairMul_bunuun$: function (p) { - return p.first * p.second; - }, - IntHolder: Kotlin.createClass(null, function (value) { - this.value = value; - }, /** @lends _.library.sample.IntHolder.prototype */ { - component1: function () { - return this.value; - }, - copy_za3lpa$: function (value) { - return new _.library.sample.IntHolder(value === void 0 ? this.value : value); - }, - toString: function () { - return 'IntHolder(value=' + Kotlin.toString(this.value) + ')'; - }, - hashCode: function () { - var result = 0; - result = result * 31 + Kotlin.hashCode(this.value) | 0; - return result; - }, - equals_za3rmp$: function (other) { - return this === other || (other !== null && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value))); - } - }) - }) - }) - }); - Kotlin.defineModule('jslib-example', _); -}(Kotlin)); + function pairAdd(p) { + return p.first + p.second | 0; + } + function pairMul(p) { + return Kotlin.imul(p.first, p.second); + } + function IntHolder(value) { + this.value = value; + } + IntHolder.$metadata$ = { + kind: Kotlin.Kind.CLASS, + simpleName: 'IntHolder', + interfaces: [] + }; + IntHolder.prototype.component1 = function () { + return this.value; + }; + IntHolder.prototype.copy_za3lpa$ = function (value) { + return new IntHolder(value === void 0 ? this.value : value); + }; + IntHolder.prototype.toString = function () { + return 'IntHolder(value=' + Kotlin.toString(this.value) + ')'; + }; + IntHolder.prototype.hashCode = function () { + var result = 0; + result = result * 31 + Kotlin.hashCode(this.value) | 0; + return result; + }; + IntHolder.prototype.equals = function (other) { + return this === other || (other !== null && (typeof other === 'object' && (Object.getPrototypeOf(this) === Object.getPrototypeOf(other) && Kotlin.equals(this.value, other.value)))); + }; + var package$library = _.library || (_.library = {}); + var package$sample = package$library.sample || (package$library.sample = {}); + package$sample.pairAdd_1fzo63$ = pairAdd; + package$sample.pairMul_1fzo63$ = pairMul; + package$sample.IntHolder = IntHolder; + Kotlin.defineModule('LibraryExample', _); + return _; +}(typeof LibraryExample === 'undefined' ? {} : LibraryExample, kotlin); diff --git a/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.meta.js b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.meta.js new file mode 100644 index 00000000000..5dd2ffc566e --- /dev/null +++ b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example.meta.js @@ -0,0 +1 @@ +// Kotlin.kotlin_module_metadata(1, "LibraryExample", "H4sIAAAAAAAAAJVW227TQBB1fF1Pb64LJTUgRBEgbiWkCIEESC19KJWQgIoPcJ1tsqmzG9ZO0v4Ar0h9QP2UfAGf0N+BcS5O0tRu6gfvaHdmzlzOjq2490FxFa94Rv4Nn0LXHsmnRHE9sMD49oOz2NVBdRTPPCNK11aSs4cwD+aRiEPGQWXChUQBdKI4hUQNffVcvIabqZol6WFIgxjUeuQ6I318Fxw1sVK7tjp0rtf9tg96K2ZhlvOXsJo6n6fHTSpZg/LYzzToBV3/2aLyBNQWy1J7BzdAE7IKWmczAK0iGqAFUeSuXowZ36qjJaZa19YS0yfgpCGZ0udVGmWh7MNGqgqBkAJT5TSazASA8VgyHrFgJvwNWBoP/bgm8yv9CBbSIJJEr1OSlgxnCakIRs90mkO3gQzbMX34AGCEmBXWxhi95gLRaPqSRYJn1vw5rKT6dkQRmgfZHXqBSacdakqBbYlZtvqFYMKE6ywnmAn3IwLkXaVeQayjmhRcRGB06EE1zG/wZY2L2tVZGvcebl00NWkbaTkTEycGRD0zqx4H+mrTHNgcq1AP3zhosbCSn/FTWJ4aOVnobyZSnMMGHwrZ8JEU+RjPwE0xCN5QKnn21NmC9asvej7ebw3+FMAK2YH0cXaZkd9ohhTszzzeFWGFylGZtvgJGG0/bFHQ8DhBbDQFR5BXoAeiidbIez+MwNoWIqQ+B0PENXRBan5U+yQqFEgs9pOpUwVzsFpNn8mtSgUKTdC/otzf+dIK3Y9jgZtJ4EUFdzSUNUdHOVnNwQqDdXGwLhcVb8e76yx5askou47jLbq6i3L/XSJdouCxm3Pcr/M6I79IUS2rJX2buKZjJBZ7tmMl6+5fbW/FISiqZYI8NfqbBdy0UTTLxJnz9GKhpO+ea2g03zs/L6C4gKKF4veBSwQ8JSpMDdpkdM7OygMpOhGVWYR5C2tjvhe4iNkhC/z+MMlFKSHKyNI4pHFQy7d4DIuTUyUrqERxmIAe0+PMOzXxSam3Mz8pd8BOGT199T9A8eLwQcbJCMk4y/Qp46AfmVsdIY+ovGbxWEivsFgDs/+fMh3/Dty79MdnbFzMkMbEJ8LnyIQeCzJK6g1U/wOSAB0W3QkAAA=="); diff --git a/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example/library/sample/sample.kjsm b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example/library/sample/sample.kjsm new file mode 100644 index 00000000000..f53578c8ac0 Binary files /dev/null and b/jps-plugin/testData/general/KotlinJavaScriptProjectWithDirectoryAsLibrary/jslib-example/jslib-example/library/sample/sample.kjsm differ diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.kt index 6087e633435..4acfa24a442 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/TopDownAnalyzerFacadeForJS.kt @@ -54,10 +54,9 @@ object TopDownAnalyzerFacadeForJS { moduleContext: ModuleContext, config: JsConfig ): JsAnalysisResult { - val allFiles = JsConfig.withJsLibAdded(files, config) val analyzerForJs = createTopDownAnalyzerForJs( moduleContext, trace, - FileBasedDeclarationProviderFactory(moduleContext.storageManager, allFiles), + FileBasedDeclarationProviderFactory(moduleContext.storageManager, files), config.configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, LanguageVersionSettingsImpl.DEFAULT) ) analyzerForJs.analyzeDeclarations(TopDownAnalysisMode.TopLevelDeclarations, files) diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/suppressWarnings.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/suppressWarnings.kt index 6db3f86e5ef..fb35b0bfd07 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/suppressWarnings.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/analyze/suppressWarnings.kt @@ -20,11 +20,8 @@ import org.jetbrains.kotlin.descriptors.VariableDescriptor import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticWithParameters1 import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.diagnostics.Severity import org.jetbrains.kotlin.js.PredefinedAnnotation.* -import org.jetbrains.kotlin.js.config.LibrarySourcesConfig import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils -import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.KtSimpleNameExpression import org.jetbrains.kotlin.resolve.diagnostics.DiagnosticSuppressor import org.jetbrains.kotlin.resolve.diagnostics.FUNCTION_NO_BODY_ERRORS @@ -50,10 +47,3 @@ class SuppressUninitializedErrorsForNativeDeclarations : DiagnosticSuppressor { } } -class SuppressWarningsFromExternalModules : DiagnosticSuppressor { - override fun isSuppressed(diagnostic: Diagnostic): Boolean { - val file = diagnostic.psiFile - return diagnostic.severity == Severity.WARNING && - file is KtFile && file.getUserData(LibrarySourcesConfig.EXTERNAL_MODULE_NAME) != null - } -} diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/config/JsConfig.java b/js/js.frontend/src/org/jetbrains/kotlin/js/config/JsConfig.java index 719c4ed8300..c589a24e162 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/config/JsConfig.java +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/config/JsConfig.java @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.js.config; -import com.google.common.collect.Lists; import com.intellij.openapi.project.Project; import com.intellij.util.SmartList; import kotlin.collections.CollectionsKt; @@ -29,7 +28,6 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentProvider; import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl; import org.jetbrains.kotlin.js.resolve.JsPlatform; import org.jetbrains.kotlin.name.Name; -import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration; import org.jetbrains.kotlin.serialization.js.JsModuleDescriptor; import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil; @@ -39,7 +37,6 @@ import org.jetbrains.kotlin.utils.JsMetadataVersion; import org.jetbrains.kotlin.utils.KotlinJavascriptMetadata; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.List; @@ -50,7 +47,6 @@ public abstract class JsConfig { private final Project project; private final CompilerConfiguration configuration; private final LockBasedStorageManager storageManager = new LockBasedStorageManager(); - private final List sourceFilesFromLibraries = new SmartList(); @NotNull protected final List metadata = new SmartList(); @@ -92,7 +88,7 @@ public abstract class JsConfig { public abstract boolean checkLibFilesAndReportErrors(@NotNull Reporter report); - protected abstract void init(@NotNull List sourceFilesInLibraries, @NotNull List metadata); + protected abstract void init(@NotNull List metadata); @NotNull public List> getModuleDescriptors() { @@ -117,16 +113,10 @@ public abstract class JsConfig { return moduleDescriptors; } - @NotNull - private List getSourceFilesFromLibraries() { - init(); - return sourceFilesFromLibraries; - } - private void init() { if (initialized) return; - init(sourceFilesFromLibraries, metadata); + init(metadata); initialized = true; } @@ -153,12 +143,4 @@ public abstract class JsConfig { private static void setDependencies(ModuleDescriptorImpl module, List modules) { module.setDependencies(CollectionsKt.plus(modules, JsPlatform.INSTANCE.getBuiltIns().getBuiltInsModule())); } - - @NotNull - public static Collection withJsLibAdded(@NotNull Collection files, @NotNull JsConfig config) { - Collection allFiles = Lists.newArrayList(); - allFiles.addAll(files); - allFiles.addAll(config.getSourceFilesFromLibraries()); - return allFiles; - } } diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/config/LibrarySourcesConfig.java b/js/js.frontend/src/org/jetbrains/kotlin/js/config/LibrarySourcesConfig.java index 275fe45ad38..67863f338cd 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/config/LibrarySourcesConfig.java +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/config/LibrarySourcesConfig.java @@ -17,24 +17,20 @@ package org.jetbrains.kotlin.js.config; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; -import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.*; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiManager; +import com.intellij.openapi.vfs.StandardFileSystems; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileManager; +import com.intellij.openapi.vfs.VirtualFileSystem; import com.intellij.util.PathUtil; import com.intellij.util.io.URLUtil; import kotlin.Unit; -import kotlin.jvm.functions.Function2; +import kotlin.jvm.functions.Function1; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.config.CompilerConfiguration; -import org.jetbrains.kotlin.idea.KotlinFileType; -import org.jetbrains.kotlin.psi.KtFile; import org.jetbrains.kotlin.utils.JsMetadataVersion; import org.jetbrains.kotlin.utils.KotlinJavascriptMetadata; import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils; -import org.jetbrains.kotlin.utils.LibraryUtils; import java.io.File; import java.util.Collections; @@ -42,7 +38,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import static org.jetbrains.kotlin.utils.LibraryUtils.isOldKotlinJavascriptLibrary; import static org.jetbrains.kotlin.utils.PathUtil.getKotlinPathsForDistDirectory; public class LibrarySourcesConfig extends JsConfig { @@ -52,7 +47,6 @@ public class LibrarySourcesConfig extends JsConfig { public static final List JS_KOTLIN_TEST = Collections.singletonList(getKotlinPathsForDistDirectory().getJsKotlinTestJarPath().getAbsolutePath()); - public static final Key EXTERNAL_MODULE_NAME = Key.create("externalModule"); public static final String UNKNOWN_EXTERNAL_MODULE_NAME = ""; public LibrarySourcesConfig(@NotNull Project project, @NotNull CompilerConfiguration configuration) { @@ -65,11 +59,9 @@ public class LibrarySourcesConfig extends JsConfig { } @Override - protected void init(@NotNull final List sourceFilesInLibraries, @NotNull final List metadata) { + protected void init(@NotNull final List metadata) { if (getLibraries().isEmpty()) return; - final PsiManager psiManager = PsiManager.getInstance(getProject()); - JsConfig.Reporter report = new JsConfig.Reporter() { @Override public void error(@NotNull String message) { @@ -77,18 +69,12 @@ public class LibrarySourcesConfig extends JsConfig { } }; - Function2 action = new Function2() { + Function1 action = new Function1() { @Override - public Unit invoke(String moduleName, VirtualFile file) { - if (moduleName != null) { - JetFileCollector jetFileCollector = new JetFileCollector(sourceFilesInLibraries, moduleName, psiManager); - VfsUtilCore.visitChildrenRecursively(file, jetFileCollector); - } - else { - String libraryPath = PathUtil.getLocalPath(file); - assert libraryPath != null : "libraryPath for " + file + " should not be null"; - metadata.addAll(KotlinJavascriptMetadataUtils.loadMetadata(libraryPath)); - } + public Unit invoke(VirtualFile file) { + String libraryPath = PathUtil.getLocalPath(file); + assert libraryPath != null : "libraryPath for " + file + " should not be null"; + metadata.addAll(KotlinJavascriptMetadataUtils.loadMetadata(libraryPath)); return Unit.INSTANCE; } @@ -103,7 +89,7 @@ public class LibrarySourcesConfig extends JsConfig { return checkLibFilesAndReportErrors(report, null); } - private boolean checkLibFilesAndReportErrors(@NotNull JsConfig.Reporter report, @Nullable Function2 action) { + private boolean checkLibFilesAndReportErrors(@NotNull JsConfig.Reporter report, @Nullable Function1 action) { List libraries = getLibraries(); if (libraries.isEmpty()) { return false; @@ -135,73 +121,28 @@ public class LibrarySourcesConfig extends JsConfig { return true; } - String moduleName; - - if (isOldKotlinJavascriptLibrary(filePath)) { - moduleName = LibraryUtils.getKotlinJsModuleName(filePath); - if (!modules.add(moduleName)) { - report.warning("Module \"" + moduleName + "\" is defined in more, than one file"); - } + List metadataList = KotlinJavascriptMetadataUtils.loadMetadata(filePath); + if (metadataList.isEmpty()) { + report.warning("'" + path + "' is not a valid Kotlin Javascript library"); + continue; } - else { - List metadataList = KotlinJavascriptMetadataUtils.loadMetadata(filePath); - if (metadataList.isEmpty()) { - report.warning("'" + path + "' is not a valid Kotlin Javascript library"); - continue; - } - for (KotlinJavascriptMetadata metadata : metadataList) { - if (!metadata.getVersion().isCompatible()) { - report.error("File '" + path + "' was compiled with an incompatible version of Kotlin. " + - "The binary version of its metadata is " + metadata.getVersion() + - ", expected version is " + JsMetadataVersion.INSTANCE); - return true; - } - if (!modules.add(metadata.getModuleName())) { + for (KotlinJavascriptMetadata metadata : metadataList) { + if (!metadata.getVersion().isCompatible()) { + report.error("File '" + path + "' was compiled with an incompatible version of Kotlin. " + + "The binary version of its metadata is " + metadata.getVersion() + + ", expected version is " + JsMetadataVersion.INSTANCE); + return true; + } + if (!modules.add(metadata.getModuleName())) { report.warning("Module \"" + metadata.getModuleName() + "\" is defined in more, than one file"); - } - } - - moduleName = null; - } + }} if (action != null) { - action.invoke(moduleName, file); + action.invoke(file); } } return false; } - - private static KtFile getJetFileByVirtualFile(VirtualFile file, String moduleName, PsiManager psiManager) { - PsiFile psiFile = psiManager.findFile(file); - assert psiFile != null; - - setupPsiFile(psiFile, moduleName); - return (KtFile) psiFile; - } - - private static void setupPsiFile(PsiFile psiFile, String moduleName) { - psiFile.putUserData(EXTERNAL_MODULE_NAME, moduleName); - } - - private static class JetFileCollector extends VirtualFileVisitor { - private final List jetFiles; - private final String moduleName; - private final PsiManager psiManager; - - private JetFileCollector(List files, String name, PsiManager manager) { - moduleName = name; - psiManager = manager; - jetFiles = files; - } - - @Override - public boolean visitFile(@NotNull VirtualFile file) { - if (!file.isDirectory() && StringUtil.notNullize(file.getExtension()).equalsIgnoreCase(KotlinFileType.EXTENSION)) { - jetFiles.add(getJetFileByVirtualFile(file, moduleName, psiManager)); - } - return true; - } - } } diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt index eed02593bff..cf96d89d637 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/FunctionReader.kt @@ -31,7 +31,7 @@ import org.jetbrains.kotlin.js.translate.context.Namer import org.jetbrains.kotlin.js.translate.context.TranslationContext import org.jetbrains.kotlin.js.translate.reference.CallExpressionTranslator import org.jetbrains.kotlin.js.translate.utils.JsAstUtils -import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils.getExternalModuleName +import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils.getModuleName import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension import org.jetbrains.kotlin.resolve.inline.InlineStrategy import org.jetbrains.kotlin.utils.JsLibraryUtils @@ -68,7 +68,7 @@ class FunctionReader(private val context: TranslationContext) { val config = context.config as LibrarySourcesConfig val libs = config.libraries.map { File(it) } - JsLibraryUtils.traverseJsLibraries(libs) { fileContent, path -> + JsLibraryUtils.traverseJsLibraries(libs) { fileContent, _ -> var current = 0 while (true) { @@ -113,9 +113,9 @@ class FunctionReader(private val context: TranslationContext) { } operator fun contains(descriptor: CallableDescriptor): Boolean { - val moduleName = getExternalModuleName(descriptor) + val moduleName = getModuleName(descriptor) val currentModuleName = context.config.moduleId - return currentModuleName != moduleName && moduleName != null && moduleName in moduleNameToInfo.keys() + return currentModuleName != moduleName && moduleName in moduleNameToInfo.keys() } operator fun get(descriptor: CallableDescriptor): JsFunction = functionCache.get(descriptor) @@ -123,7 +123,7 @@ class FunctionReader(private val context: TranslationContext) { private fun readFunction(descriptor: CallableDescriptor): JsFunction? { if (descriptor !in this) return null - val moduleName = getExternalModuleName(descriptor) + val moduleName = getModuleName(descriptor) for (info in moduleNameToInfo[moduleName]) { val function = readFunctionFromSource(descriptor, info) diff --git a/js/js.tests/test/org/jetbrains/kotlin/integration/AntTaskJsTest.java b/js/js.tests/test/org/jetbrains/kotlin/integration/AntTaskJsTest.java index 734257fa687..89e7a8af8e1 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/integration/AntTaskJsTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/integration/AntTaskJsTest.java @@ -104,14 +104,6 @@ public class AntTaskJsTest extends AbstractAntTaskTest { doJsAntTest(); } - public void testSimpleWithStdlibAndAnotherLib() throws Exception { - doJsAntTest("jslib-example.js"); - } - - public void testSimpleWithStdlibAndFolderAsAnotherLib() throws Exception { - doJsAntTest("jslib-example.js"); - } - public void testSimpleWithoutStdlibAndFolderAsAnotherLib() throws Exception { doJsAntTest("jslib-example.js"); } diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java b/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java index 6b65486a71d..12db6706966 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/facade/K2JSTranslator.java @@ -74,7 +74,7 @@ public final class K2JSTranslator { } BindingTrace bindingTrace = analysisResult.getBindingTrace(); - TopDownAnalyzerFacadeForJS.checkForErrors(JsConfig.withJsLibAdded(files, config), bindingTrace.getBindingContext()); + TopDownAnalyzerFacadeForJS.checkForErrors(files, bindingTrace.getBindingContext()); ModuleDescriptor moduleDescriptor = analysisResult.getModuleDescriptor(); Diagnostics diagnostics = bindingTrace.getBindingContext().getDiagnostics(); diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/JsDescriptorUtils.java b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/JsDescriptorUtils.java index 2dffc92a900..987d660f8ef 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/JsDescriptorUtils.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/JsDescriptorUtils.java @@ -17,15 +17,12 @@ package org.jetbrains.kotlin.js.translate.utils; import com.intellij.openapi.util.Condition; -import com.intellij.psi.PsiElement; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.js.config.LibrarySourcesConfig; import org.jetbrains.kotlin.js.descriptorUtils.DescriptorUtilsKt; -import org.jetbrains.kotlin.js.translate.context.Namer; import org.jetbrains.kotlin.js.translate.context.TranslationContext; import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.psi.KtExpression; @@ -42,7 +39,6 @@ import java.util.List; import java.util.Set; import static org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.isNativeObject; -import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration; import static org.jetbrains.kotlin.resolve.DescriptorUtils.*; public final class JsDescriptorUtils { @@ -164,24 +160,9 @@ public final class JsDescriptorUtils { @NotNull public static String getModuleName(@NotNull DeclarationDescriptor descriptor) { - String externalModuleName = getExternalModuleName(descriptor); - if (externalModuleName != null) return externalModuleName; - - return getModuleNameFromDescriptorName(descriptor); - } - - @Nullable - public static String getExternalModuleName(@NotNull DeclarationDescriptor descriptor) { - if (KotlinBuiltIns.isBuiltIn(descriptor)) return Namer.KOTLIN_LOWER_NAME; - - PsiElement element = descriptorToDeclaration(descriptor); - if (element == null && descriptor instanceof PropertyAccessorDescriptor) { - element = descriptorToDeclaration(((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty()); - } - - if (element == null) return getModuleNameFromDescriptorName(descriptor); - - return element.getContainingFile().getUserData(LibrarySourcesConfig.EXTERNAL_MODULE_NAME); + ModuleDescriptor moduleDescriptor = DescriptorUtils.getContainingModule(findRealInlineDeclaration(descriptor)); + String moduleName = moduleDescriptor.getName().asString(); + return moduleName.substring(1, moduleName.length() - 1); } @NotNull @@ -210,13 +191,6 @@ public final class JsDescriptorUtils { return null; } - private static String getModuleNameFromDescriptorName(@NotNull DeclarationDescriptor descriptor) { - ModuleDescriptor moduleDescriptor = DescriptorUtils.getContainingModule(findRealInlineDeclaration(descriptor)); - String moduleName = moduleDescriptor.getName().asString(); - return moduleName.substring(1, moduleName.length() - 1); - } - - public static boolean isImmediateSubtypeOfError(@NotNull ClassDescriptor descriptor) { if (!isExceptionClass(descriptor)) return false; ClassDescriptor superClass = org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt.getSuperClassOrAny(descriptor); diff --git a/resources/kotlinManifest.properties b/resources/kotlinManifest.properties index 823e385dc69..43fa48034bf 100644 --- a/resources/kotlinManifest.properties +++ b/resources/kotlinManifest.properties @@ -21,7 +21,6 @@ manifest.impl.title.kotlin.jvm.reflect.sources=Kotlin Reflect Sources manifest.impl.title.kotlin.script.runtime.sources=Kotlin Script Runtime Sources manifest.impl.title.kotlin.javascript.stdlib=Kotlin JavaScript StdLib -manifest.spec.title.kotlin.javascript.lib=Kotlin JavaScript Lib manifest.impl.title.kotlin.preloader=Kotlin Preloader