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:
Mikhail Glukhikh
2017-09-12 16:04:30 +03:00
parent dd1ac5bb6b
commit dafb52a44a
3 changed files with 20 additions and 3 deletions
@@ -30,7 +30,6 @@ import com.intellij.pom.event.PomModelEvent
import com.intellij.pom.event.PomModelListener
import com.intellij.pom.tree.TreeAspect
import com.intellij.pom.tree.events.TreeChangeEvent
import com.intellij.psi.PsiCodeFragment
import com.intellij.psi.PsiElement
import com.intellij.psi.impl.PsiModificationTrackerImpl
import com.intellij.psi.util.CachedValueProvider
@@ -84,8 +83,7 @@ class KotlinCodeBlockModificationListener(
val changedElements = changeSet.changedElements
// 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
if (changedElements.any { getInsideCodeBlockModificationScope(it.psi) == null } ||
(file is PsiCodeFragment && changedElements.isEmpty())) {
if (changedElements.any { getInsideCodeBlockModificationScope(it.psi) == null } || changedElements.isEmpty()) {
messageBusConnection.deliverImmediately()
if (file.isPhysical && !isReplLine(file.virtualFile)) {
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: }
@@ -269,4 +269,10 @@ public class OutOfBlockModificationTestGenerated extends AbstractOutOfBlockModif
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/StringInSuperConstroctorCall.kt");
doTest(fileName);
}
@TestMetadata("WholeFileChanged.kt")
public void testWholeFileChanged() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt");
doTest(fileName);
}
}