From 75ca42c675a3586c0bdfc9c5320f283d097bb27d Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Sun, 21 Jun 2020 12:20:57 +0200 Subject: Internal links --- .../DefaultDescriptorToDocumentableTranslator.kt | 19 +++++-------------- plugins/base/src/test/kotlin/model/ClassesTest.kt | 2 +- 2 files changed, 6 insertions(+), 15 deletions(-) (limited to 'plugins/base/src') diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 4764fbcb..9dc87d91 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -554,19 +554,15 @@ private class DokkaDescriptorVisitor( getDocumentation()?.toSourceSetDependent() ?: emptyMap() private fun ClassDescriptor.resolveClassDescriptionData(): ClassInfo { - val superClasses = hashSetOf() - + val interfaces = hashSetOf() fun processSuperClasses(supers: List) { supers.forEach { - superClasses.add(it) + if(it.kind == ClassKind.INTERFACE) interfaces.add(DRI.from(it)) processSuperClasses(it.getSuperInterfaces() + it.getAllSuperclassesWithoutAny()) } } processSuperClasses(getSuperInterfaces() + getAllSuperclassesWithoutAny()) - return ClassInfo( - superClasses.map { Supertype(DRI.from(it), it.kind == ClassKind.INTERFACE) }.toList(), - resolveDescriptorData() - ) + return ClassInfo(getAllSuperclassesWithoutAny().map { DRI.from(it) }, interfaces.toList(), resolveDescriptorData()) } private fun TypeParameterDescriptor.toTypeParameter() = @@ -739,12 +735,9 @@ private class DokkaDescriptorVisitor( private fun ValueArgument.childrenAsText() = this.safeAs()?.children?.map {it.text }.orEmpty() - private data class ClassInfo(private val allSupertypes: List, val docs: SourceSetDependent){ + private data class ClassInfo(val superclasses: List, val interfaces: List, val docs: SourceSetDependent){ val supertypes: List - get() = allSupertypes.map { it.dri } - - val interfaces: List - get() = allSupertypes.filter { it.isInterface }.map { it.dri } + get() = (superclasses + interfaces).distinct() } private fun Visibility.toDokkaVisibility(): org.jetbrains.dokka.model.Visibility = when (this) { @@ -759,8 +752,6 @@ private class DokkaDescriptorVisitor( "${this.enumClassId.relativeClassName.asString()}.${this.enumEntryName.identifier}" private fun fallbackPackageName(): String = "[${sourceSet.displayName} root]"// TODO: error-prone, find a better way to do it - - private data class Supertype(val dri: DRI, val isInterface: Boolean) } private fun DRI.withPackageFallbackTo(fallbackPackage: String): DRI { diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt index 6d17fdd1..979ea89b 100644 --- a/plugins/base/src/test/kotlin/model/ClassesTest.kt +++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt @@ -258,7 +258,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class modifier.values.forEach { it equals Final } } - D.supers.firstOrNull() equals C.dri + D.supers.single() equals C.dri E.supers.firstOrNull() equals D.dri } } -- cgit