mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-218636 [psi] send children-change events on changing content of file without document
GitOrigin-RevId: 25c4213e205307f3d1c921f45a1603c18667ad9e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0af9877fec
commit
00ececf543
@@ -784,8 +784,8 @@ private class MyFileDocumentManagerListener(private val project: Project) : File
|
||||
private val fileManager = PsiManagerEx.getInstanceEx(project).fileManager as FileManagerEx
|
||||
|
||||
override fun fileWithNoDocumentChanged(file: VirtualFile) {
|
||||
val viewProvider = fileManager.findCachedViewProvider(file)
|
||||
if (viewProvider == null) {
|
||||
val viewProviders = fileManager.findCachedViewProviders(file)
|
||||
if (viewProviders.isEmpty()) {
|
||||
project.service<PsiVFSListener>().handleVfsChangeWithoutPsi(file)
|
||||
}
|
||||
else {
|
||||
@@ -794,7 +794,9 @@ private class MyFileDocumentManagerListener(private val project: Project) : File
|
||||
fileManager.forceReload(file)
|
||||
}
|
||||
else {
|
||||
fileManager.reloadPsiAfterTextChange(viewProvider, file)
|
||||
for (viewProvider in viewProviders) {
|
||||
fileManager.reloadPsiAfterTextChange(viewProvider, file)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+35
@@ -16,6 +16,7 @@ import com.intellij.psi.PsiTreeChangeAdapter
|
||||
import com.intellij.psi.PsiTreeChangeEvent
|
||||
import com.intellij.psi.PsiTreeChangeListener
|
||||
import com.intellij.psi.impl.PsiManagerEx
|
||||
import com.intellij.psi.impl.PsiTreeChangeEventImpl
|
||||
import com.intellij.testFramework.IndexingTestUtil
|
||||
import com.intellij.testFramework.common.timeoutRunBlocking
|
||||
import com.intellij.testFramework.junit5.TestApplication
|
||||
@@ -231,6 +232,40 @@ internal class MultiversePsiEventTest {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test we receive 2 before children changed events on updating content of a file with 2 psi files and WITHOT a document `() = doChangeTest(
|
||||
listenerFactory = { counter ->
|
||||
object : PsiTreeChangeAdapter() {
|
||||
override fun beforeChildrenChange(event: PsiTreeChangeEvent) {
|
||||
if (!(event as PsiTreeChangeEventImpl).isGenericChange) {
|
||||
counter.incrementAndGet()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
updateBlock = { file ->
|
||||
file.setBinaryContent("class Baz {}".toByteArray())
|
||||
},
|
||||
expectedEventNumber = 2
|
||||
)
|
||||
|
||||
@Test
|
||||
fun `test we receive 2 children changed events on updating content of a file with 2 psi files and WITHOT a document `() = doChangeTest(
|
||||
listenerFactory = { counter ->
|
||||
object : PsiTreeChangeAdapter() {
|
||||
override fun childrenChanged(event: PsiTreeChangeEvent) {
|
||||
if (!(event as PsiTreeChangeEventImpl).isGenericChange) {
|
||||
counter.incrementAndGet()
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
updateBlock = { file ->
|
||||
file.setBinaryContent("class Baz {}".toByteArray())
|
||||
},
|
||||
expectedEventNumber = 2
|
||||
)
|
||||
|
||||
private fun doChangeTest(
|
||||
listenerFactory: (AtomicInteger) -> PsiTreeChangeListener,
|
||||
updateBlock: (file: VirtualFile) -> Unit,
|
||||
|
||||
Reference in New Issue
Block a user