[ObjCExport] Document getObjCClassOrProtocolName

^KT-65670 Fixed
This commit is contained in:
Sebastian Sellmair
2024-02-28 09:14:35 +01:00
committed by Space Team
parent 436e16efd8
commit b7de3709e4
@@ -10,6 +10,25 @@ import org.jetbrains.kotlin.analysis.api.symbols.*
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportClassOrProtocolName
import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly
/**
* Constructs the name of the given [KtClassLikeSymbol] by composing
* ```
* {Current Framework Name}{Additional Module Prefix}{ObjC Class or Protocol Name}
* (1) (2) (3)
* ```
*
* 1) Current Framework Name: See [KtObjCExportConfiguration.frameworkName]
* 2) Additional Module Prefix: Dependency modules that are not directly exported will add the prefix to distinguish from which
* dependency module a symbol came from. Note: This module name can be abbreviated e.g. `LongModuleName` will be `LMN`
* 3) ObjC Class or Protocol Name: This is either the name of the symbol, or the defined name in the `ObjCName` annotation
* (see [resolveObjCNameAnnotation]): e.g.
* ```
* @ObjCName("ObjCFoo")
* class Foo
* ```
* will use `ObjCFoo` instead of the class name `Foo`
*
*/
context(KtAnalysisSession, KtObjCExportSession)
fun KtClassLikeSymbol.getObjCClassOrProtocolName(): ObjCExportClassOrProtocolName {
val resolvedObjCNameAnnotation = resolveObjCNameAnnotation()
@@ -118,7 +137,7 @@ context(KtAnalysisSession, KtObjCExportSession)
private fun KtSymbol.getObjCModuleNamePrefix(): String? {
val module = getContainingModule()
val moduleName = module.getObjCKotlinModuleName() ?: return null
if(moduleName == "stdlib" || moduleName == "kotlin-stdlib-common") return "Kotlin"
if (moduleName == "stdlib" || moduleName == "kotlin-stdlib-common") return "Kotlin"
if (moduleName in configuration.exportedModuleNames) return null
return abbreviateModuleName(moduleName)
}