diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2022-04-29 15:03:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-29 15:03:08 +0300 |
commit | 8c218ff4dd5f970233c43845c19299fc74256389 (patch) | |
tree | b6818183ce8faa2c58d6571ca1c86aa28d4f0431 /plugins/base/src/main/kotlin/translators | |
parent | 84aacad29982240ae367b21e9d283d38dab672ae (diff) | |
download | dokka-8c218ff4dd5f970233c43845c19299fc74256389.tar.gz dokka-8c218ff4dd5f970233c43845c19299fc74256389.tar.bz2 dokka-8c218ff4dd5f970233c43845c19299fc74256389.zip |
Enable warnings as errors and fix all warnings (#2451)
* Enable warnings as errors and fix all warnings
* Enable skip-metadata-version-check compiler setting
Diffstat (limited to 'plugins/base/src/main/kotlin/translators')
-rw-r--r-- | plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt | 81 |
1 files changed, 37 insertions, 44 deletions
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 91848963..85ec1d07 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -14,7 +14,6 @@ import org.jetbrains.dokka.analysis.from import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.parsers.MarkdownParser import org.jetbrains.dokka.base.translators.psi.parsers.JavadocParser -import org.jetbrains.dokka.base.translators.psi.DefaultPsiToDocumentableTranslator import org.jetbrains.dokka.base.translators.typeConstructorsBeingExceptions import org.jetbrains.dokka.base.translators.unquotedValue import org.jetbrains.dokka.links.* @@ -96,8 +95,7 @@ class DefaultDescriptorToDocumentableTranslator( return DokkaDescriptorVisitor(sourceSet, kotlinAnalysis[sourceSet].facade, context.logger).run { packageFragments.mapNotNull { it.safeAs<PackageFragmentDescriptor>() }.parallelMap { visitPackageFragmentDescriptor( - it, - DRIWithPlatformInfo(DRI.topLevel, emptyMap()) + it ) } }.let { @@ -145,20 +143,17 @@ private class DokkaDescriptorVisitor( private fun <T> T.toSourceSetDependent() = if (this != null) mapOf(sourceSet to this) else emptyMap() - suspend fun visitPackageFragmentDescriptor( - descriptor: PackageFragmentDescriptor, - parent: DRIWithPlatformInfo - ): DPackage { + suspend fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor): DPackage { val name = descriptor.fqName.asString().takeUnless { it.isBlank() } ?: "" val driWithPlatform = DRI(packageName = name).withEmptyInfo() val scope = descriptor.getMemberScope() return coroutineScope { val descriptorsWithKind = scope.getDescriptorsWithKind(true) - val functions = async { descriptorsWithKind.functions.visitFunctions(driWithPlatform) } - val properties = async { descriptorsWithKind.properties.visitProperties(driWithPlatform) } + val functions = async { descriptorsWithKind.functions.visitFunctions() } + val properties = async { descriptorsWithKind.properties.visitProperties() } val classlikes = async { descriptorsWithKind.classlikes.visitClasslikes(driWithPlatform) } - val typealiases = async { descriptorsWithKind.typealiases.visitTypealiases(driWithPlatform) } + val typealiases = async { descriptorsWithKind.typealiases.visitTypealiases() } DPackage( dri = driWithPlatform.dri, @@ -191,8 +186,8 @@ private class DokkaDescriptorVisitor( return coroutineScope { val descriptorsWithKind = scope.getDescriptorsWithKind() - val functions = async { descriptorsWithKind.functions.visitFunctions(driWithPlatform) } - val properties = async { descriptorsWithKind.properties.visitProperties(driWithPlatform) } + val functions = async { descriptorsWithKind.functions.visitFunctions() } + val properties = async { descriptorsWithKind.properties.visitProperties() } val classlikes = async { descriptorsWithKind.classlikes.visitClasslikes(driWithPlatform) } val generics = async { descriptor.declaredTypeParameters.parallelMap { it.toVariantTypeParameter() } } @@ -232,8 +227,8 @@ private class DokkaDescriptorVisitor( return coroutineScope { val descriptorsWithKind = scope.getDescriptorsWithKind() - val functions = async { descriptorsWithKind.functions.visitFunctions(driWithPlatform) } - val properties = async { descriptorsWithKind.properties.visitProperties(driWithPlatform) } + val functions = async { descriptorsWithKind.functions.visitFunctions() } + val properties = async { descriptorsWithKind.properties.visitProperties() } val classlikes = async { descriptorsWithKind.classlikes.visitClasslikes(driWithPlatform) } DObject( @@ -271,8 +266,8 @@ private class DokkaDescriptorVisitor( return coroutineScope { val descriptorsWithKind = scope.getDescriptorsWithKind() - val functions = async { descriptorsWithKind.functions.visitFunctions(driWithPlatform) } - val properties = async { descriptorsWithKind.properties.visitProperties(driWithPlatform) } + val functions = async { descriptorsWithKind.functions.visitFunctions() } + val properties = async { descriptorsWithKind.properties.visitProperties() } val classlikes = async { descriptorsWithKind.classlikes.visitClasslikes(driWithPlatform) } val constructors = async { descriptor.constructors.parallelMap { visitConstructorDescriptor(it, driWithPlatform) } } @@ -311,8 +306,8 @@ private class DokkaDescriptorVisitor( return coroutineScope { val descriptorsWithKind = scope.getDescriptorsWithKind() - val functions = async { descriptorsWithKind.functions.visitFunctions(driWithPlatform) } - val properties = async { descriptorsWithKind.properties.visitProperties(driWithPlatform) } + val functions = async { descriptorsWithKind.functions.visitFunctions() } + val properties = async { descriptorsWithKind.properties.visitProperties() } val classlikes = async { descriptorsWithKind.classlikes.visitClasslikes(driWithPlatform) } DEnumEntry( @@ -342,8 +337,8 @@ private class DokkaDescriptorVisitor( return coroutineScope { val descriptorsWithKind = scope.getDescriptorsWithKind() - val functions = async { descriptorsWithKind.functions.visitFunctions(driWithPlatform) } - val properties = async { descriptorsWithKind.properties.visitProperties(driWithPlatform) } + val functions = async { descriptorsWithKind.functions.visitFunctions() } + val properties = async { descriptorsWithKind.properties.visitProperties() } val classlikes = async { descriptorsWithKind.classlikes.visitClasslikes(driWithPlatform) } val generics = async { descriptor.declaredTypeParameters.parallelMap { it.toVariantTypeParameter() } } val constructors = @@ -385,8 +380,8 @@ private class DokkaDescriptorVisitor( return coroutineScope { val descriptorsWithKind = scope.getDescriptorsWithKind() - val functions = async { descriptorsWithKind.functions.visitFunctions(driWithPlatform) } - val properties = async { descriptorsWithKind.properties.visitProperties(driWithPlatform) } + val functions = async { descriptorsWithKind.functions.visitFunctions() } + val properties = async { descriptorsWithKind.properties.visitProperties() } val classlikes = async { descriptorsWithKind.classlikes.visitClasslikes(driWithPlatform) } val generics = async { descriptor.declaredTypeParameters.parallelMap { it.toVariantTypeParameter() } } val constructors = async { @@ -426,10 +421,7 @@ private class DokkaDescriptorVisitor( } } - private suspend fun visitPropertyDescriptor( - originalDescriptor: PropertyDescriptor, - parent: DRIWithPlatformInfo - ): DProperty { + private suspend fun visitPropertyDescriptor(originalDescriptor: PropertyDescriptor): DProperty { val (dri, inheritedFrom) = originalDescriptor.createDRI() val descriptor = originalDescriptor.getConcreteDescriptor() val isExpect = descriptor.isExpect @@ -481,10 +473,7 @@ private class DokkaDescriptorVisitor( else overriddenDescriptors.first().createDRI(DRI.from(this)) - private suspend fun visitFunctionDescriptor( - originalDescriptor: FunctionDescriptor, - parent: DRIWithPlatformInfo - ): DFunction { + private suspend fun visitFunctionDescriptor(originalDescriptor: FunctionDescriptor): DFunction { val (dri, inheritedFrom) = originalDescriptor.createDRI() val descriptor = originalDescriptor.getConcreteDescriptor() val isExpect = descriptor.isExpect @@ -675,7 +664,7 @@ private class DokkaDescriptorVisitor( } } - private suspend fun visitTypeAliasDescriptor(descriptor: TypeAliasDescriptor, parent: DRIWithPlatformInfo?) = + private suspend fun visitTypeAliasDescriptor(descriptor: TypeAliasDescriptor) = with(descriptor) { coroutineScope { val generics = async { descriptor.declaredTypeParameters.parallelMap { it.toVariantTypeParameter() } } @@ -742,6 +731,7 @@ private class DokkaDescriptorVisitor( } } + @Suppress("UNCHECKED_CAST") return DescriptorsWithKind( (groupedDescriptors[FunctionDescriptor::class] ?: emptyList()) as List<FunctionDescriptor>, (groupedDescriptors[PropertyDescriptor::class] ?: emptyList()) as List<PropertyDescriptor>, @@ -751,17 +741,17 @@ private class DokkaDescriptorVisitor( ) } - private suspend fun List<FunctionDescriptor>.visitFunctions(parent: DRIWithPlatformInfo): List<DFunction> = - coroutineScope { parallelMap { visitFunctionDescriptor(it, parent) } } + private suspend fun List<FunctionDescriptor>.visitFunctions(): List<DFunction> = + coroutineScope { parallelMap { visitFunctionDescriptor(it) } } - private suspend fun List<PropertyDescriptor>.visitProperties(parent: DRIWithPlatformInfo): List<DProperty> = - coroutineScope { parallelMap { visitPropertyDescriptor(it, parent) } } + private suspend fun List<PropertyDescriptor>.visitProperties(): List<DProperty> = + coroutineScope { parallelMap { visitPropertyDescriptor(it) } } private suspend fun List<ClassDescriptor>.visitClasslikes(parent: DRIWithPlatformInfo): List<DClasslike> = coroutineScope { parallelMap { visitClassDescriptor(it, parent) } } - private suspend fun List<TypeAliasDescriptor>.visitTypealiases(parent: DRIWithPlatformInfo): List<DTypeAlias> = - coroutineScope { parallelMap { visitTypeAliasDescriptor(it, parent) } } + private suspend fun List<TypeAliasDescriptor>.visitTypealiases(): List<DTypeAlias> = + coroutineScope { parallelMap { visitTypeAliasDescriptor(it) } } private suspend fun List<ClassDescriptor>.visitEnumEntries(parent: DRIWithPlatformInfo): List<DEnumEntry> = coroutineScope { parallelMap { visitEnumEntryDescriptor(it, parent) } } @@ -972,7 +962,7 @@ private class DokkaDescriptorVisitor( private fun ConstantValue<*>.toValue(): AnnotationParameterValue = when (this) { is ConstantsAnnotationValue -> AnnotationValue(value.toAnnotation()) - is ConstantsArrayValue -> ArrayValue(value.mapNotNull { it.toValue() }) + is ConstantsArrayValue -> ArrayValue(value.map { it.toValue() }) is ConstantsEnumValue -> EnumValue( fullEnumEntryName(), DRI(enumClassId.packageFqName.asString(), fullEnumEntryName()) @@ -1005,9 +995,7 @@ private class DokkaDescriptorVisitor( private fun AnnotationDescriptor.toAnnotation(scope: Annotations.AnnotationScope = Annotations.AnnotationScope.DIRECT): Annotations.Annotation = Annotations.Annotation( DRI.from(annotationClass as DeclarationDescriptor), - allValueArguments.map { it.key.asString() to it.value.toValue() }.filter { - it.second != null - }.toMap(), + allValueArguments.map { it.key.asString() to it.value.toValue() }.toMap(), mustBeDocumented(), scope ) @@ -1027,9 +1015,14 @@ private class DokkaDescriptorVisitor( } } - private fun <T : CallableMemberDescriptor> T.getConcreteDescriptor(): T = - if (kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) this - else overriddenDescriptors.first().getConcreteDescriptor() as T + private fun <T : CallableMemberDescriptor> T.getConcreteDescriptor(): T { + return if (kind != CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { + this + } else { + @Suppress("UNCHECKED_CAST") + overriddenDescriptors.first().getConcreteDescriptor() as T + } + } private fun ValueParameterDescriptor.getDefaultValue(): Expression? = ((source as? KotlinSourceElement)?.psi as? KtParameter)?.defaultValue?.toDefaultValueExpression() |