Explicitly disconnect in KotlinPackageContentModificationListener (KT-33802)

This commit is contained in:
Nikolay Krasko
2019-11-27 00:56:39 +03:00
parent 0cde2e2f5b
commit 7245bbd822
@@ -47,10 +47,10 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ConcurrentMap
class KotlinPackageContentModificationListener(private val project: Project) {
init {
val connection = project.messageBus.connect()
class KotlinPackageContentModificationListener(private val project: Project): Disposable {
val connection = project.messageBus.connect()
init {
connection.subscribe(VirtualFileManager.VFS_CHANGES, object : BulkFileListener {
override fun before(events: MutableList<out VFileEvent>) = onEvents(events)
override fun after(events: List<VFileEvent>) = onEvents(events)
@@ -82,6 +82,10 @@ class KotlinPackageContentModificationListener(private val project: Project) {
}
})
}
override fun dispose() {
connection.disconnect()
}
}
class KotlinPackageStatementPsiTreeChangePreprocessor(private val project: Project) : PsiTreeChangePreprocessor {