From 77a3012145d04ff959de86fb5ec3845cde4b8167 Mon Sep 17 00:00:00 2001
From: Dmitry Jemerov <yole@jetbrains.com>
Date: Fri, 24 Feb 2017 11:56:23 +0100
Subject: Detect default platforms based only on the roots that we're currently
 processing

---
 core/src/main/kotlin/Generation/DokkaGenerator.kt | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'core')

diff --git a/core/src/main/kotlin/Generation/DokkaGenerator.kt b/core/src/main/kotlin/Generation/DokkaGenerator.kt
index b7163a5c..f014ec58 100644
--- a/core/src/main/kotlin/Generation/DokkaGenerator.kt
+++ b/core/src/main/kotlin/Generation/DokkaGenerator.kt
@@ -40,7 +40,7 @@ class DokkaGenerator(val logger: DokkaLogger,
     fun generate() {
         val sourcesGroupedByPlatform = sources.groupBy { it.defaultPlatforms[0] }
         for ((platform, roots) in sourcesGroupedByPlatform) {
-            appendSourceModule(platform, roots.map { it.path })
+            appendSourceModule(platform, roots)
         }
         documentationModule.prepareForGeneration(options)
 
@@ -52,7 +52,8 @@ class DokkaGenerator(val logger: DokkaLogger,
         logger.info("done in ${timeBuild / 1000} secs")
     }
 
-    private fun appendSourceModule(defaultPlatform: String, sourcePaths: List<String>) {
+    private fun appendSourceModule(defaultPlatform: String, sourceRoots: List<SourceRoot>) {
+        val sourcePaths = sourceRoots.map { it.path }
         val environment = createAnalysisEnvironment(sourcePaths)
 
         logger.info("Module: $moduleName")
@@ -67,7 +68,7 @@ class DokkaGenerator(val logger: DokkaLogger,
             override fun getDefaultPlatforms(descriptor: DeclarationDescriptor): List<String> {
                 val containingFilePath = descriptor.sourcePsi()?.containingFile?.virtualFile?.canonicalPath
                         ?.let { File(it).absolutePath }
-                val sourceRoot = containingFilePath?.let { path -> sources.find { path.startsWith(it.path) } }
+                val sourceRoot = containingFilePath?.let { path -> sourceRoots.find { path.startsWith(it.path) } }
                 return sourceRoot?.defaultPlatforms ?: listOf(defaultPlatform)
             }
         }
-- 
cgit