Fixed problems with ModuleDescriptor mismatch after ProcessCanceledException
This commit is contained in:
+6
-2
@@ -27,6 +27,7 @@ import com.intellij.psi.util.CachedValueProvider
|
|||||||
import com.intellij.psi.util.CachedValuesManager
|
import com.intellij.psi.util.CachedValuesManager
|
||||||
import com.intellij.psi.util.PsiModificationTracker
|
import com.intellij.psi.util.PsiModificationTracker
|
||||||
import org.jetbrains.annotations.TestOnly
|
import org.jetbrains.annotations.TestOnly
|
||||||
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.idea.analysis.analyzeInContext
|
import org.jetbrains.kotlin.idea.analysis.analyzeInContext
|
||||||
import org.jetbrains.kotlin.idea.project.KotlinCodeBlockModificationListener
|
import org.jetbrains.kotlin.idea.project.KotlinCodeBlockModificationListener
|
||||||
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
import org.jetbrains.kotlin.idea.resolve.ResolutionFacade
|
||||||
@@ -59,7 +60,7 @@ class CompletionBindingContextProvider(project: Project) {
|
|||||||
fun getInstance(project: Project): CompletionBindingContextProvider
|
fun getInstance(project: Project): CompletionBindingContextProvider
|
||||||
= project.getComponent(CompletionBindingContextProvider::class.java)
|
= project.getComponent(CompletionBindingContextProvider::class.java)
|
||||||
|
|
||||||
var ENABLED = false
|
var ENABLED = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CompletionData(
|
private class CompletionData(
|
||||||
@@ -67,6 +68,7 @@ class CompletionBindingContextProvider(project: Project) {
|
|||||||
val prevStatement: KtExpression?,
|
val prevStatement: KtExpression?,
|
||||||
val psiElementsBeforeAndAfter: List<PsiElementData>,
|
val psiElementsBeforeAndAfter: List<PsiElementData>,
|
||||||
val bindingContext: BindingContext,
|
val bindingContext: BindingContext,
|
||||||
|
val moduleDescriptor: ModuleDescriptor,
|
||||||
val statementResolutionScope: LexicalScope,
|
val statementResolutionScope: LexicalScope,
|
||||||
val statementDataFlowInfo: DataFlowInfo,
|
val statementDataFlowInfo: DataFlowInfo,
|
||||||
val debugText: String
|
val debugText: String
|
||||||
@@ -116,6 +118,8 @@ class CompletionBindingContextProvider(project: Project) {
|
|||||||
log("Previous statement is not the same\n")
|
log("Previous statement is not the same\n")
|
||||||
psiElementsBeforeAndAfter != prevCompletionData.psiElementsBeforeAndAfter ->
|
psiElementsBeforeAndAfter != prevCompletionData.psiElementsBeforeAndAfter ->
|
||||||
log("PSI-tree has changed inside current scope\n")
|
log("PSI-tree has changed inside current scope\n")
|
||||||
|
prevCompletionData.moduleDescriptor != resolutionFacade.moduleDescriptor ->
|
||||||
|
log("ModuleDescriptor has been reset")
|
||||||
inStatement.isTooComplex() ->
|
inStatement.isTooComplex() ->
|
||||||
log("Current statement is too complex to use optimization\n")
|
log("Current statement is too complex to use optimization\n")
|
||||||
else -> {
|
else -> {
|
||||||
@@ -136,7 +140,7 @@ class CompletionBindingContextProvider(project: Project) {
|
|||||||
prevCompletionDataCache.value.data = if (block != null && modificationScope != null) {
|
prevCompletionDataCache.value.data = if (block != null && modificationScope != null) {
|
||||||
val resolutionScope = inStatement.getResolutionScope(bindingContext, resolutionFacade)
|
val resolutionScope = inStatement.getResolutionScope(bindingContext, resolutionFacade)
|
||||||
val dataFlowInfo = bindingContext.getDataFlowInfoBefore(inStatement)
|
val dataFlowInfo = bindingContext.getDataFlowInfoBefore(inStatement)
|
||||||
CompletionData(block, prevStatement, psiElementsBeforeAndAfter!!, bindingContext, resolutionScope, dataFlowInfo,
|
CompletionData(block, prevStatement, psiElementsBeforeAndAfter!!, bindingContext, resolutionFacade.moduleDescriptor, resolutionScope, dataFlowInfo,
|
||||||
debugText = position.text)
|
debugText = position.text)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user