[K/JS] Remove FILE target from JsName annotation and use the new experimental JsFileName annotation instead

This commit is contained in:
Artem Kobzar
2023-07-27 09:44:28 +00:00
committed by Space Team
parent 029c71ebb1
commit 85ee2d71d2
16 changed files with 24 additions and 24 deletions
@@ -338,7 +338,7 @@ class IrModuleToJsTransformer(
val staticContext = JsStaticContext(backendContext, nameGenerator, globalNameScope, mode)
val result = JsIrProgramFragment(
fileExports.file.getJsName() ?: fileExports.file.nameWithoutExtension,
fileExports.file.getJsFileName() ?: fileExports.file.nameWithoutExtension,
fileExports.file.packageFqName.asString()
).apply {
if (shouldGeneratePolyfills) {
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.ir.backend.js.transformers.irToJs
import org.jetbrains.kotlin.ir.backend.js.utils.getJsFileName
import org.jetbrains.kotlin.ir.backend.js.utils.getJsName
import org.jetbrains.kotlin.ir.backend.js.utils.nameWithoutExtension
import org.jetbrains.kotlin.ir.backend.js.utils.sanitizeName
@@ -67,6 +68,6 @@ class ModuleFragmentToExternalName(private val jsOutputNamesMapping: Map<IrModul
return "$prefix${if (prefix.isNotEmpty()) "/" else ""}$fileName"
}
private val IrFile.outputName: String get() = getJsName() ?: nameWithoutExtension
private val IrFile.outputName: String get() = getJsFileName() ?: nameWithoutExtension
private val IrFile.stableFileName: String get() = getFileStableName(outputName, packageFqName.asString())
}
@@ -6,10 +6,7 @@
package org.jetbrains.kotlin.ir.backend.js.utils
import org.jetbrains.kotlin.builtins.StandardNames
import org.jetbrains.kotlin.ir.declarations.IrAnnotationContainer
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrDeclarationWithName
import org.jetbrains.kotlin.ir.declarations.IrOverridableDeclaration
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.expressions.IrClassReference
import org.jetbrains.kotlin.ir.expressions.IrConst
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
@@ -22,6 +19,7 @@ object JsAnnotations {
val jsModuleFqn = FqName("kotlin.js.JsModule")
val jsNonModuleFqn = FqName("kotlin.js.JsNonModule")
val jsNameFqn = FqName("kotlin.js.JsName")
val jsFileNameFqn = FqName("kotlin.js.JsFileName")
val jsQualifierFqn = FqName("kotlin.js.JsQualifier")
val jsExportFqn = FqName("kotlin.js.JsExport")
val jsImplicitExportFqn = FqName("kotlin.js.JsImplicitExport")
@@ -46,6 +44,9 @@ fun IrAnnotationContainer.isJsNonModule(): Boolean =
fun IrAnnotationContainer.getJsQualifier(): String? =
getAnnotation(JsAnnotations.jsQualifierFqn)?.getSingleConstStringArgument()
fun IrFile.getJsFileName(): String? =
getAnnotation(JsAnnotations.jsFileNameFqn)?.getSingleConstStringArgument()
fun IrAnnotationContainer.getJsName(): String? =
getAnnotation(JsAnnotations.jsNameFqn)?.getSingleConstStringArgument()
+2 -2
View File
@@ -281,7 +281,7 @@ public final annotation class JsExternalInheritorsOnly : kotlin.Annotation {
public constructor JsExternalInheritorsOnly()
}
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@kotlin.annotation.Retention(value = AnnotationRetention.SOURCE)
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FILE})
public final annotation class JsFileName : kotlin.Annotation {
public constructor JsFileName(name: kotlin.String)
@@ -298,7 +298,7 @@ public final annotation class JsModule : kotlin.Annotation {
}
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FILE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER})
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER})
public final annotation class JsName : kotlin.Annotation {
public constructor JsName(name: kotlin.String)
@@ -11,7 +11,7 @@ import kotlin.reflect.KClass
/**
* Gives a declaration (a function, a property or a class) specific name in JavaScript.
*/
@Target(FILE, CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
@OptionalExpectation
public expect annotation class JsName(val name: String)
@@ -37,6 +37,7 @@ public annotation class ExperimentalJsFileName
@Target(FILE)
@OptionalExpectation
@ExperimentalJsFileName
@Retention(AnnotationRetention.SOURCE)
public expect annotation class JsFileName(val name: String)
/**
+1 -1
View File
@@ -8,7 +8,7 @@ package kotlin.js
import kotlin.annotation.AnnotationTarget.*
@Retention(AnnotationRetention.BINARY)
@Target(FILE, CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
internal external annotation class JsName(val name: String)
internal external annotation class native
+1 -1
View File
@@ -2,7 +2,7 @@
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:JsName("ComparatorJs")
@file:JsFileName("ComparatorJs")
package kotlin
@@ -58,7 +58,7 @@ internal annotation class marker
*
*/
@Retention(AnnotationRetention.BINARY)
@Target(FILE, CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
@Target(CLASS, FUNCTION, PROPERTY, CONSTRUCTOR, PROPERTY_GETTER, PROPERTY_SETTER)
public actual annotation class JsName(actual val name: String)
/**
@@ -66,7 +66,7 @@ public actual annotation class JsName(actual val name: String)
*
* This annotation can be applied only to files and only when the compilation granularity is `PER_FILE`.
*/
@Retention(AnnotationRetention.BINARY)
@Retention(AnnotationRetention.SOURCE)
@Target(FILE)
public actual annotation class JsFileName(actual val name: String)
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:JsName("AbstractMutableCollectionJs")
@file:JsFileName("AbstractMutableCollectionJs")
package kotlin.collections
@@ -8,7 +8,7 @@
* Copyright 2007 Google Inc.
*/
@file:JsName("AbstractMutableListJs")
@file:JsFileName("AbstractMutableListJs")
package kotlin.collections
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:JsName("ArrayListJs")
@file:JsFileName("ArrayListJs")
package kotlin.collections
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:JsName("KCallableJs")
@file:JsFileName("KCallableJs")
package kotlin.reflect
@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:kotlin.js.JsName("KClassJs")
@file:kotlin.js.JsFileName("KClassJs")
package kotlin.reflect
@@ -4,7 +4,7 @@
*/
@file:Suppress("IMPLEMENTING_FUNCTION_INTERFACE")
@file:JsName("KPropertyJs")
@file:JsFileName("KPropertyJs")
package kotlin.reflect
@@ -3,12 +3,10 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
// TODO: Suppress will be until the next bootstrapping, after the bootstrapping the annotation should be replaced with [kotlin.js.JsFileName]
@file:Suppress("ANNOTATION_IS_NOT_APPLICABLE_TO_MULTIFILE_CLASSES")
@file:kotlin.js.JsName("CollectionsKt")
@file:kotlin.js.JsFileName("CollectionsKt")
@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("CollectionsKt")
@file:OptIn(kotlin.experimental.ExperimentalTypeInference::class)
@file:OptIn(kotlin.experimental.ExperimentalTypeInference::class, kotlin.js.ExperimentalJsFileName::class)
package kotlin.collections
@@ -32,7 +32,6 @@ public actual annotation class JsExport {
*/
@Retention(AnnotationRetention.BINARY)
@Target(
AnnotationTarget.FILE,
AnnotationTarget.CLASS,
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY,