[K/JS] Add ability to exclude declarations from export by a new annotation @JsExport.Ignore.
This commit is contained in:
+3
-2
@@ -22,8 +22,6 @@ import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
@@ -740,6 +738,9 @@ private fun shouldDeclarationBeExported(declaration: IrDeclarationWithName, cont
|
||||
if (context.additionalExportedDeclarations.contains(declaration))
|
||||
return true
|
||||
|
||||
if (declaration.isJsExportIgnore())
|
||||
return false
|
||||
|
||||
if (declaration is IrOverridableDeclaration<*>) {
|
||||
val overriddenNonEmpty = declaration
|
||||
.overriddenSymbols
|
||||
|
||||
+2
-1
@@ -113,7 +113,7 @@ class JsClassGenerator(private val irClass: IrClass, val context: JsGenerationCo
|
||||
if (property.getter?.extensionReceiverParameter != null || property.setter?.extensionReceiverParameter != null)
|
||||
continue
|
||||
|
||||
if (!property.visibility.isPublicAPI || property.isSimpleProperty)
|
||||
if (!property.visibility.isPublicAPI || property.isSimpleProperty || property.isJsExportIgnore())
|
||||
continue
|
||||
|
||||
if (
|
||||
@@ -223,6 +223,7 @@ class JsClassGenerator(private val irClass: IrClass, val context: JsGenerationCo
|
||||
}
|
||||
|
||||
private fun IrSimpleFunction.isDefinedInsideExportedInterface(): Boolean {
|
||||
if (isJsExportIgnore() || correspondingPropertySymbol?.owner?.isJsExportIgnore() == true) return false
|
||||
return (!isFakeOverride && parentClassOrNull.isExportedInterface(context.staticContext.backendContext)) ||
|
||||
overriddenSymbols.any { it.owner.isDefinedInsideExportedInterface() }
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ object JsAnnotations {
|
||||
val jsQualifierFqn = FqName("kotlin.js.JsQualifier")
|
||||
val jsExportFqn = FqName("kotlin.js.JsExport")
|
||||
val jsImplicitExportFqn = FqName("kotlin.js.JsImplicitExport")
|
||||
val jsExportIgnoreFqn = FqName("kotlin.js.JsExport.Ignore")
|
||||
val jsNativeGetter = FqName("kotlin.js.nativeGetter")
|
||||
val jsNativeSetter = FqName("kotlin.js.nativeSetter")
|
||||
val jsNativeInvoke = FqName("kotlin.js.nativeInvoke")
|
||||
@@ -61,6 +62,9 @@ fun IrAnnotationContainer.isJsExport(): Boolean =
|
||||
fun IrAnnotationContainer.isJsImplicitExport(): Boolean =
|
||||
hasAnnotation(JsAnnotations.jsImplicitExportFqn)
|
||||
|
||||
fun IrAnnotationContainer.isJsExportIgnore(): Boolean =
|
||||
hasAnnotation(JsAnnotations.jsExportIgnoreFqn)
|
||||
|
||||
fun IrAnnotationContainer.isJsNativeGetter(): Boolean = hasAnnotation(JsAnnotations.jsNativeGetter)
|
||||
|
||||
fun IrAnnotationContainer.isJsNativeSetter(): Boolean = hasAnnotation(JsAnnotations.jsNativeSetter)
|
||||
|
||||
Reference in New Issue
Block a user