aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/test/kotlin
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-06-22 17:14:58 +0200
committerGitHub <noreply@github.com>2022-06-22 17:14:58 +0200
commitfb589740213286cc5c2f240f248a10752187a9d7 (patch)
tree7e4d0e6b2568a4f001a3aa1aab608f5c60368c1b /plugins/kotlin-as-java/src/test/kotlin
parent3f4336d5dfc2dbeee3d4f51b576cfa7c8568b759 (diff)
downloaddokka-fb589740213286cc5c2f240f248a10752187a9d7.tar.gz
dokka-fb589740213286cc5c2f240f248a10752187a9d7.tar.bz2
dokka-fb589740213286cc5c2f240f248a10752187a9d7.zip
Render annotations for KaJ signatures (#2549)
Fixes #2527
Diffstat (limited to 'plugins/kotlin-as-java/src/test/kotlin')
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt76
1 files changed, 75 insertions, 1 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt
index 5f755ff3..5ce3ac41 100644
--- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt
+++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaSignatureTest.kt
@@ -6,6 +6,7 @@ import org.jetbrains.dokka.jdk
import org.junit.jupiter.api.Test
import signatures.firstSignature
import signatures.renderedContent
+import signatures.signature
import utils.*
class KotlinAsJavaSignatureTest : BaseAbstractTest() {
@@ -56,4 +57,77 @@ class KotlinAsJavaSignatureTest : BaseAbstractTest() {
}
}
}
-} \ No newline at end of file
+
+ @Test
+ fun `should display annotations`() {
+ val writerPlugin = TestOutputWriterPlugin()
+
+ testInline(
+ """
+ |/src/main/kotlin/kotlinAsJavaPlugin/Test.kt
+ |package kotlinAsJavaPlugin
+ |
+ |@MustBeDocumented
+ |annotation class OnClass
+ |
+ |@MustBeDocumented
+ |annotation class OnMethod
+ |
+ |@MustBeDocumented
+ |annotation class OnParameter
+ |
+ |@Target(AnnotationTarget.TYPE)
+ |@MustBeDocumented
+ |annotation class OnType
+ |
+ |@Target(AnnotationTarget.TYPE_PARAMETER)
+ |@MustBeDocumented
+ |annotation class OnTypeParameter
+ |
+ |@OnClass
+ |class Clazz<@OnTypeParameter T : @OnType Any> {
+ | @OnMethod
+ | fun <@OnTypeParameter T : @OnType Any> withParams(@OnParameter str1: String, str2: String): Boolean {
+ | return str1 == str2
+ | }
+ |}
+ """.trimIndent(),
+ configuration,
+ pluginOverrides = listOf(writerPlugin)
+ ) {
+ renderingStage = { _, _ ->
+ val signatures = writerPlugin.writer
+ .renderedContent("root/kotlinAsJavaPlugin/-clazz/index.html")
+ .signature()
+
+ val classSignature = signatures[0]
+ classSignature.match(
+ Div(Div("@", A("OnClass"), "()")),
+ "public final class ", A("Clazz"),
+ // <@OnTypeParameter() T extends @OnType() Object>
+ "<", Span("@", A("OnTypeParameter"), "() "), "T extends ", Span("@", A("OnType"), "() "), A("Object"), ">",
+ Span(),
+ ignoreSpanWithTokenStyle = true
+ )
+
+ val functionSignature = signatures[2]
+ functionSignature.match(
+ Div(Div("@", A("OnMethod"), "()")),
+ "public final ", A("Boolean"), A("withParams"),
+ // <@OnTypeParameter() T extends @OnType() Object>
+ "<", Span("@", A("OnTypeParameter"), "() "), "T extends ", Span("@", A("OnType"), "() "), A("Any"), ">(",
+ Span(
+ Span(
+ Span("@", A("OnParameter"), "() "),
+ A("String"), "str1, "
+ ),
+ Span(
+ A("String"), "str2"
+ )
+ ), ")", Span(),
+ ignoreSpanWithTokenStyle = true
+ )
+ }
+ }
+ }
+}