From 33c1eb4f6ad1d7ec4cd1e7760c37728a930a52b6 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Tue, 1 Sep 2020 14:20:03 +0200 Subject: Fix a bug in the DefaultLocationProvider which skipped lookup of some relocated DRIs --- .../resolvers/local/DefaultLocationProvider.kt | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'plugins/base/src/main/kotlin/resolvers/local') diff --git a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt index e085af1a..293ca2d4 100644 --- a/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt +++ b/plugins/base/src/main/kotlin/resolvers/local/DefaultLocationProvider.kt @@ -20,7 +20,7 @@ abstract class DefaultLocationProvider( protected val externalLocationProviderFactories = dokkaContext.plugin().query { externalLocationProviderFactory } - protected val packagesIndex: Map = dokkaContext + protected val externalLocationProviders: Map = dokkaContext .configuration .sourceSets .flatMap { sourceSet -> @@ -30,18 +30,32 @@ abstract class DefaultLocationProvider( } } .filterNotNull() - .flatMap { extDocInfo -> - extDocInfo.packageList.packages.map { packageName -> - val externalLocationProvider = (externalLocationProviderFactories.asSequence() - .mapNotNull { it.getExternalLocationProvider(extDocInfo) }.firstOrNull() - ?: run { dokkaContext.logger.error("No ExternalLocationProvider for '${extDocInfo.packageList.url}' found"); null }) - packageName to externalLocationProvider - } + .map { extDocInfo -> + val externalLocationProvider = (externalLocationProviderFactories.asSequence() + .mapNotNull { it.getExternalLocationProvider(extDocInfo) }.firstOrNull() + ?: run { dokkaContext.logger.error("No ExternalLocationProvider for '${extDocInfo.packageList.url}' found"); null }) + extDocInfo to externalLocationProvider + } + .toMap() + + protected val packagesIndex: Map = externalLocationProviders + .flatMap { (extDocInfo, externalLocationProvider) -> + extDocInfo.packageList.packages.map { packageName -> packageName to externalLocationProvider } + } + .toMap() + .filterKeys(String::isNotBlank) + + + protected val locationsIndex: Map = externalLocationProviders + .flatMap { (extDocInfo, externalLocationProvider) -> + extDocInfo.packageList.locations.keys.map { relocatedDri -> relocatedDri to externalLocationProvider } } .toMap() .filterKeys(String::isNotBlank) protected open fun getExternalLocation(dri: DRI, sourceSets: Set): String? = packagesIndex[dri.packageName]?.resolve(dri) + ?: locationsIndex[dri.toString()]?.resolve(dri) + ?: externalLocationProviders.values.mapNotNull { it?.resolve(dri) }.firstOrNull() } -- cgit