
org.jetbrains.kotlin.fir.resolve.AbstractFirSymbolProvider.kt Maven / Gradle / Ivy
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.resolve
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import org.jetbrains.kotlin.fir.visitors.FirTransformer
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
abstract class AbstractFirSymbolProvider : FirSymbolProvider() {
protected val classCache = HashMap?>()
protected val topLevelCallableCache = HashMap>>()
protected val packageCache = HashMap()
protected inline fun MutableMap.lookupCacheOrCalculate(key: K, crossinline l: (K) -> V): V? {
return if (containsKey(key)) {
this[key]
} else {
val calculated = l(key)
this[key] = calculated
calculated
}
}
protected inline fun MutableMap.lookupCacheOrCalculateWithPostCompute(
key: K, crossinline l: (K) -> Pair, postCompute: (V, T) -> Unit
): V? {
return if (containsKey(key)) {
this[key]
} else {
val calculated = l(key)
this[key] = calculated.first
postCompute(calculated.first, calculated.second)
calculated.first
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy