diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 13:44:04 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-10-29 13:44:04 +0100 |
commit | af5cd353271120a6ef9853a3913d5e828747178e (patch) | |
tree | e85638ba26898a3431bf9cfe9d687210de5f0794 /javadoc | |
parent | 4e09ac20457e2c4398406a1c23bf1f435f31349e (diff) | |
download | dokka-af5cd353271120a6ef9853a3913d5e828747178e.tar.gz dokka-af5cd353271120a6ef9853a3913d5e828747178e.tar.bz2 dokka-af5cd353271120a6ef9853a3913d5e828747178e.zip |
cleanup after merge
Diffstat (limited to 'javadoc')
-rw-r--r-- | javadoc/src/main/kotlin/docbase.kt | 27 | ||||
-rw-r--r-- | javadoc/src/main/kotlin/tags.kt | 12 |
2 files changed, 18 insertions, 21 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 <T> nodeAnnotations(self: T): List<AnnotationDescAdapter> 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<out ClassDoc> = node.members(DocumentationNode.Kind.Interface).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray() override fun errors(): Array<out ClassDoc> = emptyArray() override fun enums(): Array<out ClassDoc> = node.members(DocumentationNode.Kind.Enum).map { ClassDocumentationNodeAdapter(module, it) }.toTypedArray() - override fun allClasses(filter: Boolean): Array<out ClassDoc> = (allClasses.values().map { ClassDocumentationNodeAdapter(module, it) } + packageFacade).toTypedArray() + override fun allClasses(filter: Boolean): Array<out ClassDoc> = (allClasses.values.map { ClassDocumentationNodeAdapter(module, it) } + packageFacade).toTypedArray() override fun allClasses(): Array<out ClassDoc> = 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<out AnnotationDesc>? = nodeAnnotations(this).toTypedArray() @@ -267,8 +265,7 @@ class ReceiverParameterAdapter(module: ModuleNodeAdapter, val receiverType: Docu override fun annotations(): Array<out AnnotationDesc> = 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<out SerialFieldTag> = 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<String>() 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<out ClassDoc> = - (allTypes.values().map { ClassDocumentationNodeAdapter(this, it) } + packageFacades.values()) + (allTypes.values.map { ClassDocumentationNodeAdapter(this, it) } + packageFacades.values) .toTypedArray() override fun options(): Array<out Array<String>> = 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<out Tag> = emptyArray() // TODO override fun firstSentenceTags(): Array<out Tag> = inlineTags() // TODO } -class ParamTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val parameterName: String, val isTypeParameter: Boolean, val content: List<ContentNode>) : ParamTag { +class ParamTagAdapter(val module: ModuleNodeAdapter, val holder: Doc, val parameterName: String, val typeParameter: Boolean, val content: List<ContentNode>) : 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<out Tag> = content.flatMap { buildInlineTags(module, holder, it) }.toTypedArray() override fun firstSentenceTags(): Array<out Tag> = 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) } |