From af5cd353271120a6ef9853a3913d5e828747178e Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 29 Oct 2015 13:44:04 +0100 Subject: cleanup after merge --- javadoc/src/main/kotlin/docbase.kt | 27 ++++++++++++--------------- javadoc/src/main/kotlin/tags.kt | 12 ++++++------ src/Model/DocumentationNode.kt | 1 - 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/javadoc/src/main/kotlin/docbase.kt b/javadoc/src/main/kotlin/docbase.kt index 7625d545..9cb0148d 100644 --- a/javadoc/src/main/kotlin/docbase.kt +++ b/javadoc/src/main/kotlin/docbase.kt @@ -3,9 +3,7 @@ package org.jetbrains.dokka.javadoc import com.sun.javadoc.* import org.jetbrains.dokka.* import java.lang.reflect.Modifier -import java.util.Collections -import java.util.HashSet -import kotlin.platform.platformStatic +import java.util.* import kotlin.reflect.KClass private interface HasModule { @@ -79,7 +77,7 @@ private fun nodeAnnotations(self: T): List where T : private fun DocumentationNode.hasAnnotation(klass: KClass<*>) = klass.qualifiedName in annotations.map { it.qualifiedName } -private val allClassKinds = setOf(DocumentationNode.Kind.Class, DocumentationNode.Kind.Enum, DocumentationNode.Kind.Interface, DocumentationNode.Kind.Object, DocumentationNode.Kind.Exception) +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 } @@ -96,7 +94,7 @@ class PackageAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : Docum override fun interfaces(): Array = node.members(DocumentationNode.Kind.Interface).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray() override fun errors(): Array = emptyArray() override fun enums(): Array = node.members(DocumentationNode.Kind.Enum).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray() - override fun allClasses(filter: Boolean): Array = (allClasses.values().map { ClassDocumentationNodeAdapter(module, it) } + packageFacade).toTypedArray() + override fun allClasses(filter: Boolean): Array = (allClasses.values.map { ClassDocumentationNodeAdapter(module, it) } + packageFacade).toTypedArray() override fun allClasses(): Array = allClasses(true) override fun isIncluded(): Boolean = node.name in module.allPackages @@ -116,7 +114,7 @@ class ProgramElementAdapter(module: ModuleNodeAdapter, node: DocumentationNode) 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(platformStatic::class) + || node.hasAnnotation(JvmStatic::class) override fun modifierSpecifier(): Int = Modifier.PUBLIC + if (isStatic) Modifier.STATIC else 0 override fun qualifiedName(): String? = node.qualifiedName override fun annotations(): Array? = nodeAnnotations(this).toTypedArray() @@ -267,8 +265,7 @@ class ReceiverParameterAdapter(module: ModuleNodeAdapter, val receiverType: Docu override fun annotations(): Array = nodeAnnotations(this).toTypedArray() override fun name(): String = tryName("receiver") - tailRecursive - private fun tryName(name: String): String = when (name) { + private tailrec fun tryName(name: String): String = when (name) { in parent.parameters().drop(1).map { it.name() } -> tryName("$$name") else -> name } @@ -354,10 +351,10 @@ class FieldAdapter(module: ModuleNodeAdapter, node: DocumentationNode) : Documen override fun constantValue(): Any? = constantValueExpression() override fun type(): Type = TypeAdapter(module, node.detail(DocumentationNode.Kind.Type)) - override fun isTransient(): Boolean = node.hasAnnotation(transient::class) + override fun isTransient(): Boolean = node.hasAnnotation(Transient::class) override fun serialFieldTags(): Array = emptyArray() - override fun isVolatile(): Boolean = node.hasAnnotation(volatile::class) + override fun isVolatile(): Boolean = node.hasAnnotation(Volatile::class) } open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNode: DocumentationNode) : DocumentationNodeAdapter(module, classNode), Type by TypeAdapter(module, classNode), ProgramElementDoc by ProgramElementAdapter(module, classNode), ClassDoc { @@ -408,7 +405,7 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod val visitedTypes = HashSet() while (types.isNotEmpty()) { - val type = types.remove(types.lastIndex) + val type = types.removeAt(types.lastIndex) val fqName = type.qualifiedName if (expectedFQName == fqName) { @@ -429,7 +426,7 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod class PackageFacadeAdapter(val module: ModuleNodeAdapter, val packageNode: DocumentationNode) : ProgramElementDoc by ProgramElementAdapter(module, packageNode), ClassDoc { override fun simpleTypeName(): String = packageNode.name.substringAfterLast(".", packageNode.name).capitalize() + "Package" override fun typeName(): String = simpleTypeName() - override fun qualifiedTypeName(): String = packageNode.name.split(".").let { parts -> parts.take(parts.size() - 1) + parts.takeLast(1).map { it.capitalize() + "Package" } }.joinToString(".") + override fun qualifiedTypeName(): String = packageNode.name.split(".").let { parts -> parts.take(parts.size - 1) + parts.takeLast(1).map { it.capitalize() + "Package" } }.joinToString(".") override fun qualifiedName(): String = qualifiedTypeName() override fun name(): String = simpleTypeName() @@ -480,16 +477,16 @@ fun DocumentationNode.lookupSuperClasses(module: ModuleNodeAdapter) = .filterNotNull() class ModuleNodeAdapter(val module: DocumentationModule, val reporter: DocErrorReporter, val outputPath: String) : DocumentationNodeBareAdapter(module), DocErrorReporter by reporter, RootDoc { - val allPackages = module.members(DocumentationNode.Kind.Package).toMap { it.name } + val allPackages = module.members(DocumentationNode.Kind.Package).toMapBy { it.name } val allTypes = module.members(DocumentationNode.Kind.Package) .flatMap { it.members(DocumentationNode.Kind.Class) + it.members(DocumentationNode.Kind.Interface) + it.members(DocumentationNode.Kind.Enum) } - .toMap { it.qualifiedName } + .toMapBy { it.qualifiedName } val packageFacades = module.members(DocumentationNode.Kind.Package).map { PackageFacadeAdapter(this, it) }.toMap { it.qualifiedName() } override fun packageNamed(name: String?): PackageDoc? = allPackages[name]?.let { PackageAdapter(this, it) } override fun classes(): Array = - (allTypes.values().map { ClassDocumentationNodeAdapter(this, it) } + packageFacades.values()) + (allTypes.values.map { ClassDocumentationNodeAdapter(this, it) } + packageFacades.values) .toTypedArray() override fun options(): Array> = arrayOf( diff --git a/javadoc/src/main/kotlin/tags.kt b/javadoc/src/main/kotlin/tags.kt index b9b7995d..266c8712 100644 --- a/javadoc/src/main/kotlin/tags.kt +++ b/javadoc/src/main/kotlin/tags.kt @@ -2,7 +2,7 @@ package org.jetbrains.dokka.javadoc import com.sun.javadoc.* import org.jetbrains.dokka.* -import java.util.ArrayList +import java.util.* class TextTag(val holder: Doc, val content: ContentText) : Tag { val plainText: String @@ -60,13 +60,13 @@ class SeeClassTagAdapter(holder: Doc, val clazz: ClassDocumentationNodeAdapter, override fun referencedPackage(): PackageDoc? = null override fun referencedClass(): ClassDoc = clazz override fun referencedClassName(): String = clazz.name() - override fun label(): String = "${clazz.classNode.kind.name().toLowerCase()} ${clazz.name()}" + override fun label(): String = "${clazz.classNode.kind.name.toLowerCase()} ${clazz.name()}" override fun inlineTags(): Array = emptyArray() // TODO override fun firstSentenceTags(): Array = inlineTags() // TODO } -class ParamTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val parameterName: String, val isTypeParameter: Boolean, val content: List) : ParamTag { +class ParamTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val parameterName: String, val typeParameter: Boolean, val content: List) : ParamTag { constructor(module: ModuleNodeAdapter, holder: Doc, parameterName: String, isTypeParameter: Boolean, content: ContentNode) : this(module, holder, parameterName, isTypeParameter, listOf(content)) override fun name(): String = "@param" @@ -78,7 +78,7 @@ class ParamTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val parame override fun inlineTags(): Array = content.flatMap { buildInlineTags(module, holder, it) }.toTypedArray() override fun firstSentenceTags(): Array = arrayOf(TextTag(holder, ContentText(text()))) - override fun isTypeParameter(): Boolean = isTypeParameter + override fun isTypeParameter(): Boolean = typeParameter override fun parameterComment(): String = content.toString() // TODO override fun parameterName(): String = parameterName } @@ -114,7 +114,7 @@ private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, node: Conten } if (result.last() === open) { - result.remove(result.lastIndex) + result.removeAt(result.lastIndex) } else { result.add(close) } @@ -129,7 +129,7 @@ private fun buildInlineTags(module: ModuleNodeAdapter, holder: Doc, node: Conten result.add(open) buildInlineTags(module, holder, node, result) if (result.last() === open) { - result.remove(result.lastIndex) + result.removeAt(result.lastIndex) } else { result.add(close) } diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index 4a77f761..44e9099e 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -141,7 +141,6 @@ fun DocumentationNode.findOrCreatePackageNode(packageName: String, packageConten fun DocumentationNode.append(child: DocumentationNode, kind: DocumentationReference.Kind) { addReferenceTo(child, kind) - @suppress("NON_EXHAUSTIVE_WHEN") when (kind) { DocumentationReference.Kind.Detail -> child.addReferenceTo(this, DocumentationReference.Kind.Owner) DocumentationReference.Kind.Member -> child.addReferenceTo(this, DocumentationReference.Kind.Owner) -- cgit