aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2020-12-29 14:38:19 +0100
committerGitHub <noreply@github.com>2020-12-29 14:38:19 +0100
commitf5e7cffbebb66b989c64bdda61e1f7809ddc6068 (patch)
treeea0ef4b550f9a55681a915d5cb4d9f1beca22041 /plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
parente55f3b015faec3f62e829a2aa5984e4bd6d5037e (diff)
downloaddokka-f5e7cffbebb66b989c64bdda61e1f7809ddc6068.tar.gz
dokka-f5e7cffbebb66b989c64bdda61e1f7809ddc6068.tar.bz2
dokka-f5e7cffbebb66b989c64bdda61e1f7809ddc6068.zip
Parsing of JvmName (#1675)
* Parsing of JvmName * Make JvmName processor run after KaJ
Diffstat (limited to 'plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt')
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
index b90c7350..d88d9505 100644
--- a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
+++ b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
@@ -4,10 +4,16 @@ 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.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
class ContentForAnnotationsTest : BaseAbstractTest() {
@@ -18,6 +24,7 @@ class ContentForAnnotationsTest : BaseAbstractTest() {
sourceSet {
sourceRoots = listOf("src/")
analysisPlatform = "jvm"
+ classpath += jvmStdlibPath!!
}
}
}
@@ -218,4 +225,43 @@ class ContentForAnnotationsTest : BaseAbstractTest() {
}
}
}
+
+ @Test
+ fun `JvmName for property with setter and getter`(){
+ testInline(
+ """
+ |/src/main/kotlin/test/source.kt
+ |package test
+ |@get:JvmName("xd")
+ |@set:JvmName("asd")
+ |var property: String
+ | get() = ""
+ | set(value) {}
+ """.trimIndent(), testConfiguration) {
+ documentablesCreationStage = { modules ->
+ fun expectedAnnotation(name: String) = Annotations.Annotation(
+ dri = DRI("kotlin.jvm", "JvmName"),
+ params = mapOf("name" to StringValue(name)),
+ scope = Annotations.AnnotationScope.DIRECT,
+ mustBeDocumented = false
+ )
+
+ val property = modules.flatMap { it.packages }.flatMap { it.properties }.first()
+ val getterAnnotation = property.getter?.extra?.get(Annotations)?.let {
+ it.directAnnotations.entries.firstNotNullResult { (_, annotations) -> annotations.firstOrNull() }
+ }
+ val setterAnnotation = property.getter?.extra?.get(Annotations)?.let {
+ it.directAnnotations.entries.firstNotNullResult { (_, annotations) -> annotations.firstOrNull() }
+ }
+
+ assertEquals(expectedAnnotation("xd"), getterAnnotation)
+ assertFalse(getterAnnotation?.mustBeDocumented!!)
+ assertEquals(Annotations.AnnotationScope.DIRECT, getterAnnotation.scope)
+
+ assertEquals(expectedAnnotation("asd"), setterAnnotation)
+ assertFalse(setterAnnotation?.mustBeDocumented!!)
+ assertEquals(Annotations.AnnotationScope.DIRECT, setterAnnotation.scope)
+ }
+ }
+ }
}