to avoid deadlock, don't refresh VFS during service initialization, instead refresh asynchronously during plugin initialization

This commit is contained in:
Dmitry Jemerov
2015-09-22 14:35:49 +02:00
parent 51ee1b3e5a
commit c5309d7955
2 changed files with 17 additions and 6 deletions
@@ -94,12 +94,7 @@ public class BuiltInsReferenceResolver(val project: Project, val startupManager:
val vf = VirtualFileManager.getInstance().findFileByUrl(fromUrl)
assert(vf != null) { "Virtual file not found by URL: $url" }
// Refreshing VFS: in case the plugin jar was updated, the caches may hold the old value
vf!!.getChildren()
vf.refresh(false, true)
PathUtil.getLocalFile(vf).refresh(false, true)
val psiDirectory = PsiManager.getInstance(project).findDirectory(vf)
val psiDirectory = PsiManager.getInstance(project).findDirectory(vf!!)
assert(psiDirectory != null) { "No PsiDirectory for $vf" }
return psiDirectory!!.getFiles().filterIsInstance<JetFile>().toHashSet()
}
@@ -188,5 +183,18 @@ public class BuiltInsReferenceResolver(val project: Project, val startupManager:
}
return setOf(defaultBuiltIns)
}
public fun refreshBuiltIns() {
getBuiltInsDirUrls().forEach { url ->
val fromUrl = VfsUtilCore.convertFromUrl(url)
val vf = VirtualFileManager.getInstance().findFileByUrl(fromUrl)
assert(vf != null) { "Virtual file not found by URL: $url" }
// Refreshing VFS: in case the plugin jar was updated, the caches may hold the old value
vf!!.getChildren()
vf.refresh(true, true)
PathUtil.getLocalFile(vf).refresh(true, true)
}
}
}
}