Use ModalityState.NON_MODAL for invokeLater() actions (EA-91730 - assert: PsiModificationTrackerImpl.fireEvent)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.codeInliner
|
||||
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
@@ -24,6 +25,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import com.intellij.ui.GuiUtils
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import org.jetbrains.kotlin.idea.core.targetDescriptors
|
||||
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||
@@ -68,7 +70,7 @@ private fun UsageReplacementStrategy.replaceUsages(
|
||||
commandName: String,
|
||||
postAction: () -> Unit
|
||||
) {
|
||||
UIUtil.invokeLaterIfNeeded {
|
||||
GuiUtils.invokeLaterIfNeeded({
|
||||
project.executeWriteCommand(commandName) {
|
||||
// we should delete imports later to not affect other usages
|
||||
val importsToDelete = arrayListOf<KtImportDirective>()
|
||||
@@ -97,5 +99,5 @@ private fun UsageReplacementStrategy.replaceUsages(
|
||||
|
||||
postAction()
|
||||
}
|
||||
}
|
||||
}, ModalityState.NON_MODAL)
|
||||
}
|
||||
|
||||
+4
-3
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.inspections
|
||||
import com.intellij.codeInsight.FileModificationService
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction
|
||||
import com.intellij.codeInspection.*
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
@@ -28,7 +29,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElementVisitor
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.searches.ReferencesSearch
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import com.intellij.ui.GuiUtils
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
@@ -203,7 +204,7 @@ class ConflictingExtensionPropertyInspection : AbstractKotlinInspection(), Clean
|
||||
.mapNotNull { ref -> ref.expression.getStrictParentOfType<KtImportDirective>() }
|
||||
.filter { import -> !import.isAllUnder && import.targetDescriptors().size == 1 }
|
||||
}
|
||||
UIUtil.invokeLaterIfNeeded {
|
||||
GuiUtils.invokeLaterIfNeeded({
|
||||
project.executeWriteCommand(text) {
|
||||
importsToDelete.forEach { import ->
|
||||
if (!FileModificationService.getInstance().preparePsiElementForWrite(import)) return@forEach
|
||||
@@ -216,7 +217,7 @@ class ConflictingExtensionPropertyInspection : AbstractKotlinInspection(), Clean
|
||||
}
|
||||
declaration.delete()
|
||||
}
|
||||
}
|
||||
}, ModalityState.NON_MODAL)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user