[ObjCExport] Analysis Api: Ensure KDocs being exported by providing ObjCExportStubOrigin

^KT-64888 Fixed


Co-authored-by: Sebastian Sellmair <Sebastian.sellmair@jetbrains.com>


Merge-request: KT-MR-13854
Merged-by: Eugene Levenetc <Eugene.Levenetc@jetbrains.com>
This commit is contained in:
Sebastian Sellmair
2024-01-14 01:13:58 +00:00
committed by Space Team
parent a8914acb68
commit a713d66b7b
6 changed files with 19 additions and 20 deletions
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportStubOrigin
import org.jetbrains.kotlin.objcexport.analysisApiUtils.getKDocString import org.jetbrains.kotlin.objcexport.analysisApiUtils.getKDocString
context(KtAnalysisSession) context(KtAnalysisSession)
fun KtSymbol.getObjCStubOrigin(): ObjCExportStubOrigin { fun KtSymbol.getObjCExportStubOrigin(): ObjCExportStubOrigin {
// TODO: Differentiate origins // TODO: Differentiate origins
// TODO: Extract kdoc from deserialized symbols // TODO: Extract kdoc from deserialized symbols
return ObjCExportStubOrigin.Source( return ObjCExportStubOrigin.Source(
@@ -25,7 +25,7 @@ fun KtClassOrObjectSymbol.translateToObjCClass(): ObjCClass? {
val name = getObjCClassOrProtocolName() val name = getObjCClassOrProtocolName()
val comment: ObjCComment? = annotationsList.translateToObjCComment() val comment: ObjCComment? = annotationsList.translateToObjCComment()
val origin: ObjCExportStubOrigin = getObjCStubOrigin() val origin: ObjCExportStubOrigin = getObjCExportStubOrigin()
val superProtocols: List<String> = superProtocols() val superProtocols: List<String> = superProtocols()
val members: List<ObjCExportStub> = members().flatMap { it.translateToObjCExportStubs() } val members: List<ObjCExportStub> = members().flatMap { it.translateToObjCExportStubs() }
val categoryName: String? = null val categoryName: String? = null
@@ -15,13 +15,13 @@ fun KtConstructorSymbol.translateToObjCConstructors(): List<ObjCMethod> {
result.add( result.add(
ObjCMethod( ObjCMethod(
null, comment = null,
null, origin = getObjCExportStubOrigin(),
false, isInstanceMethod = false,
ObjCInstanceType, returnType = ObjCInstanceType,
listOf("new"), selectors = listOf("new"),
emptyList(), parameters = emptyList(),
listOf( attributes = listOf(
"availability(swift, unavailable, message=\"use object initializers instead\")" "availability(swift, unavailable, message=\"use object initializers instead\")"
) )
) )
@@ -48,7 +48,6 @@ internal fun KtFunctionLikeSymbol.buildObjCMethod(
unavailable: Boolean = false, unavailable: Boolean = false,
): ObjCMethod { ): ObjCMethod {
val bridge = getMethodBridge() val bridge = getMethodBridge()
val origin: ObjCExportStubOrigin? = null
val returnType: ObjCType = mapReturnType(bridge.returnBridge) val returnType: ObjCType = mapReturnType(bridge.returnBridge)
val parameters = translateToObjCParameters(bridge) val parameters = translateToObjCParameters(bridge)
val selector = getSelector(bridge) val selector = getSelector(bridge)
@@ -82,7 +81,7 @@ internal fun KtFunctionLikeSymbol.buildObjCMethod(
return ObjCMethod( return ObjCMethod(
comment = comment, comment = comment,
origin = origin, origin = getObjCExportStubOrigin(),
isInstanceMethod = bridge.isInstance || isConstructor, isInstanceMethod = bridge.isInstance || isConstructor,
returnType = returnType, returnType = returnType,
selectors = selectors, selectors = selectors,
@@ -54,13 +54,13 @@ fun KtPropertySymbol.buildProperty(): ObjCProperty {
//declarationAttributes.addIfNotNull(mapper.getDeprecation(property)?.toDeprecationAttribute()) //declarationAttributes.addIfNotNull(mapper.getDeprecation(property)?.toDeprecationAttribute())
return ObjCProperty( return ObjCProperty(
name, name = name,
null, comment = null,
null, origin = getObjCExportStubOrigin(),
type!!, type = type!!,
attributes, propertyAttributes = attributes,
setterName, setterName = setterName,
getterName, getterName = getterName,
declarationAttributes declarationAttributes = declarationAttributes
) )
} }
@@ -33,7 +33,7 @@ fun KtClassOrObjectSymbol.translateToObjCProtocol(): ObjCProtocol? {
return ObjCProtocolImpl( return ObjCProtocolImpl(
name = name.objCName, name = name.objCName,
comment = comment, comment = comment,
origin = getObjCStubOrigin(), origin = getObjCExportStubOrigin(),
attributes = name.toNameAttributes(), attributes = name.toNameAttributes(),
superProtocols = superProtocols(), superProtocols = superProtocols(),
members = members members = members