aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-08-05 15:38:00 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-14 14:16:41 +0200
commit0a2a5896ece71f9d37930274c86b09a5fdf38644 (patch)
tree5df828b2698a0b99d8a66ba56c3b0962cf19bc80 /core/src
parente9ae3982e3b1e7b5dfd105a9e0cad9ccd9ee8d41 (diff)
downloaddokka-0a2a5896ece71f9d37930274c86b09a5fdf38644.tar.gz
dokka-0a2a5896ece71f9d37930274c86b09a5fdf38644.tar.bz2
dokka-0a2a5896ece71f9d37930274c86b09a5fdf38644.zip
Add tests checking omitting of obvious types
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/model/WithChildren.kt7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/src/main/kotlin/model/WithChildren.kt b/core/src/main/kotlin/model/WithChildren.kt
index 4aba51c6..59a14acc 100644
--- a/core/src/main/kotlin/model/WithChildren.kt
+++ b/core/src/main/kotlin/model/WithChildren.kt
@@ -23,6 +23,11 @@ inline fun <reified T> WithChildren<WithChildren<*>>.firstMemberOfType(): T wher
return withDescendants().filterIsInstance<T>().first()
}
+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<*> {
return withDescendants().filterIsInstance<T>().firstOrNull()
}
@@ -66,7 +71,7 @@ fun <T> T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren<T> = if (pre
children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull()
}
-fun <T: WithChildren<T>> T.asPrintableTree(
+fun <T : WithChildren<T>> T.asPrintableTree(
nodeNameBuilder: Appendable.(T) -> Unit = { append(it.toString()) }
): String {
fun Appendable.append(element: T, ownPrefix: String, childPrefix: String) {