Synchronization logic extracted into a method
This commit is contained in:
@@ -135,6 +135,12 @@ class KotlinCacheService(val project: Project) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getCacheForSyntheticFile(file: JetFile): KotlinResolveCache {
|
||||||
|
return synchronized(syntheticFileCaches) {
|
||||||
|
syntheticFileCaches[file]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public fun getGlobalLazyResolveSession(platform: TargetPlatform): ResolveSessionForBodies {
|
public fun getGlobalLazyResolveSession(platform: TargetPlatform): ResolveSessionForBodies {
|
||||||
return globalCachesPerPlatform[platform]!!.getLazyResolveSession()
|
return globalCachesPerPlatform[platform]!!.getLazyResolveSession()
|
||||||
}
|
}
|
||||||
@@ -142,9 +148,7 @@ class KotlinCacheService(val project: Project) {
|
|||||||
public fun getLazyResolveSession(element: JetElement): ResolveSessionForBodies {
|
public fun getLazyResolveSession(element: JetElement): ResolveSessionForBodies {
|
||||||
val file = element.getContainingJetFile()
|
val file = element.getContainingJetFile()
|
||||||
if (!isFileInScope(file)) {
|
if (!isFileInScope(file)) {
|
||||||
return synchronized(syntheticFileCaches) {
|
return getCacheForSyntheticFile(file).getLazyResolveSession()
|
||||||
syntheticFileCaches[file].getLazyResolveSession()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return getGlobalLazyResolveSession(TargetPlatformDetector.getPlatform(file))
|
return getGlobalLazyResolveSession(TargetPlatformDetector.getPlatform(file))
|
||||||
@@ -155,9 +159,7 @@ class KotlinCacheService(val project: Project) {
|
|||||||
|
|
||||||
val firstFile = elements.first().getContainingJetFile()
|
val firstFile = elements.first().getContainingJetFile()
|
||||||
if (elements.size == 1 && !isFileInScope(firstFile)) {
|
if (elements.size == 1 && !isFileInScope(firstFile)) {
|
||||||
return synchronized(syntheticFileCaches) {
|
return getCacheForSyntheticFile(firstFile).getAnalysisResultsForElements(elements)
|
||||||
syntheticFileCaches[firstFile].getAnalysisResultsForElements(elements)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val resolveCache = globalCachesPerPlatform[TargetPlatformDetector.getPlatform(firstFile)]!!
|
val resolveCache = globalCachesPerPlatform[TargetPlatformDetector.getPlatform(firstFile)]!!
|
||||||
|
|||||||
Reference in New Issue
Block a user