diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/kotlin/model/CompositeSourceSetID.kt | 8 | ||||
-rw-r--r-- | core/src/test/kotlin/model/CompositeSourceSetIDTest.kt | 10 |
2 files changed, 18 insertions, 0 deletions
diff --git a/core/src/main/kotlin/model/CompositeSourceSetID.kt b/core/src/main/kotlin/model/CompositeSourceSetID.kt index 5eb106bf..3c1cf7de 100644 --- a/core/src/main/kotlin/model/CompositeSourceSetID.kt +++ b/core/src/main/kotlin/model/CompositeSourceSetID.kt @@ -27,4 +27,12 @@ data class CompositeSourceSetID( operator fun contains(sourceSet: DokkaConfiguration.DokkaSourceSet): Boolean { return sourceSet.sourceSetID in this } + + operator fun plus(other: DokkaSourceSetID): CompositeSourceSetID { + return copy(children = children + other) + } +} + +operator fun DokkaSourceSetID.plus(other: DokkaSourceSetID): CompositeSourceSetID { + return CompositeSourceSetID(listOf(this, other)) } diff --git a/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt b/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt index ab9a2ab1..472581e7 100644 --- a/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt +++ b/core/src/test/kotlin/model/CompositeSourceSetIDTest.kt @@ -2,6 +2,7 @@ package model import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.model.CompositeSourceSetID +import org.jetbrains.dokka.model.plus import kotlin.test.* class CompositeSourceSetIDTest { @@ -55,4 +56,13 @@ class CompositeSourceSetIDTest { "Expected merged source set id being contained in composite" ) } + + @Test + fun `plus operator`() { + val composite = DokkaSourceSetID("m1", "s1") + DokkaSourceSetID("m2", "s2") + DokkaSourceSetID("m3", "s3") + assertEquals( + DokkaSourceSetID("m1+m2+m3", "s1+s2+s3"), composite.merged, + "Expected all three source sets being merged in order" + ) + } } |