Refactor FirSelfImportingScope
This commit is contained in:
committed by
Mikhail Glukhikh
parent
f22cca5087
commit
a5ca8ffe69
+4
-12
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.scopes.impl
|
package org.jetbrains.kotlin.fir.scopes.impl
|
||||||
|
|
||||||
import com.intellij.util.containers.ContainerUtil
|
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
import org.jetbrains.kotlin.fir.FirSession
|
||||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
||||||
@@ -19,26 +18,19 @@ class FirSelfImportingScope(val fqName: FqName, val session: FirSession) : FirSc
|
|||||||
|
|
||||||
private val symbolProvider = FirSymbolProvider.getInstance(session)
|
private val symbolProvider = FirSymbolProvider.getInstance(session)
|
||||||
|
|
||||||
private val cache = ContainerUtil.newConcurrentMap<Name, ConeClassifierSymbol>()
|
private val cache = mutableMapOf<Name, ConeClassifierSymbol?>()
|
||||||
private val absentKeys = ContainerUtil.newConcurrentSet<Name>()
|
|
||||||
|
|
||||||
override fun processClassifiersByName(
|
override fun processClassifiersByName(
|
||||||
name: Name,
|
name: Name,
|
||||||
position: FirPosition,
|
position: FirPosition,
|
||||||
processor: (ConeClassifierSymbol) -> Boolean
|
processor: (ConeClassifierSymbol) -> Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
|
if (name.asString().isEmpty()) return true
|
||||||
|
|
||||||
|
|
||||||
if (name in absentKeys) return true
|
val symbol = cache.getOrPut(name) {
|
||||||
val symbol = cache[name] ?: run {
|
|
||||||
val unambiguousFqName = ClassId(fqName, name)
|
val unambiguousFqName = ClassId(fqName, name)
|
||||||
val computed = symbolProvider.getClassLikeSymbolByFqName(unambiguousFqName)
|
symbolProvider.getClassLikeSymbolByFqName(unambiguousFqName)
|
||||||
if (computed == null) {
|
|
||||||
absentKeys += name
|
|
||||||
} else {
|
|
||||||
cache[name] = computed
|
|
||||||
}
|
|
||||||
computed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return if (symbol != null) {
|
return if (symbol != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user