diff options
Diffstat (limited to 'plugins/base/src')
6 files changed, 34 insertions, 37 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt index 1b8fa299..c8e4f565 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DefaultDocumentableMerger.kt @@ -25,7 +25,7 @@ internal object DefaultDocumentableMerger : DocumentableMerger { ), documentation = list.map { it.documentation }.flatMap { it.entries }.associate { (k,v) -> k to v }, expectPresentInSet = list.firstNotNullResult { it.expectPresentInSet }, - sourceSets = list.flatMap { it.sourceSets } + sourceSets = list.flatMap { it.sourceSets }.toSet() ).mergeExtras(left, right) } } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt index d15ec791..d3fc65fb 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt @@ -91,12 +91,12 @@ internal class DocumentableVisibilityFilter(val context: DokkaContext) : PreMerg visibilityForPlatform(d)?.isAllowedInPackage(dri.packageName) == true && additionalCondition(this, d) || alternativeCondition(this, d) - } + }.toSet() private fun <T> List<T>.transform( additionalCondition: (T, SourceSetData) -> Boolean = ::alwaysTrue, alternativeCondition: (T, SourceSetData) -> Boolean = ::alwaysFalse, - recreate: (T, List<SourceSetData>) -> T + recreate: (T, Set<SourceSetData>) -> T ): Pair<Boolean, List<T>> where T : Documentable, T : WithVisibility { var changed = false val values = mapNotNull { t -> @@ -170,11 +170,11 @@ internal class DocumentableVisibilityFilter(val context: DokkaContext) : PreMerg } } - private fun filterEnumEntries(entries: List<DEnumEntry>, filteredPlatforms: List<SourceSetData>) = + private fun filterEnumEntries(entries: List<DEnumEntry>, filteredPlatforms: Set<SourceSetData>) = entries.mapNotNull { entry -> if (filteredPlatforms.containsAll(entry.sourceSets)) entry else { - val intersection = filteredPlatforms.intersect(entry.sourceSets).toList() + val intersection = filteredPlatforms.intersect(entry.sourceSets) if (intersection.isEmpty()) null else DEnumEntry( entry.dri, diff --git a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt index e324c5bb..d987a5d5 100644 --- a/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/pages/sourcelinks/SourceLinksTransformer.kt @@ -9,15 +9,12 @@ import org.jetbrains.dokka.model.SourceSetData import org.jetbrains.dokka.model.DocumentableSource import org.jetbrains.dokka.model.PsiDocumentableSource import org.jetbrains.dokka.model.WithExpectActual -import org.jetbrains.dokka.model.properties.PropertyContainer -import org.jetbrains.dokka.model.sourceSet import org.jetbrains.dokka.pages.* import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.pages.PageTransformer import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource import org.jetbrains.kotlin.resolve.source.getPsi import org.jetbrains.kotlin.utils.addToStdlib.cast -import org.jetbrains.kotlin.utils.addToStdlib.safeAs class SourceLinksTransformer(val context: DokkaContext, val builder: PageContentBuilder) : PageTransformer { diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 33cad4f5..90e37308 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -67,7 +67,7 @@ object DefaultDescriptorToDocumentableTranslator : SourceToDocumentableTranslato DRIWithPlatformInfo(DRI.topLevel, emptyMap()) ) } - }.let { DModule(sourceSet.moduleName, it, emptyMap(), null, listOf(sourceSet)) } + }.let { DModule(sourceSet.moduleName, it, emptyMap(), null, setOf(sourceSet)) } } } @@ -112,7 +112,7 @@ private class DokkaDescriptorVisitor( classlikes = scope.classlikes(driWithPlatform, true), typealiases = scope.typealiases(driWithPlatform, true), documentation = descriptor.resolveDescriptorData(), - sourceSets = listOf(sourceSet) + sourceSets = setOf(sourceSet) ) } @@ -145,7 +145,7 @@ private class DokkaDescriptorVisitor( documentation = info.docs, generics = descriptor.declaredTypeParameters.map { it.toTypeParameter() }, companion = descriptor.companion(driWithPlatform), - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations() @@ -171,7 +171,7 @@ private class DokkaDescriptorVisitor( visibility = descriptor.visibility.toDokkaVisibility().toSourceSetDependent(), supertypes = info.supertypes.toSourceSetDependent(), documentation = info.docs, - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations() @@ -199,7 +199,7 @@ private class DokkaDescriptorVisitor( supertypes = info.supertypes.toSourceSetDependent(), documentation = info.docs, companion = descriptor.companion(driWithPlatform), - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations() @@ -219,7 +219,7 @@ private class DokkaDescriptorVisitor( classlikes = scope.classlikes(driWithPlatform), functions = scope.functions(driWithPlatform), properties = scope.properties(driWithPlatform), - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), expectPresentInSet = sourceSet.takeIf { isExpect }, extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), @@ -241,7 +241,7 @@ private class DokkaDescriptorVisitor( functions = scope.functions(driWithPlatform), properties = scope.properties(driWithPlatform), expectPresentInSet = null, - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations() @@ -282,7 +282,7 @@ private class DokkaDescriptorVisitor( documentation = info.docs, modifier = descriptor.modifier().toSourceSetDependent(), companion = descriptor.companion(driWithPlatform), - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations() @@ -313,7 +313,7 @@ private class DokkaDescriptorVisitor( modifier = descriptor.modifier().toSourceSetDependent(), type = descriptor.returnType!!.toBound(), expectPresentInSet = sourceSet.takeIf { isExpect }, - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), generics = descriptor.typeParameters.map { it.toTypeParameter() }, extra = PropertyContainer.withAll( (descriptor.additionalExtras() + descriptor.getAnnotationsWithBackingField() @@ -351,7 +351,7 @@ private class DokkaDescriptorVisitor( documentation = descriptor.resolveDescriptorData(), modifier = descriptor.modifier().toSourceSetDependent(), type = descriptor.returnType!!.toBound(), - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll( InheritedFunction(isInherited), descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), @@ -394,7 +394,7 @@ private class DokkaDescriptorVisitor( type = descriptor.returnType.toBound(), modifier = descriptor.modifier().toSourceSetDependent(), generics = descriptor.typeParameters.map { it.toTypeParameter() }, - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll<DFunction>( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations() @@ -415,7 +415,7 @@ private class DokkaDescriptorVisitor( type = descriptor.type.toBound(), expectPresentInSet = null, documentation = descriptor.resolveDescriptorData(), - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll(descriptor.getAnnotations().toSourceSetDependent().toAnnotations()) ) @@ -435,7 +435,7 @@ private class DokkaDescriptorVisitor( type = this.type.toBound(), expectPresentInSet = sourceSet.takeIf { isExpect }, documentation = descriptor.resolveDescriptorData(), - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), getAnnotationsWithBackingField().toSourceSetDependent().toAnnotations() @@ -473,7 +473,7 @@ private class DokkaDescriptorVisitor( ) }, sources = descriptor.createSources(), - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations() @@ -491,7 +491,7 @@ private class DokkaDescriptorVisitor( underlyingType = underlyingType.toBound().toSourceSetDependent(), visibility = visibility.toDokkaVisibility().toSourceSetDependent(), documentation = resolveDescriptorData(), - sourceSets = listOf(sourceSet) + sourceSets = setOf(sourceSet) ) } @@ -502,7 +502,7 @@ private class DokkaDescriptorVisitor( type = descriptor.type.toBound(), expectPresentInSet = null, documentation = descriptor.resolveDescriptorData(), - sourceSets = listOf(sourceSet), + sourceSets = setOf(sourceSet), extra = PropertyContainer.withAll(listOfNotNull( descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(), descriptor.getAnnotations().toSourceSetDependent().toAnnotations(), @@ -564,7 +564,7 @@ private class DokkaDescriptorVisitor( resolveDescriptorData(), null, upperBounds.map { it.toBound() }, - listOf(sourceSet), + setOf(sourceSet), extra = PropertyContainer.withAll(additionalExtras().toSourceSetDependent().toAdditionalModifiers()) ) diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt index bdc6d680..6d50f19a 100644 --- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt +++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt @@ -106,7 +106,7 @@ open class DefaultPageCreator( protected open fun contentForScope( s: WithScope, dri: DRI, - sourceSets: List<SourceSetData> + sourceSets: Set<SourceSetData> ) = contentBuilder.contentFor(s as Documentable) { divergentBlock("Types", s.classlikes, ContentKind.Classlikes, extra = mainExtra + SimpleAttr.header("Types")) divergentBlock("Functions", s.functions, ContentKind.Functions, extra = mainExtra + SimpleAttr.header( "Functions")) diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index d68f0e01..a5fa4189 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -74,12 +74,12 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { emptyList(), emptyMap(), null, - listOf(sourceSetData) + setOf(sourceSetData) ) }, emptyMap(), null, - listOf(sourceSetData) + setOf(sourceSetData) ) } @@ -166,7 +166,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { null, constructors.map { parseFunction(it, true) }, mapTypeParameters(dri), - listOf(sourceSetData), + setOf(sourceSetData), PropertyContainer.empty<DAnnotation>() + annotations.toList().getAnnotations() .toSourceSetDependent().toAnnotations() ) @@ -182,7 +182,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { emptyList(), emptyList(), emptyList(), - listOf(sourceSetData), + setOf(sourceSetData), PropertyContainer.empty<DEnumEntry>() + entry.annotations.toList().getAnnotations() .toSourceSetDependent().toAnnotations() ) @@ -197,7 +197,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { null, constructors.map { parseFunction(it, true) }, ancestors, - listOf(sourceSetData), + setOf(sourceSetData), PropertyContainer.empty<DEnum>() + annotations.toList().getAnnotations().toSourceSetDependent() .toAnnotations() ) @@ -214,7 +214,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { null, mapTypeParameters(dri), ancestors, - listOf(sourceSetData), + setOf(sourceSetData), PropertyContainer.empty<DInterface>() + annotations.toList().getAnnotations().toSourceSetDependent() .toAnnotations() ) @@ -233,7 +233,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { documentation, null, modifiers, - listOf(sourceSetData), + setOf(sourceSetData), PropertyContainer.empty<DClass>() + annotations.toList().getAnnotations().toSourceSetDependent() .toAnnotations() ) @@ -257,7 +257,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { javadocParser.parseDocumentation(psiParameter).toSourceSetDependent(), null, getBound(psiParameter.type), - listOf(sourceSetData) + setOf(sourceSetData) ) }, javadocParser.parseDocumentation(psi).toSourceSetDependent(), @@ -268,7 +268,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { psi.mapTypeParameters(dri), null, psi.getModifier().toSourceSetDependent(), - listOf(sourceSetData), + setOf(sourceSetData), psi.additionalExtras().let { PropertyContainer.withAll( InheritedFunction(isInherited), @@ -350,7 +350,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { javadocParser.parseDocumentation(type).toSourceSetDependent(), null, mapBounds(type.bounds), - listOf(sourceSetData) + setOf(sourceSetData) ) } } @@ -393,7 +393,7 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator { accessors.firstOrNull { it.hasParameters() }?.let { parseFunction(it) }, accessors.firstOrNull { it.returnType == psi.type }?.let { parseFunction(it) }, psi.getModifier().toSourceSetDependent(), - listOf(sourceSetData), + setOf(sourceSetData), emptyList(), psi.additionalExtras().let { PropertyContainer.withAll<DProperty>( |