[ObjCExport] Fix 'MustBeDocumented' annotation missing on non value parameters
This commit is contained in:
committed by
Space Team
parent
885a7dcd8f
commit
1440e66519
+2
-1
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.konan.objcexport
|
package org.jetbrains.kotlin.backend.konan.objcexport
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.backend.common.descriptors.allParameters
|
||||||
import org.jetbrains.kotlin.backend.common.serialization.findSourceFile
|
import org.jetbrains.kotlin.backend.common.serialization.findSourceFile
|
||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.*
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.enumEntries
|
import org.jetbrains.kotlin.backend.konan.descriptors.enumEntries
|
||||||
@@ -807,7 +808,7 @@ class ObjCExportTranslatorImpl(
|
|||||||
} else emptyList()
|
} else emptyList()
|
||||||
|
|
||||||
val visibilityComments = visibilityComments(method.visibility, "method")
|
val visibilityComments = visibilityComments(method.visibility, "method")
|
||||||
val paramComments = method.valueParameters.flatMap { parameterDescriptor ->
|
val paramComments = method.allParameters.flatMap { parameterDescriptor ->
|
||||||
parameters.find { parameter -> parameter.origin?.name == parameterDescriptor.name }?.let { parameter ->
|
parameters.find { parameter -> parameter.origin?.name == parameterDescriptor.name }?.let { parameter ->
|
||||||
mustBeDocumentedParamAttributeList(parameter, descriptor = parameterDescriptor)
|
mustBeDocumentedParamAttributeList(parameter, descriptor = parameterDescriptor)
|
||||||
} ?: emptyList()
|
} ?: emptyList()
|
||||||
|
|||||||
+4
-2
@@ -374,8 +374,6 @@ class ObjCExportLazyImpl(
|
|||||||
private val lazy: ObjCExportLazyImpl,
|
private val lazy: ObjCExportLazyImpl,
|
||||||
) : LazyObjCInterface(name = name.objCName, generics = emptyList(), categoryName = categoryName, attributes = emptyList()) {
|
) : LazyObjCInterface(name = name.objCName, generics = emptyList(), categoryName = categoryName, attributes = emptyList()) {
|
||||||
|
|
||||||
override val origin: ObjCExportStubOrigin? = ObjCExportStubOrigin(classDescriptor)
|
|
||||||
|
|
||||||
override fun computeRealStub(): ObjCInterface = lazy.translator.translateExtensions(
|
override fun computeRealStub(): ObjCInterface = lazy.translator.translateExtensions(
|
||||||
classDescriptor,
|
classDescriptor,
|
||||||
declarations.mapNotNull { declaration ->
|
declarations.mapNotNull { declaration ->
|
||||||
@@ -403,6 +401,10 @@ private abstract class LazyObjCInterface(
|
|||||||
|
|
||||||
private val realStub by lazy { computeRealStub() }
|
private val realStub by lazy { computeRealStub() }
|
||||||
|
|
||||||
|
override val origin: ObjCExportStubOrigin? by lazy {
|
||||||
|
realStub.origin
|
||||||
|
}
|
||||||
|
|
||||||
override val members: List<ObjCExportStub>
|
override val members: List<ObjCExportStub>
|
||||||
get() = realStub.members
|
get() = realStub.members
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -13,14 +13,18 @@ import org.jetbrains.kotlin.resolve.source.PsiSourceElement
|
|||||||
fun ObjCExportStubOrigin(descriptor: DeclarationDescriptor?): ObjCExportStubOrigin? {
|
fun ObjCExportStubOrigin(descriptor: DeclarationDescriptor?): ObjCExportStubOrigin? {
|
||||||
if (descriptor == null) return null
|
if (descriptor == null) return null
|
||||||
|
|
||||||
|
if (descriptor is DeserializedDescriptor) {
|
||||||
|
return ObjCExportStubOrigin.Binary(descriptor.name, descriptor.extractSerializedKdocString())
|
||||||
|
}
|
||||||
|
|
||||||
if (descriptor is DeclarationDescriptorWithSource) {
|
if (descriptor is DeclarationDescriptorWithSource) {
|
||||||
return ObjCExportStubOrigin.Source(descriptor.name, descriptor.findKDocString(), (descriptor.source as? PsiSourceElement)?.psi)
|
return ObjCExportStubOrigin.Source(descriptor.name, descriptor.findKDocString(), (descriptor.source as? PsiSourceElement)?.psi)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(descriptor is DeserializedDescriptor) { "Expected '$descriptor' to implement ${DeserializedDescriptor::class.simpleName}" }
|
|
||||||
return ObjCExportStubOrigin.Binary(descriptor.name, descriptor.extractSerializedKdocString())
|
return ObjCExportStubOrigin.Binary(descriptor.name, descriptor.extractSerializedKdocString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun ObjCProtocolImpl(
|
fun ObjCProtocolImpl(
|
||||||
name: String,
|
name: String,
|
||||||
descriptor: ClassDescriptor,
|
descriptor: ClassDescriptor,
|
||||||
|
|||||||
+15
@@ -115,6 +115,21 @@ class ObjCExportHeaderGeneratorTest(val generator: HeaderGenerator) {
|
|||||||
doTest(headersTestDataDir.resolve("kdocWithBlockTags"))
|
doTest(headersTestDataDir.resolve("kdocWithBlockTags"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - functionWithMustBeDocumentedAnnotation`() {
|
||||||
|
doTest(headersTestDataDir.resolve("functionWithMustBeDocumentedAnnotation"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - parameterWithMustBeDocumentedAnnotation`() {
|
||||||
|
doTest(headersTestDataDir.resolve("parameterWithMustBeDocumentedAnnotation"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `test - receiverWithMustBeDocumentedAnnotation`() {
|
||||||
|
doTest(headersTestDataDir.resolve("receiverWithMustBeDocumentedAnnotation"))
|
||||||
|
}
|
||||||
|
|
||||||
fun interface HeaderGenerator {
|
fun interface HeaderGenerator {
|
||||||
fun generateHeaders(root: File): String
|
fun generateHeaders(root: File): String
|
||||||
}
|
}
|
||||||
|
|||||||
+34
@@ -0,0 +1,34 @@
|
|||||||
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSDictionary.h>
|
||||||
|
#import <Foundation/NSError.h>
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
|
#import <Foundation/NSSet.h>
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSValue.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||||
|
#pragma clang diagnostic ignored "-Wincompatible-property-type"
|
||||||
|
#pragma clang diagnostic ignored "-Wnullability"
|
||||||
|
|
||||||
|
#pragma push_macro("_Nullable_result")
|
||||||
|
#if !__has_feature(nullability_nullable_result)
|
||||||
|
#undef _Nullable_result
|
||||||
|
#define _Nullable_result _Nullable
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @note annotations
|
||||||
|
* ImportantAnnotation
|
||||||
|
*/
|
||||||
|
__attribute__((objc_subclassing_restricted))
|
||||||
|
@interface Foo : Base
|
||||||
|
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||||
|
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma pop_macro("_Nullable_result")
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
@kotlin.annotation.MustBeDocumented
|
||||||
|
annotation class ImportantAnnotation
|
||||||
|
|
||||||
|
@ImportantAnnotation
|
||||||
|
class Foo
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSDictionary.h>
|
||||||
|
#import <Foundation/NSError.h>
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
|
#import <Foundation/NSSet.h>
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSValue.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||||
|
#pragma clang diagnostic ignored "-Wincompatible-property-type"
|
||||||
|
#pragma clang diagnostic ignored "-Wnullability"
|
||||||
|
|
||||||
|
#pragma push_macro("_Nullable_result")
|
||||||
|
#if !__has_feature(nullability_nullable_result)
|
||||||
|
#undef _Nullable_result
|
||||||
|
#define _Nullable_result _Nullable
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__attribute__((objc_subclassing_restricted))
|
||||||
|
@interface Foo : Base
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param myPrameter annotations ImportantAnnotation
|
||||||
|
*/
|
||||||
|
- (instancetype)initWithMyPrameter:(NSString *)myPrameter __attribute__((swift_name("init(myPrameter:)"))) __attribute__((objc_designated_initializer));
|
||||||
|
@property (readonly) NSString *myPrameter __attribute__((swift_name("myPrameter")));
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma pop_macro("_Nullable_result")
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
@kotlin.annotation.MustBeDocumented
|
||||||
|
annotation class ImportantAnnotation
|
||||||
|
|
||||||
|
class Foo(@param:ImportantAnnotation val myPrameter: String)
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
#import <Foundation/NSArray.h>
|
||||||
|
#import <Foundation/NSDictionary.h>
|
||||||
|
#import <Foundation/NSError.h>
|
||||||
|
#import <Foundation/NSObject.h>
|
||||||
|
#import <Foundation/NSSet.h>
|
||||||
|
#import <Foundation/NSString.h>
|
||||||
|
#import <Foundation/NSValue.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||||
|
#pragma clang diagnostic ignored "-Wincompatible-property-type"
|
||||||
|
#pragma clang diagnostic ignored "-Wnullability"
|
||||||
|
|
||||||
|
#pragma push_macro("_Nullable_result")
|
||||||
|
#if !__has_feature(nullability_nullable_result)
|
||||||
|
#undef _Nullable_result
|
||||||
|
#define _Nullable_result _Nullable
|
||||||
|
#endif
|
||||||
|
|
||||||
|
__attribute__((objc_subclassing_restricted))
|
||||||
|
@interface FooKt : Base
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param receiver annotations ImportantAnnotation
|
||||||
|
*/
|
||||||
|
+ (NSString *)foo:(id)receiver __attribute__((swift_name("foo(_:)")));
|
||||||
|
@end
|
||||||
|
|
||||||
|
#pragma pop_macro("_Nullable_result")
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
Vendored
+5
@@ -0,0 +1,5 @@
|
|||||||
|
@Target(AnnotationTarget.VALUE_PARAMETER)
|
||||||
|
@MustBeDocumented
|
||||||
|
annotation class ImportantAnnotation
|
||||||
|
|
||||||
|
fun @receiver:ImportantAnnotation Any.foo() = toString()
|
||||||
Reference in New Issue
Block a user