Skip to content

Commit

Permalink
Use DokkaSourceSetID
Browse files Browse the repository at this point in the history
  • Loading branch information
vmishenev committed Jan 23, 2023
1 parent d854002 commit 7b8ce5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
Expand Up @@ -83,33 +83,23 @@ abstract class KotlinAnalysis(
) : Closeable {

operator fun get(key: DokkaSourceSet): AnalysisContext {
return get(key.sourceSetID)
}
operator fun get(key: DokkaSourceSetID): AnalysisContext {
return find(key)
?: parent?.get(key)
?: throw IllegalStateException("Missing EnvironmentAndFacade for sourceSet ${key}")
}

operator fun get(sourceSetID: DokkaSourceSetID): AnalysisContext {
return find(sourceSetID)
?: parent?.get(sourceSetID)
?: throw IllegalStateException("Missing EnvironmentAndFacade for sourceSet ${sourceSetID.sourceSetName}")
}

protected abstract fun find(sourceSetID: DokkaSourceSetID): AnalysisContext?
protected abstract fun find(sourceSet: DokkaSourceSet): AnalysisContext?
}

internal open class EnvironmentKotlinAnalysis(
private val environments: SourceSetDependent<AnalysisContext>,
parent: KotlinAnalysis? = null,
) : KotlinAnalysis(parent = parent) {

override fun find(sourceSetID: DokkaSourceSetID): AnalysisContext? {
return environments.entries.firstOrNull { (sourceSet, _) -> sourceSet.sourceSetID == sourceSetID }?.value
}

override fun find(sourceSet: DokkaSourceSet): AnalysisContext? {
return environments[sourceSet]
}
override fun find(sourceSetID: DokkaSourceSetID): AnalysisContext? =
environments.entries.firstOrNull { (sourceSet, _) -> sourceSet.sourceSetID == sourceSetID }?.value

override fun close() {
environments.values.forEach(AnalysisContext::close)
Expand Down
4 changes: 2 additions & 2 deletions plugins/base/src/test/kotlin/model/InheritorsTest.kt
Expand Up @@ -61,12 +61,12 @@ class InheritorsTest : AbstractModelTest("/src/main/kotlin/inheritors/Test.kt",
val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
displayName = "jvm"
name = "jvm"
sourceRoots = listOf("common/src/", "jvm/src/")
analysisPlatform = "jvm"
}
sourceSet {
displayName = "js"
name = "js"
sourceRoots = listOf("common/src/", "js/src/")
analysisPlatform = "js"
}
Expand Down

0 comments on commit 7b8ce5b

Please sign in to comment.