From 71a04f8cfc84dc0a8f79782681ce0c4766601c9f Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Mon, 8 May 2017 00:19:25 +0200 Subject: [PATCH] Fix script-related tests that aren't ready for roots changed optimizations (cherry picked from commit ab52c55) --- .../idea/core/script/KotlinScriptConfigurationManager.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/KotlinScriptConfigurationManager.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/KotlinScriptConfigurationManager.kt index ca5741b8890..2e771963923 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/KotlinScriptConfigurationManager.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/script/KotlinScriptConfigurationManager.kt @@ -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) { 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()