aboutsummaryrefslogtreecommitdiff
path: root/javadoc
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-11-03 20:21:52 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-11-03 20:21:52 +0100
commitfb25c1eaf41ae314d19d6cda55446a2ab6b63715 (patch)
tree99cb6e86eb45a7ea4a3f0eeb2f35f200c3117270 /javadoc
parentaa9395aa97a9d738125e21d5ed235b350d637a24 (diff)
downloaddokka-fb25c1eaf41ae314d19d6cda55446a2ab6b63715.tar.gz
dokka-fb25c1eaf41ae314d19d6cda55446a2ab6b63715.tar.bz2
dokka-fb25c1eaf41ae314d19d6cda55446a2ab6b63715.zip
reduce the number of Kotlinisms in documentation model generated from Java code
Diffstat (limited to 'javadoc')
-rw-r--r--javadoc/src/main/kotlin/docbase.kt27
-rw-r--r--javadoc/src/main/kotlin/utils.kt3
2 files changed, 17 insertions, 13 deletions
diff --git a/javadoc/src/main/kotlin/docbase.kt b/javadoc/src/main/kotlin/docbase.kt
index a9a7f23b..318aa3d5 100644
--- a/javadoc/src/main/kotlin/docbase.kt
+++ b/javadoc/src/main/kotlin/docbase.kt
@@ -39,7 +39,7 @@ open class DocumentationNodeBareAdapter(override val node: DocumentationNode) :
override fun isEnum(): Boolean = node.kind == DocumentationNode.Kind.Enum
override fun isMethod(): Boolean = node.kind == DocumentationNode.Kind.Function
override fun isInterface(): Boolean = node.kind == DocumentationNode.Kind.Interface
- override fun isField(): Boolean = node.kind == DocumentationNode.Kind.Property
+ override fun isField(): Boolean = node.kind == DocumentationNode.Kind.Field
override fun isClass(): Boolean = node.kind == DocumentationNode.Kind.Class
override fun isAnnotationType(): Boolean = node.kind == DocumentationNode.Kind.AnnotationClass
override fun isConstructor(): Boolean = node.kind == DocumentationNode.Kind.Constructor
@@ -76,11 +76,11 @@ private fun <T> nodeAnnotations(self: T): List<AnnotationDescAdapter> where T :
= self.node.annotations.map { AnnotationDescAdapter(self.module, it) }
private fun DocumentationNode.hasAnnotation(klass: KClass<*>) = klass.qualifiedName in annotations.map { it.qualifiedName }
+private fun DocumentationNode.hasModifier(name: String) = details(DocumentationNode.Kind.Modifier).any { it.name == name }
-val allClassKinds = setOf(DocumentationNode.Kind.Class, DocumentationNode.Kind.Enum, DocumentationNode.Kind.Interface, DocumentationNode.Kind.Object, DocumentationNode.Kind.Exception)
class PackageAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), PackageDoc {
- private val allClasses = node.members.filter { it.kind in allClassKinds }.toMap { it.name }
+ private val allClasses = node.members.filter { it.kind in DocumentationNode.Kind.classLike }.toMap { it.name }
override fun findClass(className: String?): ClassDoc? =
allClasses.get(className)?.let { ClassDocumentationNodeAdapter(module, it) }
@@ -111,15 +111,14 @@ class AnnotationDescAdapter(val module: ModuleNodeAdapter, val node: Documentati
class ProgramElementAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : DocumentationNodeAdapter(module, node), ProgramElementDoc {
override fun isPublic(): Boolean = true
override fun isPackagePrivate(): Boolean = false
- override fun isStatic(): Boolean = node.owner?.kind in listOf(DocumentationNode.Kind.Package, DocumentationNode.Kind.ExternalClass)
- || node.hasAnnotation(JvmStatic::class)
+ override fun isStatic(): Boolean = node.hasModifier("static")
override fun modifierSpecifier(): Int = Modifier.PUBLIC + if (isStatic) Modifier.STATIC else 0
override fun qualifiedName(): String? = node.qualifiedName
override fun annotations(): Array<out AnnotationDesc>? = nodeAnnotations(this).toTypedArray()
override fun modifiers(): String? = "public ${if (isStatic) "static" else ""}".trim()
override fun isProtected(): Boolean = false
- override fun isFinal(): Boolean = node.details(DocumentationNode.Kind.Modifier).any { it.name == "final" }
+ override fun isFinal(): Boolean = node.hasModifier("final")
override fun containingPackage(): PackageDoc? {
var owner: DocumentationNode? = node
@@ -356,13 +355,19 @@ class FieldAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : Documen
override fun isVolatile(): Boolean = node.hasAnnotation(Volatile::class)
}
-open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNode: DocumentationNode, val name: String = classNode.name)
+open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNode: DocumentationNode)
: DocumentationNodeAdapter(module, classNode),
Type by TypeAdapter(module, classNode),
ProgramElementDoc by ProgramElementAdapter(module, classNode),
ClassDoc {
- override fun name(): String = name
+ override fun name(): String {
+ val parent = classNode.owner
+ if (parent?.kind in DocumentationNode.Kind.classLike) {
+ return parent!!.name + "." + classNode.name
+ }
+ return classNode.name
+ }
override fun constructors(filter: Boolean): Array<out ConstructorDoc> = classNode.members(DocumentationNode.Kind.Constructor).map { ConstructorAdapter(module, it) }.toTypedArray()
override fun constructors(): Array<out ConstructorDoc> = constructors(true)
@@ -392,8 +397,8 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod
ParamTagAdapter(module, this, it.subjectName ?: "?", true, it.children)
}).toTypedArray()
- override fun fields(): Array<out FieldDoc> = emptyArray()
- override fun fields(filter: Boolean): Array<out FieldDoc> = emptyArray()
+ override fun fields(): Array<out FieldDoc> = fields(true)
+ override fun fields(filter: Boolean): Array<out FieldDoc> = classNode.members(DocumentationNode.Kind.Field).map { FieldAdapter(module, it) }.toTypedArray()
override fun findClass(className: String?): ClassDoc? = null // TODO !!!
override fun serializableFields(): Array<out FieldDoc> = emptyArray()
@@ -425,7 +430,7 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod
return false
}
- override fun innerClasses(): Array<out ClassDoc> = classNode.members(DocumentationNode.Kind.Class).map { ClassDocumentationNodeAdapter(module, it, name + "." + it.name) }.toTypedArray()
+ override fun innerClasses(): Array<out ClassDoc> = classNode.members(DocumentationNode.Kind.Class).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray()
override fun innerClasses(filter: Boolean): Array<out ClassDoc> = innerClasses()
}
diff --git a/javadoc/src/main/kotlin/utils.kt b/javadoc/src/main/kotlin/utils.kt
index 661de0c8..96f2d64c 100644
--- a/javadoc/src/main/kotlin/utils.kt
+++ b/javadoc/src/main/kotlin/utils.kt
@@ -2,9 +2,8 @@ package org.jetbrains.dokka.javadoc
import org.jetbrains.dokka.DocumentationNode
import org.jetbrains.dokka.path
-import java.util.*
val DocumentationNode.qualifiedName: String
- get() = this.path.filter { it.kind == DocumentationNode.Kind.Package || it.kind in allClassKinds }
+ get() = this.path.filter { it.kind == DocumentationNode.Kind.Package || it.kind in DocumentationNode.Kind.classLike }
.map { it.name }
.joinToString(".")