Allow calling KotlinCacheService.getResolutionFacade() with an empty set of Kotlin files.

This is needed in Dokka, where a project to be documented can contain only Java files, but we will still attempt to resolve links in Markdown files containing package documentation through the KDoc reference resolver. The attempts will fail when there are no Kotlin files, but at least we won't crash trying to retrieve the first element of an empty list.
This commit is contained in:
Dmitry Jemerov
2015-05-27 18:18:19 +02:00
parent 3ad06f169d
commit a41205fff7
2 changed files with 7 additions and 2 deletions
@@ -202,7 +202,12 @@ public class KotlinCacheService(val project: Project) {
getCacheForSyntheticFiles(syntheticFiles)
}
else {
getGlobalCache(TargetPlatformDetector.getPlatform(files.first()))
val firstFile = files.firstOrNull()
val targetPlatform = if (firstFile != null)
TargetPlatformDetector.getPlatform(firstFile)
else
TargetPlatformDetector.getDefaultPlatform()
getGlobalCache(targetPlatform)
}
}
@@ -53,7 +53,7 @@ public class TargetPlatformDetector {
}
@NotNull
private static TargetPlatform getDefaultPlatform() {
public static TargetPlatform getDefaultPlatform() {
LOG.info("Using default platform");
return TargetPlatform.JVM;
}