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 b48660d
Showing 1 changed file with 5 additions and 15 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

0 comments on commit b48660d

Please sign in to comment.