diff --git a/compiler/frontend/src/org/jetbrains/kotlin/storage/ExceptionTracker.kt b/compiler/frontend/src/org/jetbrains/kotlin/storage/ExceptionTracker.kt
index 2ba12b00be4..8d557d166b6 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/storage/ExceptionTracker.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/storage/ExceptionTracker.kt
@@ -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)
+ }
+}
diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index e1b70fa0e58..16d03e85b13 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -150,9 +150,9 @@
class="org.jetbrains.kotlin.idea.actions.internal.benchmark.HighlightingBenchmarkAction"
text="Benchmark highlighting"/>
-
+
diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/internal/CompletionBindingContextCachingToggleAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/internal/CacheResetOnProcessCanceledToggleAction.kt
similarity index 70%
rename from idea/src/org/jetbrains/kotlin/idea/actions/internal/CompletionBindingContextCachingToggleAction.kt
rename to idea/src/org/jetbrains/kotlin/idea/actions/internal/CacheResetOnProcessCanceledToggleAction.kt
index 7d3321e9326..ff4c1a86eee 100644
--- a/idea/src/org/jetbrains/kotlin/idea/actions/internal/CompletionBindingContextCachingToggleAction.kt
+++ b/idea/src/org/jetbrains/kotlin/idea/actions/internal/CacheResetOnProcessCanceledToggleAction.kt
@@ -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
}
}