diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/KotlinCodeBlockModificationListener.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/KotlinCodeBlockModificationListener.kt index ff02f0b822a..03570622655 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/KotlinCodeBlockModificationListener.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/KotlinCodeBlockModificationListener.kt @@ -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) diff --git a/idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt b/idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt new file mode 100644 index 00000000000..cc4664f431c --- /dev/null +++ b/idea/testData/codeInsight/outOfBlock/WholeFileChanged.kt @@ -0,0 +1,13 @@ +// TRUE +// SKIP_ANALYZE_CHECK + +fun test() { + + val someThing: Any? = null + val otherThing: Any? = null + + if (!(someThing?.equals(otherThing) ?: otherThing == null)) { + // Some comment + } + +// TYPE: } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java index 42cc24bf2c9..212cc470fa3 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/OutOfBlockModificationTestGenerated.java @@ -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); + } }