aboutsummaryrefslogtreecommitdiff
path: root/plugins/base
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base')
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt18
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt12
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/FileLevelJvmNameTest.kt4
3 files changed, 15 insertions, 19 deletions
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 00c9a8e1..1ac519a0 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -23,10 +23,10 @@ import org.jetbrains.dokka.plugability.plugin
import org.jetbrains.dokka.plugability.querySingle
import org.jetbrains.dokka.transformers.sources.AsyncSourceToDocumentableTranslator
import org.jetbrains.dokka.utilities.DokkaLogger
-import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
-import org.jetbrains.kotlin.builtins.isBuiltinExtensionFunctionalType
import org.jetbrains.dokka.utilities.parallelMap
import org.jetbrains.dokka.utilities.parallelMapNotNull
+import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
+import org.jetbrains.kotlin.builtins.isBuiltinExtensionFunctionalType
import org.jetbrains.kotlin.builtins.isExtensionFunctionType
import org.jetbrains.kotlin.builtins.isSuspendFunctionTypeOrSubtype
import org.jetbrains.kotlin.codegen.isJvmStaticInObjectOrClassOrInterface
@@ -55,7 +55,6 @@ import org.jetbrains.kotlin.types.typeUtil.immediateSupertypes
import org.jetbrains.kotlin.types.typeUtil.isAnyOrNullableAny
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
-import java.lang.IllegalStateException
import java.nio.file.Paths
import org.jetbrains.kotlin.resolve.constants.AnnotationValue as ConstantsAnnotationValue
import org.jetbrains.kotlin.resolve.constants.ArrayValue as ConstantsArrayValue
@@ -931,21 +930,18 @@ private class DokkaDescriptorVisitor(
else -> StringValue(unquotedValue(toString()))
}
- private suspend fun AnnotationDescriptor.toAnnotation(scope: Annotations.AnnotationScope = Annotations.AnnotationScope.DIRECT): Annotations.Annotation {
- val dri = DRI.from(annotationClass as DeclarationDescriptor)
- return Annotations.Annotation(
+ private suspend fun AnnotationDescriptor.toAnnotation(scope: Annotations.AnnotationScope = Annotations.AnnotationScope.DIRECT): Annotations.Annotation =
+ Annotations.Annotation(
DRI.from(annotationClass as DeclarationDescriptor),
allValueArguments.map { it.key.asString() to it.value.toValue() }.filter {
it.second != null
}.toMap() as Map<String, AnnotationParameterValue>,
- mustBeDocumented(dri),
+ mustBeDocumented(),
scope
)
- }
- private fun AnnotationDescriptor.mustBeDocumented(dri: DRI): Boolean =
- if (dri.isJvmName()) false
- else annotationClass!!.annotations.hasAnnotation(FqName("kotlin.annotation.MustBeDocumented"))
+ private fun AnnotationDescriptor.mustBeDocumented(): Boolean =
+ annotationClass?.annotations?.hasAnnotation(FqName("kotlin.annotation.MustBeDocumented")) ?: false
private suspend fun PropertyDescriptor.getAnnotationsWithBackingField(): List<Annotations.Annotation> =
getAnnotations() + (backingField?.getAnnotations() ?: emptyList())
diff --git a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
index d88d9505..164e5f4a 100644
--- a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
+++ b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
@@ -1,19 +1,19 @@
package content.annotations
import matchers.content.*
-import org.jetbrains.dokka.pages.ContentPage
-import org.jetbrains.dokka.pages.PackagePageNode
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.Annotations
import org.jetbrains.dokka.model.StringValue
+import org.jetbrains.dokka.pages.ContentPage
+import org.jetbrains.dokka.pages.PackagePageNode
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
import org.junit.jupiter.api.Test
import utils.ParamAttributes
import utils.bareSignature
import utils.propertySignature
import kotlin.test.assertEquals
-import kotlin.test.assertFalse
+import kotlin.test.assertTrue
class ContentForAnnotationsTest : BaseAbstractTest() {
@@ -243,7 +243,7 @@ class ContentForAnnotationsTest : BaseAbstractTest() {
dri = DRI("kotlin.jvm", "JvmName"),
params = mapOf("name" to StringValue(name)),
scope = Annotations.AnnotationScope.DIRECT,
- mustBeDocumented = false
+ mustBeDocumented = true
)
val property = modules.flatMap { it.packages }.flatMap { it.properties }.first()
@@ -255,11 +255,11 @@ class ContentForAnnotationsTest : BaseAbstractTest() {
}
assertEquals(expectedAnnotation("xd"), getterAnnotation)
- assertFalse(getterAnnotation?.mustBeDocumented!!)
+ assertTrue(getterAnnotation?.mustBeDocumented!!)
assertEquals(Annotations.AnnotationScope.DIRECT, getterAnnotation.scope)
assertEquals(expectedAnnotation("asd"), setterAnnotation)
- assertFalse(setterAnnotation?.mustBeDocumented!!)
+ assertTrue(setterAnnotation?.mustBeDocumented!!)
assertEquals(Annotations.AnnotationScope.DIRECT, setterAnnotation.scope)
}
}
diff --git a/plugins/base/src/test/kotlin/content/annotations/FileLevelJvmNameTest.kt b/plugins/base/src/test/kotlin/content/annotations/FileLevelJvmNameTest.kt
index f2fd518c..ff54f8a7 100644
--- a/plugins/base/src/test/kotlin/content/annotations/FileLevelJvmNameTest.kt
+++ b/plugins/base/src/test/kotlin/content/annotations/FileLevelJvmNameTest.kt
@@ -74,7 +74,7 @@ class FileLevelJvmNameTest : BaseAbstractTest() {
dri = DRI("kotlin.jvm", "JvmName"),
params = mapOf("name" to StringValue("CustomJvmName")),
scope = Annotations.AnnotationScope.FILE,
- mustBeDocumented = false
+ mustBeDocumented = true
)
val function = modules.flatMap { it.packages }.first().functions.first()
val annotation = function.extra[Annotations]?.fileLevelAnnotations?.entries?.first()?.value?.single()
@@ -97,7 +97,7 @@ class FileLevelJvmNameTest : BaseAbstractTest() {
dri = DRI("kotlin.jvm", "JvmName"),
params = mapOf("name" to StringValue("CustomJvmName")),
scope = Annotations.AnnotationScope.FILE,
- mustBeDocumented = false
+ mustBeDocumented = true
)
val properties = modules.flatMap { it.packages }.first().properties.first()
val annotation = properties.extra[Annotations]?.fileLevelAnnotations?.entries?.first()?.value?.single()