aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
authorBłażej Kardyś <bkardys@virtuslab.com>2020-03-20 16:59:05 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-03-23 08:52:29 +0100
commit1ec41b16f609a15dc66e13c381aa4ac0ef74d07c (patch)
treee30841b902299d477a37d9bec23a017f8cc7a609 /plugins/base/src/main/kotlin
parentec5990f948647c245a5f7996bb8a9f62ccc6a3c5 (diff)
downloaddokka-1ec41b16f609a15dc66e13c381aa4ac0ef74d07c.tar.gz
dokka-1ec41b16f609a15dc66e13c381aa4ac0ef74d07c.tar.bz2
dokka-1ec41b16f609a15dc66e13c381aa4ac0ef74d07c.zip
Restoring filtered out expected values
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt24
1 files changed, 12 insertions, 12 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt
index 76276f39..150df302 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/DocumentableVisibilityFilter.kt
@@ -79,27 +79,27 @@ internal object DocumentableVisibilityFilter : PreMergeDocumentableTransformer {
private fun <T : WithVisibility> alwaysTrue(a: T, p: PlatformData) = true
private fun <T : WithVisibility> alwaysFalse(a: T, p: PlatformData) = false
+ private fun WithVisibility.visibilityForPlatform(data: PlatformData): Visibility? =
+ visibility[data] ?: visibility.expect
+
private fun <T> T.filterPlatforms(
additionalCondition: (T, PlatformData) -> Boolean = ::alwaysTrue,
- optionalCondition: (T, PlatformData) -> Boolean = ::alwaysFalse
+ alternativeCondition: (T, PlatformData) -> Boolean = ::alwaysFalse
) where T : Documentable, T : WithVisibility =
- visibility.mapNotNull { (platformData, visibility) ->
- platformData.takeIf { d ->
- (visibility.isAllowedInPackage(dri.packageName) || optionalCondition(
- this,
- d
- )) && additionalCondition(this, d)
- }
+ platformData.filter { d ->
+ visibilityForPlatform(d)?.isAllowedInPackage(dri.packageName) == true &&
+ additionalCondition(this, d) ||
+ alternativeCondition(this, d)
}
private fun <T> List<T>.transform(
additionalCondition: (T, PlatformData) -> Boolean = ::alwaysTrue,
- optionalCondition: (T, PlatformData) -> Boolean = ::alwaysFalse,
+ alternativeCondition: (T, PlatformData) -> Boolean = ::alwaysFalse,
recreate: (T, List<PlatformData>) -> T
): Pair<Boolean, List<T>> where T : Documentable, T : WithVisibility {
var changed = false
val values = mapNotNull { t ->
- val filteredPlatforms = t.filterPlatforms(additionalCondition, optionalCondition)
+ val filteredPlatforms = t.filterPlatforms(additionalCondition, alternativeCondition)
when (filteredPlatforms.size) {
t.visibility.size -> t
0 -> {
@@ -140,8 +140,8 @@ internal object DocumentableVisibilityFilter : PreMergeDocumentableTransformer {
}
private fun hasVisibleAccessorsForPlatform(property: DProperty, data: PlatformData) =
- property.getter?.visibility?.get(data)?.isAllowedInPackage(property.dri.packageName) == true ||
- property.setter?.visibility?.get(data)?.isAllowedInPackage(property.dri.packageName) == true
+ property.getter?.visibilityForPlatform(data)?.isAllowedInPackage(property.dri.packageName) == true ||
+ property.setter?.visibilityForPlatform(data)?.isAllowedInPackage(property.dri.packageName) == true
private fun filterProperties(
properties: List<DProperty>,