From 9bf535bf8c0b758fc0abf99b61208fa5430239d6 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Wed, 26 Aug 2020 15:40:23 +0200 Subject: Let `DRI.packageName` always be a real package name for root packages ("") --- .../DefaultDescriptorToDocumentableTranslator.kt | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'plugins/base/src/main/kotlin/translators') diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index fccbe716..18b05df4 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -104,7 +104,7 @@ private class DokkaDescriptorVisitor( descriptor: PackageFragmentDescriptor, parent: DRIWithPlatformInfo ): DPackage { - val name = descriptor.fqName.asString().takeUnless { it.isBlank() } ?: fallbackPackageName() + val name = descriptor.fqName.asString().takeUnless { it.isBlank() } ?: "" val driWithPlatform = DRI(packageName = name).withEmptyInfo() val scope = descriptor.getMemberScope() @@ -590,7 +590,7 @@ private class DokkaDescriptorVisitor( private fun TypeParameterDescriptor.toVariantTypeParameter() = DTypeParameter( variantTypeParameter( - TypeParameter(DRI.from(this).withPackageFallbackTo(fallbackPackageName()), name.identifier) + TypeParameter(DRI.from(this), name.identifier) ), resolveDescriptorData(), null, @@ -603,7 +603,7 @@ private class DokkaDescriptorVisitor( is DynamicType -> Dynamic else -> when (val ctor = constructor.declarationDescriptor) { is TypeParameterDescriptor -> TypeParameter( - dri = DRI.from(ctor).withPackageFallbackTo(fallbackPackageName()), + dri = DRI.from(ctor), name = ctor.name.asString() ) else -> TypeConstructor( @@ -776,14 +776,4 @@ private class DokkaDescriptorVisitor( private fun ConstantsEnumValue.fullEnumEntryName() = "${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 fun DRI.withPackageFallbackTo(fallbackPackage: String): DRI { - return if (packageName.isNullOrBlank()) { - copy(packageName = fallbackPackage) - } else { - this - } } -- cgit