aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Languages/JavaLanguageService.kt3
-rw-r--r--core/src/main/kotlin/Model/DocumentationNode.kt2
-rw-r--r--core/src/main/kotlin/javadoc/docbase.kt10
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt15
-rw-r--r--core/testdata/javadoc/stringarr.kt8
5 files changed, 33 insertions, 5 deletions
diff --git a/core/src/main/kotlin/Languages/JavaLanguageService.kt b/core/src/main/kotlin/Languages/JavaLanguageService.kt
index f3b567d3..59bedd02 100644
--- a/core/src/main/kotlin/Languages/JavaLanguageService.kt
+++ b/core/src/main/kotlin/Languages/JavaLanguageService.kt
@@ -45,7 +45,8 @@ class JavaLanguageService : LanguageService {
fun getArrayElementType(node: DocumentationNode): DocumentationNode? = when (node.qualifiedName()) {
"kotlin.Array" ->
- node.details(NodeKind.Type).singleOrNull()?.let { et -> getArrayElementType(et) ?: et } ?: DocumentationNode("Object", node.content, NodeKind.ExternalClass)
+ node.details(NodeKind.Type).singleOrNull()?.let { et -> getArrayElementType(et) ?: et } ?:
+ DocumentationNode("Object", node.content, NodeKind.ExternalClass)
"kotlin.IntArray", "kotlin.LongArray", "kotlin.ShortArray", "kotlin.ByteArray",
"kotlin.CharArray", "kotlin.DoubleArray", "kotlin.FloatArray", "kotlin.BooleanArray" ->
diff --git a/core/src/main/kotlin/Model/DocumentationNode.kt b/core/src/main/kotlin/Model/DocumentationNode.kt
index 33543aff..ebfce907 100644
--- a/core/src/main/kotlin/Model/DocumentationNode.kt
+++ b/core/src/main/kotlin/Model/DocumentationNode.kt
@@ -174,3 +174,5 @@ fun DocumentationNode.qualifiedName(): String {
}
return path.drop(1).map { it.name }.filter { it.length > 0 }.joinToString(".")
}
+
+fun DocumentationNode.simpleName() = name.substringAfterLast('.')
diff --git a/core/src/main/kotlin/javadoc/docbase.kt b/core/src/main/kotlin/javadoc/docbase.kt
index 795ba84a..20d74088 100644
--- a/core/src/main/kotlin/javadoc/docbase.kt
+++ b/core/src/main/kotlin/javadoc/docbase.kt
@@ -173,7 +173,7 @@ open class TypeAdapter(override val module: ModuleNodeAdapter, override val node
private val javaLanguageService = JavaLanguageService()
override fun qualifiedTypeName(): String = javaLanguageService.getArrayElementType(node)?.qualifiedNameFromType() ?: node.qualifiedNameFromType()
- override fun typeName(): String = javaLanguageService.getArrayElementType(node)?.name ?: node.name
+ override fun typeName(): String = javaLanguageService.getArrayElementType(node)?.simpleName() ?: node.simpleName()
override fun simpleTypeName(): String = typeName() // TODO difference typeName() vs simpleTypeName()
override fun dimension(): String = Collections.nCopies(javaLanguageService.getArrayDimension(node), "[]").joinToString("")
@@ -194,8 +194,10 @@ open class TypeAdapter(override val module: ModuleNodeAdapter, override val node
override fun asTypeVariable(): TypeVariable? = if (node.kind == NodeKind.TypeParameter) TypeVariableAdapter(module, node) else null
override fun asParameterizedType(): ParameterizedType? =
- if (node.details(NodeKind.Type).isNotEmpty()) ParameterizedTypeAdapter(module, node)
- else null // TODO it should ignore dimensions
+ if (node.details(NodeKind.Type).isNotEmpty() && javaLanguageService.getArrayElementType(node) == null)
+ ParameterizedTypeAdapter(module, node)
+ else
+ null
override fun asAnnotationTypeDoc(): AnnotationTypeDoc? = if (node.kind == NodeKind.AnnotationClass) AnnotationTypeDocAdapter(module, node) else null
override fun asAnnotatedType(): AnnotatedType? = if (node.annotations.isNotEmpty()) AnnotatedTypeAdapter(module, node) else null
@@ -389,7 +391,7 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod
if (parent?.kind in NodeKind.classLike) {
return parent!!.name + "." + classNode.name
}
- return classNode.name
+ return classNode.simpleName()
}
override fun constructors(filter: Boolean): Array<out ConstructorDoc> = classNode.members(NodeKind.Constructor).map { ConstructorAdapter(module, it) }.toTypedArray()
diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt
index 54654a2c..8bd520f6 100644
--- a/core/src/test/kotlin/javadoc/JavadocTest.kt
+++ b/core/src/test/kotlin/javadoc/JavadocTest.kt
@@ -59,4 +59,19 @@ class JavadocTest {
assertEquals("[]", member.returnType().dimension())
}
}
+
+ @Test fun testStringArray() {
+ verifyModel("testdata/javadoc/stringarr.kt", format = "javadoc", withKotlinRuntime = true) { model ->
+ val doc = ModuleNodeAdapter(model, StandardReporter(DokkaConsoleLogger), "")
+
+ val classDoc = doc.classNamed("foo.Foo")!!
+ assertNotNull(classDoc.asClassDoc())
+
+ val member = classDoc.methods().find { it.name() == "main" }!!
+ val paramType = member.parameters()[0].type()
+ assertNull(paramType.asParameterizedType())
+ assertEquals("String", paramType.typeName())
+ assertEquals("String", paramType.asClassDoc().name())
+ }
+ }
}
diff --git a/core/testdata/javadoc/stringarr.kt b/core/testdata/javadoc/stringarr.kt
new file mode 100644
index 00000000..d6cd9dea
--- /dev/null
+++ b/core/testdata/javadoc/stringarr.kt
@@ -0,0 +1,8 @@
+package foo
+
+class Foo {
+ companion object {
+ @JvmStatic fun main(args: Array<String>) {
+ }
+ }
+} \ No newline at end of file