Avoid collecting events from other projects in PerModulePackageCacheService (KT-33802)

It looks like VFS_CHANGES subscription ignores project boundaries so all events are processed by every listener. If event has a hard reference to project in the requestor field, it might leak through the collection of pending events.

An attempt to fix holding test projects through pending events.

 #KT-33802 Fixed
This commit is contained in:
Nikolay Krasko
2019-11-27 00:58:47 +03:00
parent 7245bbd822
commit c341a3e709
@@ -71,6 +71,13 @@ class KotlinPackageContentModificationListener(private val project: Project): Di
val vFile = it.file!!
vFile.isDirectory || FileTypeRegistry.getInstance().getFileTypeByFileName(vFile.nameSequence) == KotlinFileType.INSTANCE
}
.filter {
when (val origin = it.requestor) {
is Project -> origin == project
is PsiManager -> origin.project == project
else -> true
}
}
.forEach { event -> service.notifyPackageChange(event) }
}
}