CodeBlockModification...: count file as changed when no changed elements
It means that root PSI (KtFile itself) is changed So #KT-19726 Fixed So #KT-20157 Fixed
This commit is contained in:
+1
-3
@@ -30,7 +30,6 @@ import com.intellij.pom.event.PomModelEvent
|
|||||||
import com.intellij.pom.event.PomModelListener
|
import com.intellij.pom.event.PomModelListener
|
||||||
import com.intellij.pom.tree.TreeAspect
|
import com.intellij.pom.tree.TreeAspect
|
||||||
import com.intellij.pom.tree.events.TreeChangeEvent
|
import com.intellij.pom.tree.events.TreeChangeEvent
|
||||||
import com.intellij.psi.PsiCodeFragment
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.impl.PsiModificationTrackerImpl
|
import com.intellij.psi.impl.PsiModificationTrackerImpl
|
||||||
import com.intellij.psi.util.CachedValueProvider
|
import com.intellij.psi.util.CachedValueProvider
|
||||||
@@ -84,8 +83,7 @@ class KotlinCodeBlockModificationListener(
|
|||||||
val changedElements = changeSet.changedElements
|
val changedElements = changeSet.changedElements
|
||||||
// When a code fragment is reparsed, IntelliJ doesn't do an AST diff and considers the entire
|
// When a code fragment is reparsed, IntelliJ doesn't do an AST diff and considers the entire
|
||||||
// contents to be replaced, which is represented in a POM event as an empty list of changed elements
|
// contents to be replaced, which is represented in a POM event as an empty list of changed elements
|
||||||
if (changedElements.any { getInsideCodeBlockModificationScope(it.psi) == null } ||
|
if (changedElements.any { getInsideCodeBlockModificationScope(it.psi) == null } || changedElements.isEmpty()) {
|
||||||
(file is PsiCodeFragment && changedElements.isEmpty())) {
|
|
||||||
messageBusConnection.deliverImmediately()
|
messageBusConnection.deliverImmediately()
|
||||||
if (file.isPhysical && !isReplLine(file.virtualFile)) {
|
if (file.isPhysical && !isReplLine(file.virtualFile)) {
|
||||||
lastAffectedModule = ModuleUtil.findModuleForPsiElement(file)
|
lastAffectedModule = ModuleUtil.findModuleForPsiElement(file)
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// TRUE
|
||||||
|
// SKIP_ANALYZE_CHECK
|
||||||
|
|
||||||
|
fun test() {<caret>
|
||||||
|
|
||||||
|
val someThing: Any? = null
|
||||||
|
val otherThing: Any? = null
|
||||||
|
|
||||||
|
if (!(someThing?.equals(otherThing) ?: otherThing == null)) {
|
||||||
|
// Some comment
|
||||||
|
}
|
||||||
|
|
||||||
|
// TYPE: }
|
||||||
+6
@@ -269,4 +269,10 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/StringInSuperConstroctorCall.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/StringInSuperConstroctorCall.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WholeFileChanged.kt")
|
||||||
|
public void testWholeFileChanged() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user