From 14f0d36f6ec9d192a5c46c2b8267dcb2f1d21aa1 Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Thu, 12 Mar 2020 15:23:07 +0100 Subject: Response to comments --- .../src/main/kotlin/model/properties/properties.kt | 3 --- core/src/main/kotlin/plugability/extensions.kt | 29 ++++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'core/src') diff --git a/core/src/main/kotlin/model/properties/properties.kt b/core/src/main/kotlin/model/properties/properties.kt index 4c8b345f..7010d0df 100644 --- a/core/src/main/kotlin/model/properties/properties.kt +++ b/core/src/main/kotlin/model/properties/properties.kt @@ -1,8 +1,5 @@ package org.jetbrains.dokka.model.properties -import org.jetbrains.dokka.model.Documentable -import org.jetbrains.dokka.model.ExtraModifiers - interface ExtraProperty { interface Key { fun mergeStrategyFor(left: T, right: T): MergeStrategy = MergeStrategy.Fail { diff --git a/core/src/main/kotlin/plugability/extensions.kt b/core/src/main/kotlin/plugability/extensions.kt index 1f994e75..20b60469 100644 --- a/core/src/main/kotlin/plugability/extensions.kt +++ b/core/src/main/kotlin/plugability/extensions.kt @@ -15,7 +15,7 @@ abstract class Extension internal constructor( internal val extensionName: String, internal val action: LazyEvaluated, internal val ordering: (OrderDsl.() -> Unit)? = null, - internal val condition: DokkaConfiguration.() -> Boolean = { true }, + internal val conditions: Array Boolean> = emptyArray(), internal val isFallback: Boolean ) { override fun toString() = "Extension: $pluginClass/$extensionName" @@ -26,9 +26,12 @@ abstract class Extension internal constructor( override fun hashCode() = listOf(pluginClass, extensionName).hashCode() - abstract fun setCondition(condition: (DokkaConfiguration.() -> Boolean)): Extension + abstract fun addCondition(condition: (DokkaConfiguration.() -> Boolean)): Extension abstract fun markedAsFallback(): Extension + + open val condition: DokkaConfiguration.() -> Boolean + get() = { conditions.all { it(this) }} } class ExtensionOrdered internal constructor( @@ -37,7 +40,7 @@ class ExtensionOrdered internal constructor( extensionName: String, action: LazyEvaluated, ordering: (OrderDsl.() -> Unit), - condition: DokkaConfiguration.() -> Boolean = { true }, + conditions: Array Boolean> = emptyArray(), isFallback: Boolean = false ) : Extension( extensionPoint, @@ -45,14 +48,14 @@ class ExtensionOrdered internal constructor( extensionName, action, ordering, - condition, + conditions, isFallback ) { - override fun setCondition(condition: DokkaConfiguration.() -> Boolean) = - ExtensionOrdered(extensionPoint, pluginClass, extensionName, action, ordering!!, condition) + override fun addCondition(condition: DokkaConfiguration.() -> Boolean) = + ExtensionOrdered(extensionPoint, pluginClass, extensionName, action, ordering!!, conditions + condition) override fun markedAsFallback() = - ExtensionOrdered(extensionPoint, pluginClass, extensionName, action, ordering!!, condition, true) + ExtensionOrdered(extensionPoint, pluginClass, extensionName, action, ordering!!, conditions, true) } class ExtensionUnordered internal constructor( @@ -60,7 +63,7 @@ class ExtensionUnordered internal constructor( pluginClass: String, extensionName: String, action: LazyEvaluated, - condition: DokkaConfiguration.() -> Boolean = { true }, + conditions: Array Boolean> = emptyArray(), isFallback: Boolean = false ) : Extension( extensionPoint, @@ -68,14 +71,14 @@ class ExtensionUnordered internal constructor( extensionName, action, null, - condition, + conditions, isFallback ) { - override fun setCondition(condition: DokkaConfiguration.() -> Boolean) = - ExtensionUnordered(extensionPoint, pluginClass, extensionName, action, condition) + override fun addCondition(condition: DokkaConfiguration.() -> Boolean) = + ExtensionUnordered(extensionPoint, pluginClass, extensionName, action, conditions + condition) override fun markedAsFallback() = - ExtensionUnordered(extensionPoint, pluginClass, extensionName, action, condition, true) + ExtensionUnordered(extensionPoint, pluginClass, extensionName, action, conditions, true) } internal data class Ordering(val previous: Set>, val following: Set>) @@ -96,7 +99,7 @@ class ExtendingDSL(private val pluginClass: String, private val extensionName: S ExtensionOrdered(extensionPoint, pluginClass, extensionName, action, block) infix fun Extension.applyIf(condition: DokkaConfiguration.() -> Boolean): Extension = - this.setCondition { this@applyIf.condition(this) && condition(this) } + this.addCondition(condition) } -- cgit