Minor, move lazyClosure out of TypeUtils.kt
This commit is contained in:
@@ -144,27 +144,6 @@ fun <T> Collection<T>.closure(preserveOrder: Boolean = false, f: (T) -> Collecti
|
||||
return result
|
||||
}
|
||||
|
||||
fun <T> Collection<T>.lazyClosure(f: (T) -> Collection<T>): Sequence<T> = sequence {
|
||||
if (size == 0) return@sequence
|
||||
var sizeBeforeIteration = 0
|
||||
|
||||
yieldAll(this@lazyClosure)
|
||||
var yieldedCount = size
|
||||
var elementsToCheck = this@lazyClosure
|
||||
|
||||
while (yieldedCount > sizeBeforeIteration) {
|
||||
val toAdd = hashSetOf<T>()
|
||||
elementsToCheck.forEach {
|
||||
val neighbours = f(it)
|
||||
yieldAll(neighbours)
|
||||
yieldedCount += neighbours.size
|
||||
toAdd.addAll(neighbours)
|
||||
}
|
||||
elementsToCheck = toAdd
|
||||
sizeBeforeIteration = yieldedCount
|
||||
}
|
||||
}
|
||||
|
||||
fun boundClosure(types: Collection<KotlinType>): Collection<KotlinType> =
|
||||
types.closure { type -> TypeUtils.getTypeParameterDescriptorOrNull(type)?.upperBounds ?: emptySet() }
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.idea.util.isKotlinBinary
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.scripting.definitions.findScriptDefinition
|
||||
import org.jetbrains.kotlin.types.typeUtil.lazyClosure
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
@@ -310,3 +309,27 @@ private fun OrderEntry.toIdeaModuleInfo(
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
/**
|
||||
* @see [org.jetbrains.kotlin.types.typeUtil.closure].
|
||||
*/
|
||||
fun <T> Collection<T>.lazyClosure(f: (T) -> Collection<T>): Sequence<T> = sequence {
|
||||
if (size == 0) return@sequence
|
||||
var sizeBeforeIteration = 0
|
||||
|
||||
yieldAll(this@lazyClosure)
|
||||
var yieldedCount = size
|
||||
var elementsToCheck = this@lazyClosure
|
||||
|
||||
while (yieldedCount > sizeBeforeIteration) {
|
||||
val toAdd = hashSetOf<T>()
|
||||
elementsToCheck.forEach {
|
||||
val neighbours = f(it)
|
||||
yieldAll(neighbours)
|
||||
yieldedCount += neighbours.size
|
||||
toAdd.addAll(neighbours)
|
||||
}
|
||||
elementsToCheck = toAdd
|
||||
sizeBeforeIteration = yieldedCount
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,9 @@ import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
|
||||
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
|
||||
import org.jetbrains.kotlin.descriptors.konan.DeserializedKonanModuleOrigin
|
||||
import org.jetbrains.kotlin.ide.konan.analyzer.NativeResolverForModuleFactory
|
||||
import org.jetbrains.kotlin.idea.caches.project.IdeaModuleInfo
|
||||
import org.jetbrains.kotlin.idea.caches.project.LibraryInfo
|
||||
import org.jetbrains.kotlin.idea.caches.project.SdkInfo
|
||||
import org.jetbrains.kotlin.idea.caches.project.getModuleInfosFromIdeaModel
|
||||
import org.jetbrains.kotlin.idea.caches.project.lazyClosure
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.BuiltInsCacheKey
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.PlatformAnalysisSettings
|
||||
import org.jetbrains.kotlin.idea.compiler.IDELanguageSettingsProvider
|
||||
import org.jetbrains.kotlin.konan.file.File
|
||||
import org.jetbrains.kotlin.konan.library.*
|
||||
@@ -39,10 +36,10 @@ import org.jetbrains.kotlin.konan.util.KonanFactories
|
||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||
import org.jetbrains.kotlin.platform.impl.NativeIdePlatformKind
|
||||
import org.jetbrains.kotlin.platform.konan.KonanPlatforms
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration
|
||||
import org.jetbrains.kotlin.resolve.ImplicitIntegerCoercion
|
||||
import org.jetbrains.kotlin.resolve.TargetEnvironment
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.typeUtil.lazyClosure
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult
|
||||
|
||||
class NativePlatformKindResolution : IdePlatformKindResolution {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user