Use runReadActionInSmartMode instead of runReadAction in ConfigureKotlinInProjectUtils
runReadActionInSmartMode has no effect if it is already run under runReadAction - therefore it could lead to IndexNotReadyException ^EA-220414 Fixed ^EA-210940 Fixed ^KT-30929 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
02be470e91
commit
4e3b1f141e
+3
-6
@@ -31,12 +31,9 @@ import org.jetbrains.kotlin.idea.core.util.getKotlinJvmRuntimeMarkerClass
|
||||
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
||||
import org.jetbrains.kotlin.idea.framework.effectiveKind
|
||||
import org.jetbrains.kotlin.idea.quickfix.KotlinAddRequiredModuleFix
|
||||
import org.jetbrains.kotlin.idea.util.*
|
||||
import org.jetbrains.kotlin.idea.util.application.isUnitTestMode
|
||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.idea.util.findFirstPsiJavaModule
|
||||
import org.jetbrains.kotlin.idea.util.isDev
|
||||
import org.jetbrains.kotlin.idea.util.isEap
|
||||
import org.jetbrains.kotlin.idea.util.isSnapshot
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.sdk
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.version
|
||||
@@ -267,7 +264,7 @@ fun findApplicableConfigurator(module: Module): KotlinProjectConfigurator {
|
||||
}
|
||||
|
||||
fun hasAnyKotlinRuntimeInScope(module: Module): Boolean {
|
||||
return runReadAction {
|
||||
return module.project.runReadActionInSmartMode {
|
||||
val scope = module.getModuleWithDependenciesAndLibrariesScope(hasKotlinFilesOnlyInTests(module))
|
||||
getKotlinJvmRuntimeMarkerClass(module.project, scope) != null ||
|
||||
hasKotlinJsKjsmFile(module.project, LibraryKindSearchScope(module, scope, JSLibraryKind)) ||
|
||||
@@ -283,7 +280,7 @@ fun hasKotlinJvmRuntimeInScope(module: Module): Boolean {
|
||||
}
|
||||
|
||||
fun hasKotlinJsRuntimeInScope(module: Module): Boolean {
|
||||
return runReadAction {
|
||||
return module.project.runReadActionInSmartMode {
|
||||
val scope = module.getModuleWithDependenciesAndLibrariesScope(hasKotlinFilesOnlyInTests(module))
|
||||
hasKotlinJsKjsmFile(module.project, LibraryKindSearchScope(module, scope, JSLibraryKind))
|
||||
}
|
||||
|
||||
@@ -167,9 +167,11 @@ class KotlinCopyPasteReferenceProcessor : CopyPastePostProcessor<BasicKotlinRefe
|
||||
elements.flatMap { it.collectDescendantsOfType<KtElement>() }
|
||||
}
|
||||
|
||||
val project = file.project
|
||||
|
||||
// TODO: allowResolveInDispatchThread could be dropped as soon as
|
||||
// ConvertJavaCopyPasteProcessor will perform it on non UI thread
|
||||
val bindingContext = runReadAction {
|
||||
val bindingContext = project.runReadActionInSmartMode {
|
||||
allowResolveInDispatchThread {
|
||||
file.getResolutionFacade().analyze(allElementsToResolve, BodyResolveMode.PARTIAL)
|
||||
}
|
||||
@@ -177,7 +179,7 @@ class KotlinCopyPasteReferenceProcessor : CopyPastePostProcessor<BasicKotlinRefe
|
||||
|
||||
val result = mutableListOf<KotlinReferenceData>()
|
||||
for (ktElement in allElementsToResolve) {
|
||||
runReadAction {
|
||||
project.runReadActionInSmartMode {
|
||||
indicator?.checkCanceled()
|
||||
result.addReferenceDataInsideElement(
|
||||
ktElement, file, ranges, bindingContext, fakePackageName = fakePackageName,
|
||||
@@ -211,7 +213,7 @@ class KotlinCopyPasteReferenceProcessor : CopyPastePostProcessor<BasicKotlinRefe
|
||||
sourcePackageName: String? = null,
|
||||
targetPackageName: String? = null
|
||||
) {
|
||||
val reference = runReadAction { ktElement.mainReference } ?: return
|
||||
val reference = file.project.runReadActionInSmartMode { ktElement.mainReference } ?: return
|
||||
|
||||
val descriptors = resolveReference(reference, bindingContext)
|
||||
//check whether this reference is unambiguous
|
||||
|
||||
Reference in New Issue
Block a user