Minor: extract function
This commit is contained in:
+11
-16
@@ -165,31 +165,26 @@ public class KotlinCacheService(val project: Project) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun getGlobalLazyResolveSession(file: JetFile, platform: TargetPlatform): ResolveSessionForBodies {
|
|
||||||
return getGlobalCache(platform).getLazyResolveSession(file)
|
|
||||||
}
|
|
||||||
|
|
||||||
public fun getLazyResolveSession(element: JetElement): ResolveSessionForBodies {
|
public fun getLazyResolveSession(element: JetElement): ResolveSessionForBodies {
|
||||||
val file = element.getContainingJetFile()
|
val file = element.getContainingJetFile()
|
||||||
val syntheticFiles = findSyntheticFiles(listOf(file))
|
return getCacheToAnalyzeFiles(listOf(file)).getLazyResolveSession(file)
|
||||||
if (syntheticFiles.isNotEmpty()) {
|
|
||||||
return getCacheForSyntheticFiles(syntheticFiles).getLazyResolveSession(file)
|
|
||||||
}
|
|
||||||
|
|
||||||
return getGlobalLazyResolveSession(file, TargetPlatformDetector.getPlatform(file))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun getAnalysisResults(elements: Collection<JetElement>): AnalyzeExhaust {
|
public fun getAnalysisResults(elements: Collection<JetElement>): AnalyzeExhaust {
|
||||||
val files = elements.map { it.getContainingJetFile() }.toSet()
|
val files = elements.map { it.getContainingJetFile() }.toSet()
|
||||||
assertAreInSameModule(files)
|
assertAreInSameModule(files)
|
||||||
|
|
||||||
val syntheticFiles = findSyntheticFiles(files)
|
return getCacheToAnalyzeFiles(files).getAnalysisResultsForElements(elements)
|
||||||
if (syntheticFiles.isNotEmpty()) {
|
}
|
||||||
return getCacheForSyntheticFiles(syntheticFiles).getAnalysisResultsForElements(elements)
|
|
||||||
}
|
|
||||||
|
|
||||||
val firstFile = elements.first().getContainingJetFile()
|
private fun getCacheToAnalyzeFiles(files: Collection<JetFile>): KotlinResolveCache {
|
||||||
return getGlobalCache(TargetPlatformDetector.getPlatform(firstFile)).getAnalysisResultsForElements(elements)
|
val syntheticFiles = findSyntheticFiles(files)
|
||||||
|
return if (syntheticFiles.isNotEmpty()) {
|
||||||
|
getCacheForSyntheticFiles(syntheticFiles)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
getGlobalCache(TargetPlatformDetector.getPlatform(files.first()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findSyntheticFiles(files: Collection<JetFile>) = files.map {
|
private fun findSyntheticFiles(files: Collection<JetFile>) = files.map {
|
||||||
|
|||||||
Reference in New Issue
Block a user