Don't keep ref to ABSENT_KOTLIN_INJECTION in companion object
As it prevents from dynamic reloading of plugin ^KT-39958 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
7c2112d014
commit
677f5ca4e3
@@ -56,11 +56,11 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
|||||||
class KotlinLanguageInjector(
|
class KotlinLanguageInjector(
|
||||||
private val project: Project
|
private val project: Project
|
||||||
) : MultiHostInjector {
|
) : MultiHostInjector {
|
||||||
|
private val absentKotlinInjection = BaseInjection("ABSENT_KOTLIN_BASE_INJECTION")
|
||||||
private val configuration get() = Configuration.getProjectInstance(project)
|
private val configuration get() = Configuration.getProjectInstance(project)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val STRING_LITERALS_REGEXP = "\"([^\"]*)\"".toRegex()
|
private val STRING_LITERALS_REGEXP = "\"([^\"]*)\"".toRegex()
|
||||||
private val ABSENT_KOTLIN_INJECTION = BaseInjection("ABSENT_KOTLIN_BASE_INJECTION")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val kotlinSupport: KotlinLanguageInjectionSupport? by lazy {
|
private val kotlinSupport: KotlinLanguageInjectionSupport? by lazy {
|
||||||
@@ -88,14 +88,14 @@ class KotlinLanguageInjector(
|
|||||||
val baseInjection = when {
|
val baseInjection = when {
|
||||||
needImmediateAnswer -> {
|
needImmediateAnswer -> {
|
||||||
// Can't afford long counting or typing will be laggy. Force cache reuse even if it's outdated.
|
// Can't afford long counting or typing will be laggy. Force cache reuse even if it's outdated.
|
||||||
kotlinCachedInjection?.baseInjection ?: ABSENT_KOTLIN_INJECTION
|
kotlinCachedInjection?.baseInjection ?: absentKotlinInjection
|
||||||
}
|
}
|
||||||
kotlinCachedInjection != null && (modificationCount == kotlinCachedInjection.modificationCount) ->
|
kotlinCachedInjection != null && (modificationCount == kotlinCachedInjection.modificationCount) ->
|
||||||
// Cache is up-to-date
|
// Cache is up-to-date
|
||||||
kotlinCachedInjection.baseInjection
|
kotlinCachedInjection.baseInjection
|
||||||
else -> {
|
else -> {
|
||||||
fun computeAndCache(): BaseInjection {
|
fun computeAndCache(): BaseInjection {
|
||||||
val computedInjection = computeBaseInjection(ktHost, support) ?: ABSENT_KOTLIN_INJECTION
|
val computedInjection = computeBaseInjection(ktHost, support) ?: absentKotlinInjection
|
||||||
ktHost.cachedInjectionWithModification = KotlinCachedInjection(modificationCount, computedInjection)
|
ktHost.cachedInjectionWithModification = KotlinCachedInjection(modificationCount, computedInjection)
|
||||||
return computedInjection
|
return computedInjection
|
||||||
}
|
}
|
||||||
@@ -104,14 +104,14 @@ class KotlinLanguageInjector(
|
|||||||
// The action cannot be canceled by caller and by internal checkCanceled() calls.
|
// The action cannot be canceled by caller and by internal checkCanceled() calls.
|
||||||
// Force creating new indicator that is canceled on write action start, otherwise there might be lags in typing.
|
// Force creating new indicator that is canceled on write action start, otherwise there might be lags in typing.
|
||||||
runInReadActionWithWriteActionPriority(::computeAndCache) ?: kotlinCachedInjection?.baseInjection
|
runInReadActionWithWriteActionPriority(::computeAndCache) ?: kotlinCachedInjection?.baseInjection
|
||||||
?: ABSENT_KOTLIN_INJECTION
|
?: absentKotlinInjection
|
||||||
} else {
|
} else {
|
||||||
computeAndCache()
|
computeAndCache()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseInjection == ABSENT_KOTLIN_INJECTION) {
|
if (baseInjection == absentKotlinInjection) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user