J2K: do not run runUndoTransparentAction outside EDT

#KT-39739 fixed
This commit is contained in:
Ilya Kirillov
2020-07-16 21:05:24 +03:00
parent d16f246375
commit dccac34282
2 changed files with 15 additions and 14 deletions
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.idea.util
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.command.CommandProcessor
enum class ActionRunningMode {
RUN_IN_CURRENT_THREAD,
@@ -19,7 +20,9 @@ inline fun <T> ActionRunningMode.runAction(crossinline action: () -> T): T = whe
ActionRunningMode.RUN_IN_EDT -> {
var result: T? = null
ApplicationManager.getApplication().invokeAndWait {
result = ApplicationManager.getApplication().runWriteAction<T> { action() }
CommandProcessor.getInstance().runUndoTransparentAction {
result = ApplicationManager.getApplication().runWriteAction<T> { action() }
}
}
result!!
}
@@ -28,20 +28,18 @@ class ShortenReferenceProcessing : FileBasedPostProcessing() {
}
override fun runProcessing(file: KtFile, allFiles: List<KtFile>, rangeMarker: RangeMarker?, converterContext: NewJ2kConverterContext) {
CommandProcessor.getInstance().runUndoTransparentAction {
if (rangeMarker != null) {
if (rangeMarker.isValid) {
ShortenReferences.DEFAULT.process(
file,
rangeMarker.startOffset,
rangeMarker.endOffset,
filter,
actionRunningMode = ActionRunningMode.RUN_IN_EDT
)
}
} else {
ShortenReferences.DEFAULT.process(file, filter, actionRunningMode = ActionRunningMode.RUN_IN_EDT)
if (rangeMarker != null) {
if (rangeMarker.isValid) {
ShortenReferences.DEFAULT.process(
file,
rangeMarker.startOffset,
rangeMarker.endOffset,
filter,
actionRunningMode = ActionRunningMode.RUN_IN_EDT
)
}
} else {
ShortenReferences.DEFAULT.process(file, filter, actionRunningMode = ActionRunningMode.RUN_IN_EDT)
}
}
}