diff options
Diffstat (limited to 'core/src/main/kotlin/plugability/extensions.kt')
-rw-r--r-- | core/src/main/kotlin/plugability/extensions.kt | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/core/src/main/kotlin/plugability/extensions.kt b/core/src/main/kotlin/plugability/extensions.kt index 4cbb61eb..46c356df 100644 --- a/core/src/main/kotlin/plugability/extensions.kt +++ b/core/src/main/kotlin/plugability/extensions.kt @@ -15,7 +15,8 @@ abstract class Extension<T : Any> internal constructor( internal val extensionName: String, internal val action: LazyEvaluated<T>, internal val ordering: (OrderDsl.() -> Unit)? = null, - internal val condition: DokkaConfiguration.() -> Boolean = { true } + internal val condition: DokkaConfiguration.() -> Boolean = { true }, + internal val isFallback: Boolean ) { override fun toString() = "Extension: $pluginClass/$extensionName" @@ -26,6 +27,8 @@ abstract class Extension<T : Any> internal constructor( override fun hashCode() = listOf(pluginClass, extensionName).hashCode() abstract fun setCondition(condition: (DokkaConfiguration.() -> Boolean)): Extension<T> + + abstract fun markedAsFallback(): Extension<T> } class ExtensionOrdered<T : Any> internal constructor( @@ -34,17 +37,22 @@ class ExtensionOrdered<T : Any> internal constructor( extensionName: String, action: LazyEvaluated<T>, ordering: (OrderDsl.() -> Unit), - condition: DokkaConfiguration.() -> Boolean = { true } + condition: DokkaConfiguration.() -> Boolean = { true }, + isFallback: Boolean = false ) : Extension<T>( extensionPoint, pluginClass, extensionName, action, ordering, - condition + condition, + isFallback ) { override fun setCondition(condition: DokkaConfiguration.() -> Boolean) = ExtensionOrdered(extensionPoint, pluginClass, extensionName, action, ordering!!, condition) + + override fun markedAsFallback() = + ExtensionOrdered(extensionPoint, pluginClass, extensionName, action, ordering!!, condition, true) } class ExtensionUnordered<T : Any> internal constructor( @@ -52,17 +60,22 @@ class ExtensionUnordered<T : Any> internal constructor( pluginClass: String, extensionName: String, action: LazyEvaluated<T>, - condition: DokkaConfiguration.() -> Boolean = { true } + condition: DokkaConfiguration.() -> Boolean = { true }, + isFallback: Boolean = false ) : Extension<T>( extensionPoint, pluginClass, extensionName, action, null, - condition + condition, + isFallback ) { override fun setCondition(condition: DokkaConfiguration.() -> Boolean) = ExtensionUnordered(extensionPoint, pluginClass, extensionName, action, condition) + + override fun markedAsFallback() = + ExtensionUnordered(extensionPoint, pluginClass, extensionName, action, condition, true) } internal data class Ordering(val previous: Set<Extension<*>>, val following: Set<Extension<*>>) @@ -79,10 +92,11 @@ class ExtendingDSL(private val pluginClass: String, private val extensionName: S infix fun <T : Any> ExtensionPoint<T>.providing(action: (DokkaContext) -> T) = ExtensionUnordered(this, this@ExtendingDSL.pluginClass, extensionName, LazyEvaluated.fromRecipe(action)) - infix fun <T: Any> ExtensionUnordered<T>.order(block: OrderDsl.() -> Unit) = + infix fun <T : Any> ExtensionUnordered<T>.order(block: OrderDsl.() -> Unit) = ExtensionOrdered(extensionPoint, pluginClass, extensionName, action, block) - infix fun <T : Any> Extension<T>.applyIf(condition: DokkaConfiguration.() -> Boolean): Extension<T> = this.setCondition(condition) + infix fun <T : Any> Extension<T>.applyIf(condition: DokkaConfiguration.() -> Boolean): Extension<T> = + this.setCondition(condition) } @ExtensionsDsl |