aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/model/SourceSetData.kt
blob: 3e38cc7b490fcf2bf9bfeebe2dc76324898a219b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package org.jetbrains.dokka.model

import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.plugability.DokkaContext

data class SourceSetData(
    val moduleName: String,
    val sourceSetID: String,
    val displayName: String,
    val platform: Platform,
    val sourceRoots: List<DokkaConfiguration.SourceRoot> = emptyList(),
    val dependentSourceSets: List<String> = emptyList()
)

class SourceSetCache {
    private val sourceSets = HashMap<String, SourceSetData>()

    val allSourceSets: List<SourceSetData>
        get() = sourceSets.values.toList()

    fun getSourceSet(pass: DokkaConfiguration.PassConfiguration) =
        sourceSets.getOrPut(pass.sourceSetID,
            {
                SourceSetData(
                    pass.moduleName,
                    pass.sourceSetID,
                    pass.displayName,
                    pass.analysisPlatform,
                    pass.sourceRoots,
                    pass.dependentSourceSets
                )
            }
        )
}

fun DokkaContext.sourceSet(pass: DokkaConfiguration.PassConfiguration): SourceSetData =
    sourceSetCache.getSourceSet(pass)