From 89d5c030dc7bbc92b2942936f0f7c0cc94bf9194 Mon Sep 17 00:00:00 2001 From: Igor Yakovlev Date: Wed, 1 Jul 2020 01:01:06 +0300 Subject: [PATCH] Improve incremental analisys for nested blocks --- .../trackers/KotlinCodeBlockModificationListenerCompat.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/caches/trackers/KotlinCodeBlockModificationListenerCompat.kt b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/caches/trackers/KotlinCodeBlockModificationListenerCompat.kt index aacd0e69d70..9c6521beb74 100644 --- a/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/caches/trackers/KotlinCodeBlockModificationListenerCompat.kt +++ b/idea/idea-frontend-independent/src/org/jetbrains/kotlin/idea/caches/trackers/KotlinCodeBlockModificationListenerCompat.kt @@ -340,7 +340,11 @@ val KtFile.inBlockModifications: Collection private fun KtFile.addInBlockModifiedItem(element: KtElement) { val collection = putUserDataIfAbsent(IN_BLOCK_MODIFICATIONS, mutableSetOf()) synchronized(collection) { - collection.add(element) + val needToAddBlock = collection.none { it.isAncestor(element, strict = false) } + if (needToAddBlock) { + collection.removeIf { element.isAncestor(it, strict = false) } + collection.add(element) + } } val count = getUserData(FILE_IN_BLOCK_MODIFICATION_COUNT) ?: 0 putUserData(FILE_IN_BLOCK_MODIFICATION_COUNT, count + 1)