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:
+6
-1
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class TargetPlatformDetector {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static TargetPlatform getDefaultPlatform() {
|
||||
public static TargetPlatform getDefaultPlatform() {
|
||||
LOG.info("Using default platform");
|
||||
return TargetPlatform.JVM;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user