Remove reference to binding context from LazyLightClassDataHolder cache

The ultimate goal is to remove references to binding context and resolve
result from light classes. There still can be references from `diagnostics`
field, but `bindingContext` is unneeded and can be removed.

Relates to snapshots from IDEA-187395.
This commit is contained in:
Nikolay Krasko
2018-03-16 11:38:42 +03:00
parent 481a5bc28d
commit 14a0434737
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.asJava.elements.KtLightMethodImpl
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.NotNullableUserDataProperty
import org.jetbrains.kotlin.psi.debugText.getDebugText
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
typealias ExactLightClassContextProvider = () -> LightClassConstructionContext
@@ -38,16 +39,23 @@ sealed class LazyLightClassDataHolder(
isLocal: Boolean = false
) : LightClassDataHolder {
private data class CachedLightClassBuilderResult(val stub: PsiJavaFileStub, val diagnostics: Diagnostics)
private val exactResultCachedValue =
CachedValuesManager.getManager(project).createCachedValue({
CachedValueProvider.Result.create(
builder(exactContextProvider()),
if (isLocal)
PsiModificationTracker.MODIFICATION_COUNT
else
PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT
)
}, false)
CachedValuesManager.getManager(project).createCachedValue(
{
val (stub, _, diagnostics) = builder(exactContextProvider())
val cachedResult = CachedLightClassBuilderResult(stub, diagnostics)
CachedValueProvider.Result.create(
cachedResult,
if (isLocal)
PsiModificationTracker.MODIFICATION_COUNT
else
PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT
)
}, false
)
private val lazyInexactStub by lazyPub {
dummyContextProvider?.let { provider -> provider()?.let { context -> builder.invoke(context).stub } }