Fix script-related tests that aren't ready for roots changed optimizations

(cherry picked from commit ab52c55)
This commit is contained in:
Ilya Chernikov
2017-05-08 00:19:25 +02:00
parent ca331d2f55
commit 71a04f8cfc
@@ -70,11 +70,17 @@ class KotlinScriptConfigurationManager(
project.messageBus.connect().subscribe(VirtualFileManager.VFS_CHANGES, object : BulkFileListener.Adapter() {
val projectFileIndex = ProjectRootManager.getInstance(project).fileIndex
val application = ApplicationManager.getApplication()
override fun after(events: List<VFileEvent>) {
if (updateExternalImportsCache(events.mapNotNull {
// The check is partly taken from the BuildManager.java
it.file?.takeIf { projectFileIndex.isInContent(it) && !ProjectUtil.isProjectOrWorkspaceFile(it) } }))
it.file?.takeIf {
// the isUnitTestMode check fixes ScriptConfigurationHighlighting & Navigation tests, since they are not trigger proper update mechanims
// TODO: find out the reason, then consider to fix tests and remove this check
(application.isUnitTestMode || projectFileIndex.isInContent(it)) && !ProjectUtil.isProjectOrWorkspaceFile(it)
}
}))
{
invalidateLocalCaches()
notifyRootsChanged()