diff options
author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-08-31 20:16:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-31 20:16:01 +0200 |
commit | 02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33 (patch) | |
tree | 66f6d6f089a93b863bf1144666491eca6729ad05 /core/src/main/kotlin/model/WithChildren.kt | |
parent | 6a181a7a2b03ec263788d137610e86937a57d434 (diff) | |
download | dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.gz dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.tar.bz2 dokka-02f30b142aa467d3a24cc52a1fe3f2fed7ea1e33.zip |
Enable explicit API mode (#3139)
Diffstat (limited to 'core/src/main/kotlin/model/WithChildren.kt')
-rw-r--r-- | core/src/main/kotlin/model/WithChildren.kt | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/core/src/main/kotlin/model/WithChildren.kt b/core/src/main/kotlin/model/WithChildren.kt index 01e69fd0..f73a5aa0 100644 --- a/core/src/main/kotlin/model/WithChildren.kt +++ b/core/src/main/kotlin/model/WithChildren.kt @@ -4,39 +4,39 @@ package org.jetbrains.dokka.model -interface WithChildren<out T> { - val children: List<T> +public interface WithChildren<out T> { + public val children: List<T> } -inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(): T? = +public inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(): T? = children.filterIsInstance<T>().firstOrNull() -inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = +public inline fun <reified T> WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = children.filterIsInstance<T>().firstOrNull(predicate) -inline fun <reified T> WithChildren<*>.firstChildOfType(): T = +public inline fun <reified T> WithChildren<*>.firstChildOfType(): T = children.filterIsInstance<T>().first() -inline fun <reified T> WithChildren<*>.childrenOfType(): List<T> = +public inline fun <reified T> WithChildren<*>.childrenOfType(): List<T> = children.filterIsInstance<T>() -inline fun <reified T> WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = +public inline fun <reified T> WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = children.filterIsInstance<T>().first(predicate) -inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType(): T where T : WithChildren<*> { +public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType(): T where T : WithChildren<*> { return withDescendants().filterIsInstance<T>().first() } -inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType( +public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType( predicate: (T) -> Boolean ): T where T : WithChildren<*> = withDescendants().filterIsInstance<T>().first(predicate) -inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { +public inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { return withDescendants().filterIsInstance<T>().firstOrNull() } -fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { +public fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -46,7 +46,7 @@ fun <T> T.withDescendants(): Sequence<T> where T : WithChildren<T> { } @JvmName("withDescendantsProjection") -fun WithChildren<*>.withDescendants(): Sequence<Any?> { +public fun WithChildren<*>.withDescendants(): Sequence<Any?> { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -58,7 +58,7 @@ fun WithChildren<*>.withDescendants(): Sequence<Any?> { } @JvmName("withDescendantsAny") -fun WithChildren<Any>.withDescendants(): Sequence<Any> { +public fun WithChildren<Any>.withDescendants(): Sequence<Any> { return sequence { yield(this@withDescendants) children.forEach { child -> @@ -69,13 +69,13 @@ fun WithChildren<Any>.withDescendants(): Sequence<Any> { } } -fun <T> T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren<T> = if (predicate(this)) { +public fun <T> T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren<T> = if (predicate(this)) { this } else { children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() } -fun <T : WithChildren<T>> T.asPrintableTree( +public fun <T : WithChildren<T>> T.asPrintableTree( nodeNameBuilder: Appendable.(T) -> Unit = { append(it.toString()) } ): String { fun Appendable.append(element: T, ownPrefix: String, childPrefix: String) { |