Add note comment for protected properties
^KT-51593 Fixed Merge-request: KT-MR-6593 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
+11
-5
@@ -614,7 +614,9 @@ internal class ObjCExportTranslatorImpl(
|
||||
val declarationAttributes = mutableListOf(swiftNameAttribute(name))
|
||||
declarationAttributes.addIfNotNull(mapper.getDeprecation(property)?.toDeprecationAttribute())
|
||||
|
||||
val commentOrNull = objCCommentOrNull(mustBeDocumentedAttributeList(property.annotations))
|
||||
val visibilityComments = visibilityComments(property.visibility, "property")
|
||||
|
||||
val commentOrNull = objCCommentOrNull(mustBeDocumentedAttributeList(property.annotations) + visibilityComments)
|
||||
return ObjCProperty(name, property, type, attributes, setterName, getterName, declarationAttributes, commentOrNull)
|
||||
}
|
||||
|
||||
@@ -770,10 +772,7 @@ internal class ObjCExportTranslatorImpl(
|
||||
}
|
||||
} else emptyList()
|
||||
|
||||
val visibilityComments = when (method.visibility) {
|
||||
DescriptorVisibilities.PROTECTED -> listOf("@note This method has protected visibility in Kotlin source and is intended only for use by subclasses.")
|
||||
else -> emptyList()
|
||||
}
|
||||
val visibilityComments = visibilityComments(method.visibility, "method")
|
||||
val paramComments = parameters.flatMap { parameter ->
|
||||
parameter.descriptor?.let { mustBeDocumentedParamAttributeList(parameter, descriptor = it) } ?: emptyList()
|
||||
}
|
||||
@@ -781,6 +780,13 @@ internal class ObjCExportTranslatorImpl(
|
||||
return objCCommentOrNull(annotationsComments + paramComments + throwsComments + visibilityComments)
|
||||
}
|
||||
|
||||
private fun visibilityComments(visibility: DescriptorVisibility, kind: String): List<String> {
|
||||
return when (visibility) {
|
||||
DescriptorVisibilities.PROTECTED -> listOf("@note This $kind has protected visibility in Kotlin source and is intended only for use by subclasses.")
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private fun mustBeDocumentedParamAttributeList(parameter: ObjCParameter, descriptor: ParameterDescriptor): List<String> {
|
||||
val mbdAnnotations = mustBeDocumentedAnnotations(descriptor.annotations).joinToString(" ")
|
||||
return if (mbdAnnotations.isNotEmpty()) listOf("@param ${parameter.name} annotations $mbdAnnotations") else emptyList()
|
||||
|
||||
@@ -1020,7 +1020,6 @@ __attribute__((swift_name("Bar")))
|
||||
* @note This method has protected visibility in Kotlin source and is intended only for use by subclasses.
|
||||
*/
|
||||
- (void)bazNodocParam:(int32_t)nodocParam fooParam:(int32_t)fooParam completionHandler:(void (^)(KtInt * _Nullable, NSError * _Nullable))completionHandler __attribute__((swift_name("baz(nodocParam:fooParam:completionHandler:)"))) __attribute__((deprecated("warning")));
|
||||
- (void)notKDoc __attribute__((swift_name("notKDoc()")));
|
||||
|
||||
/** My property
|
||||
***
|
||||
@@ -1031,6 +1030,11 @@ __attribute__((swift_name("Bar")))
|
||||
* BugReport(assignedTo="me", status="open")
|
||||
*/
|
||||
@property (readonly) NSString *greeting __attribute__((swift_name("greeting")));
|
||||
|
||||
/**
|
||||
* @note This property has protected visibility in Kotlin source and is intended only for use by subclasses.
|
||||
*/
|
||||
@property (readonly) NSString *farewell __attribute__((swift_name("farewell")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
|
||||
@@ -958,7 +958,6 @@ __attribute__((swift_name("Bar")))
|
||||
* @note This method has protected visibility in Kotlin source and is intended only for use by subclasses.
|
||||
*/
|
||||
- (void)bazNodocParam:(int32_t)nodocParam fooParam:(int32_t)fooParam completionHandler:(void (^)(KtInt * _Nullable, NSError * _Nullable))completionHandler __attribute__((swift_name("baz(nodocParam:fooParam:completionHandler:)"))) __attribute__((deprecated("warning")));
|
||||
- (void)notKDoc __attribute__((swift_name("notKDoc()")));
|
||||
|
||||
/**
|
||||
* @note annotations
|
||||
@@ -966,6 +965,11 @@ __attribute__((swift_name("Bar")))
|
||||
* BugReport(assignedTo="me", status="open")
|
||||
*/
|
||||
@property (readonly) NSString *greeting __attribute__((swift_name("greeting")));
|
||||
|
||||
/**
|
||||
* @note This property has protected visibility in Kotlin source and is intended only for use by subclasses.
|
||||
*/
|
||||
@property (readonly) NSString *farewell __attribute__((swift_name("farewell")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
|
||||
@@ -958,7 +958,6 @@ __attribute__((swift_name("Bar")))
|
||||
* @note This method has protected visibility in Kotlin source and is intended only for use by subclasses.
|
||||
*/
|
||||
- (void)bazNodocParam:(int32_t)nodocParam fooParam:(int32_t)fooParam completionHandler:(void (^)(KtInt * _Nullable, NSError * _Nullable))completionHandler __attribute__((swift_name("baz(nodocParam:fooParam:completionHandler:)"))) __attribute__((deprecated("warning")));
|
||||
- (void)notKDoc __attribute__((swift_name("notKDoc()")));
|
||||
|
||||
/**
|
||||
* @note annotations
|
||||
@@ -966,6 +965,11 @@ __attribute__((swift_name("Bar")))
|
||||
* BugReport(assignedTo="me", status="open")
|
||||
*/
|
||||
@property (readonly) NSString *greeting __attribute__((swift_name("greeting")));
|
||||
|
||||
/**
|
||||
* @note This property has protected visibility in Kotlin source and is intended only for use by subclasses.
|
||||
*/
|
||||
@property (readonly) NSString *farewell __attribute__((swift_name("farewell")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
|
||||
@@ -49,5 +49,6 @@ class Bar {
|
||||
}
|
||||
|
||||
// Not a kDoc-formatted comment
|
||||
fun notKDoc() {}
|
||||
protected val farewell: String
|
||||
get() { return "Bye bye!" }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user