Ability to disable caches reset on ProcessCanceledException via internal action
This commit is contained in:
@@ -16,10 +16,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.storage
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.openapi.util.ModificationTracker
|
||||
import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
import org.jetbrains.kotlin.utils.isProcessCanceledException
|
||||
import org.jetbrains.kotlin.utils.rethrow
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
open class ExceptionTracker : ModificationTracker, LockBasedStorageManager.ExceptionHandlingStrategy {
|
||||
private val cancelledTracker: AtomicLong = AtomicLong()
|
||||
@@ -27,7 +29,9 @@ open class ExceptionTracker : ModificationTracker, LockBasedStorageManager.Excep
|
||||
override fun handleException(throwable: Throwable): RuntimeException {
|
||||
// should not increment counter when ReenteringLazyValueComputationException is thrown since it implements correct frontend behaviour
|
||||
if (throwable !is ReenteringLazyValueComputationException) {
|
||||
incCounter()
|
||||
if (!throwable.isProcessCanceledException() || CacheResetOnProcessCanceled.enabled) {
|
||||
incCounter()
|
||||
}
|
||||
}
|
||||
throw rethrow(throwable)
|
||||
}
|
||||
@@ -44,3 +48,14 @@ open class ExceptionTracker : ModificationTracker, LockBasedStorageManager.Excep
|
||||
return this::class.java.name + ": " + modificationCount
|
||||
}
|
||||
}
|
||||
|
||||
object CacheResetOnProcessCanceled {
|
||||
private val PROPERTY = "kotlin.internal.cacheResetOnProcessCanceled"
|
||||
private val DEFAULT_VALUE = true
|
||||
|
||||
var enabled: Boolean
|
||||
get() = PropertiesComponent.getInstance()!!.getBoolean(PROPERTY, DEFAULT_VALUE)
|
||||
set(value) {
|
||||
PropertiesComponent.getInstance()!!.setValue(PROPERTY, value, DEFAULT_VALUE)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,9 +150,9 @@
|
||||
class="org.jetbrains.kotlin.idea.actions.internal.benchmark.HighlightingBenchmarkAction"
|
||||
text="Benchmark highlighting"/>
|
||||
|
||||
<action id="CompletionBindingContextCachingToggleAction"
|
||||
class="org.jetbrains.kotlin.idea.actions.internal.CompletionBindingContextCachingToggleAction"
|
||||
text="Enable completion binding context caching"/>
|
||||
<action id="CacheResetOnProcessCanceledToggleAction"
|
||||
class="org.jetbrains.kotlin.idea.actions.internal.CacheResetOnProcessCanceledToggleAction"
|
||||
text="Reset caches on ProcessCanceledException"/>
|
||||
|
||||
<action id="CheckComponentsUsageSearchAction" class="org.jetbrains.kotlin.idea.actions.internal.CheckComponentsUsageSearchAction"
|
||||
text="Check Component Functions Usage Search"/>
|
||||
|
||||
+7
-7
@@ -18,18 +18,18 @@ package org.jetbrains.kotlin.idea.actions.internal
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.ToggleAction
|
||||
import org.jetbrains.kotlin.idea.completion.CompletionBindingContextProvider
|
||||
import org.jetbrains.kotlin.storage.CacheResetOnProcessCanceled
|
||||
|
||||
class CompletionBindingContextCachingToggleAction : ToggleAction() {
|
||||
override fun isSelected(e: AnActionEvent?): Boolean =
|
||||
CompletionBindingContextProvider.ENABLED
|
||||
class CacheResetOnProcessCanceledToggleAction : ToggleAction() {
|
||||
override fun isSelected(e: AnActionEvent): Boolean =
|
||||
CacheResetOnProcessCanceled.enabled
|
||||
|
||||
|
||||
override fun setSelected(e: AnActionEvent?, state: Boolean) {
|
||||
CompletionBindingContextProvider.ENABLED = state
|
||||
override fun setSelected(e: AnActionEvent, state: Boolean) {
|
||||
CacheResetOnProcessCanceled.enabled = state
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
super.update(e)
|
||||
e.presentation.isEnabledAndVisible = KotlinInternalMode.enabled
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user