diff options
author | Andriy Trypilka <54888768+tripolkaandrey@users.noreply.github.com> | 2022-05-27 11:20:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-27 10:20:58 +0200 |
commit | ad5f857a85ee4a1667197b7b2ddd285c4fc5e463 (patch) | |
tree | 39e6b8c5ac7dd37be05f326d2d1dd7ae6682560f /plugins/kotlin-as-java/src/test/kotlin | |
parent | 01eb31a3e0051a8faa2b3aa5cbf6ff8895ed1385 (diff) | |
download | dokka-ad5f857a85ee4a1667197b7b2ddd285c4fc5e463.tar.gz dokka-ad5f857a85ee4a1667197b7b2ddd285c4fc5e463.tar.bz2 dokka-ad5f857a85ee4a1667197b7b2ddd285c4fc5e463.zip |
Make the `kotlin-as-java` plugin include information about access modifiers for functions (#2510)
* Include access modifiers for Java functions
* Test that access modifiers are present
* Modify existing tests due to including access modifier in output
Diffstat (limited to 'plugins/kotlin-as-java/src/test/kotlin')
-rw-r--r-- | plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt index 635abf5a..b77dc23c 100644 --- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt +++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt @@ -176,7 +176,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() { divergentInstance { divergent { group { - +"final " + +"public final " group { link { +"String" @@ -331,7 +331,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() { ) { renderingStage = { _, _ -> writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-a-b-c/some-fun.html").firstSignature().match( - "final ", A("Integer"), A("someFun"), "(", Parameters( + "public final ", A("Integer"), A("someFun"), "(", Parameters( Parameter(A("Integer"), "xd") ), ")", Span(), ignoreSpanWithTokenStyle = true ) @@ -370,7 +370,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() { ) { renderingStage = { _, _ -> writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-a-b-c/some-fun.html").firstSignature().match( - "final ", A("Integer"), A("someFun"), "(", Parameters( + "public final ", A("Integer"), A("someFun"), "(", Parameters( Parameter(A("Map"), "<", A("String"), ", ", A("Integer"), "> xd"), ), ")", Span(), ignoreSpanWithTokenStyle = true ) @@ -436,7 +436,7 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() { ) { renderingStage = { _, _ -> writerPlugin.writer.renderedContent("root/kotlinAsJavaPlugin/-test-kt/sample.html").firstSignature().match( - "final static ", A("String"), A("sample"), "(", Parameters( + "public final static ", A("String"), A("sample"), "(", Parameters( Parameter(A("Integer"), "a"), ), ")", Span(), ignoreSpanWithTokenStyle = true ) @@ -583,6 +583,52 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() { } } } + + @Test + fun `Java function should keep its access modifier`(){ + val className = "Test" + val accessModifier = "public" + val methodName = "method" + + val testClassQuery = """ + |/src/main/kotlin/kotlinAsJavaPlugin/${className}.java + |package kotlinAsJavaPlugin; + | + |public class $className { + | $accessModifier void ${methodName}() { + | + | } + |} + """.trimMargin() + + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + + val writerPlugin = TestOutputWriterPlugin() + + testInline( + testClassQuery, + configuration, + pluginOverrides = listOf(writerPlugin), + cleanupOutput = true + ) { + renderingStage = { _, _ -> + val methodDocumentation = "root/kotlinAsJavaPlugin/-${className.toLowerCase()}/${methodName}.html" + + writerPlugin.writer.renderedContent(methodDocumentation) + .firstSignature() + .match( + "$accessModifier void ", A(methodName), "()", Span(), + ignoreSpanWithTokenStyle = true + ) + } + } + } } private val ContentNode.mainContents: List<ContentNode> |