aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt1
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt54
2 files changed, 51 insertions, 4 deletions
diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
index 1f5719ea..2b56a2bf 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -131,6 +131,7 @@ class JavaSignatureProvider internal constructor(ctcc: CommentsToContentConverte
sourceSets = setOf(sourceSet)
) {
annotationsBlock(f)
+ f.visibility[sourceSet]?.takeIf { it !in ignoredVisibilities }?.name?.let { keyword("$it ") }
f.modifier[sourceSet]?.takeIf { it !in ignoredModifiers }?.name?.plus(" ")?.let { keyword(it) }
f.modifiers()[sourceSet]?.toSignatureString()?.let { keyword(it) }
val returnType = f.type
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>