aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2017-02-24 14:17:12 +0100
committerDmitry Jemerov <yole@jetbrains.com>2017-02-24 14:17:12 +0100
commit5b90b573476f63366a5253280f5be5d68ac08a6d (patch)
tree9a8402096ecab392aab8d5ee62b0299ead8fd5e1 /core/src
parent386f3a88f24cc9ce032899354188dfc4d54ad0a8 (diff)
downloaddokka-5b90b573476f63366a5253280f5be5d68ac08a6d.tar.gz
dokka-5b90b573476f63366a5253280f5be5d68ac08a6d.tar.bz2
dokka-5b90b573476f63366a5253280f5be5d68ac08a6d.zip
Don't crash on source roots without a platform
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/Generation/DokkaGenerator.kt7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt
index f014ec58..6b5df7c9 100644
--- a/core/src/main/kotlin/Generation/DokkaGenerator.kt
+++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt
@@ -38,7 +38,7 @@ class DokkaGenerator(val logger: DokkaLogger,
private val documentationModule = DocumentationModule(moduleName)
fun generate() {
- val sourcesGroupedByPlatform = sources.groupBy { it.defaultPlatforms[0] }
+ val sourcesGroupedByPlatform = sources.groupBy { it.defaultPlatforms.firstOrNull() }
for ((platform, roots) in sourcesGroupedByPlatform) {
appendSourceModule(platform, roots)
}
@@ -52,7 +52,7 @@ class DokkaGenerator(val logger: DokkaLogger,
logger.info("done in ${timeBuild / 1000} secs")
}
- private fun appendSourceModule(defaultPlatform: String, sourceRoots: List<SourceRoot>) {
+ private fun appendSourceModule(defaultPlatform: String?, sourceRoots: List<SourceRoot>) {
val sourcePaths = sourceRoots.map { it.path }
val environment = createAnalysisEnvironment(sourcePaths)
@@ -64,12 +64,13 @@ class DokkaGenerator(val logger: DokkaLogger,
logger.info("Analysing sources and libraries... ")
val startAnalyse = System.currentTimeMillis()
+ val defaultPlatformAsList = defaultPlatform?.let { listOf(it) }.orEmpty()
val defaultPlatformsProvider = object : DefaultPlatformsProvider {
override fun getDefaultPlatforms(descriptor: DeclarationDescriptor): List<String> {
val containingFilePath = descriptor.sourcePsi()?.containingFile?.virtualFile?.canonicalPath
?.let { File(it).absolutePath }
val sourceRoot = containingFilePath?.let { path -> sourceRoots.find { path.startsWith(it.path) } }
- return sourceRoot?.defaultPlatforms ?: listOf(defaultPlatform)
+ return sourceRoot?.defaultPlatforms ?: defaultPlatformAsList
}
}