diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-11-05 13:30:05 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-11-05 13:30:05 +0100 |
commit | 0bad64896baed4056d75f8b948afe0d848bc8adf (patch) | |
tree | ffb0184af3a0ccff00090e9d0a886b1560ce9610 /javadoc/src/main/kotlin | |
parent | fb9f466fc5b33bc4ef6c58bffd76d4d17054d7e1 (diff) | |
download | dokka-0bad64896baed4056d75f8b948afe0d848bc8adf.tar.gz dokka-0bad64896baed4056d75f8b948afe0d848bc8adf.tar.bz2 dokka-0bad64896baed4056d75f8b948afe0d848bc8adf.zip |
get rid of duplicate implementations of calculating DocumentationNode qualified name
Diffstat (limited to 'javadoc/src/main/kotlin')
-rw-r--r-- | javadoc/src/main/kotlin/docbase.kt | 16 | ||||
-rw-r--r-- | javadoc/src/main/kotlin/utils.kt | 9 |
2 files changed, 8 insertions, 17 deletions
diff --git a/javadoc/src/main/kotlin/docbase.kt b/javadoc/src/main/kotlin/docbase.kt index 22db0a09..e98e28cd 100644 --- a/javadoc/src/main/kotlin/docbase.kt +++ b/javadoc/src/main/kotlin/docbase.kt @@ -51,7 +51,7 @@ open class DocumentationNodeBareAdapter(override val node: DocumentationNode) : else -> node.name.compareTo(other.node.name) } - override fun equals(other: Any?): Boolean = node.qualifiedName == (other as? DocumentationNodeAdapter)?.node?.qualifiedName + override fun equals(other: Any?): Boolean = node.qualifiedName() == (other as? DocumentationNodeAdapter)?.node?.qualifiedName() override fun hashCode(): Int = node.name.hashCode() override fun isIncluded(): Boolean = node.kind != DocumentationNode.Kind.ExternalClass @@ -88,7 +88,7 @@ open class DocumentationNodeAdapter(override val module: ModuleNodeAdapter, node private fun <T> nodeAnnotations(self: T): List<AnnotationDescAdapter> where T : HasModule, T : HasDocumentationNode = self.node.annotations.map { AnnotationDescAdapter(self.module, it) } -private fun DocumentationNode.hasAnnotation(klass: KClass<*>) = klass.qualifiedName in annotations.map { it.qualifiedName } +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 } @@ -126,7 +126,7 @@ class ProgramElementAdapter(module: ModuleNodeAdapter, node: DocumentationNode) override fun isPackagePrivate(): Boolean = false 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 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 @@ -166,7 +166,7 @@ class ProgramElementAdapter(module: ModuleNodeAdapter, node: DocumentationNode) open class TypeAdapter(override val module: ModuleNodeAdapter, override val node: DocumentationNode) : Type, HasDocumentationNode, HasModule { private val javaLanguageService = JavaLanguageService() - override fun qualifiedTypeName(): String = javaLanguageService.getArrayElementType(node)?.qualifiedName ?: node.qualifiedName + override fun qualifiedTypeName(): String = javaLanguageService.getArrayElementType(node)?.qualifiedName() ?: node.qualifiedName() override fun typeName(): String = javaLanguageService.getArrayElementType(node)?.name ?: node.name override fun simpleTypeName(): String = typeName() // TODO difference typeName() vs simpleTypeName() @@ -430,14 +430,14 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod while (types.isNotEmpty()) { val type = types.removeAt(types.lastIndex) - val fqName = type.qualifiedName + val fqName = type.qualifiedName() if (expectedFQName == fqName) { return true } visitedTypes.add(fqName) - types.addAll(type.details(DocumentationNode.Kind.Supertype).filter { it.qualifiedName !in visitedTypes }) + types.addAll(type.details(DocumentationNode.Kind.Supertype).filter { it.qualifiedName() !in visitedTypes }) } return false @@ -450,7 +450,7 @@ open class ClassDocumentationNodeAdapter(module: ModuleNodeAdapter, val classNod fun DocumentationNode.lookupSuperClasses(module: ModuleNodeAdapter) = details(DocumentationNode.Kind.Supertype) .map { it.links.firstOrNull() } - .map { module.allTypes[it?.qualifiedName] } + .map { module.allTypes[it?.qualifiedName()] } .filterNotNull() fun List<DocumentationNode>.collectAllTypesRecursively(): Map<String, DocumentationNode> { @@ -459,7 +459,7 @@ fun List<DocumentationNode>.collectAllTypesRecursively(): Map<String, Documentat fun DocumentationNode.collectTypesRecursively() { val classLikeMembers = DocumentationNode.Kind.classLike.flatMap { members(it) } classLikeMembers.forEach { - result.put(it.qualifiedName, it) + result.put(it.qualifiedName(), it) it.collectTypesRecursively() } } diff --git a/javadoc/src/main/kotlin/utils.kt b/javadoc/src/main/kotlin/utils.kt deleted file mode 100644 index 96f2d64c..00000000 --- a/javadoc/src/main/kotlin/utils.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.jetbrains.dokka.javadoc - -import org.jetbrains.dokka.DocumentationNode -import org.jetbrains.dokka.path - -val DocumentationNode.qualifiedName: String - get() = this.path.filter { it.kind == DocumentationNode.Kind.Package || it.kind in DocumentationNode.Kind.classLike } - .map { it.name } - .joinToString(".") |