Temporary allow resolve in write action for insert handler

This commit is contained in:
Nikolay Krasko
2019-05-21 22:26:03 +03:00
parent 78569c62c0
commit e38ad3a513
@@ -22,6 +22,7 @@ import com.intellij.psi.PsiClass
import com.intellij.psi.PsiDocumentManager
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.allowResolveInWriteAction
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.completion.isAfterDot
import org.jetbrains.kotlin.idea.completion.isArtificialImportAliasedDescriptor
@@ -60,7 +61,7 @@ object KotlinClassifierInsertHandler : BaseDeclarationInsertHandler() {
val token = file.findElementAt(startOffset)!!
val nameRef = token.parent as? KtNameReferenceExpression
if (nameRef != null) {
val bindingContext = nameRef.analyze(BodyResolveMode.PARTIAL)
val bindingContext = allowResolveInWriteAction { nameRef.analyze(BodyResolveMode.PARTIAL) }
val target = bindingContext[BindingContext.SHORT_REFERENCE_TO_COMPANION_OBJECT, nameRef]
?: bindingContext[BindingContext.REFERENCE_TARGET, nameRef] as? ClassDescriptor
if (target != null && IdeDescriptorRenderers.SOURCE_CODE.renderClassifierName(target) == qualifiedName) return