I have a plugin Action that launches an external tool which might make substantial changes on disk to both project structure (.idea directory) and Java/Scala sources. I'm looking for a reliable method to ensure the IDE is up to date after these changes and I'd like to avoid something as heavy-handed as force-reloading the entire project if possible.
My first attempt was based off the code from the IDE's own SynchronizeAction.java, involving calls to FileDocumentManager.saveAllDocuments then SaveAndSyncHandlerImpl.refreshOpenFiles and finally VirtualFileManager.refreshWithoutFileWatcher. This works most of the time, though some users have reported that it occassionally misses changes to project structure (.idea directory). In my own testing I haven't been able to replicate those misses, but I have seen it behave somewhat nondeterministically (sometimes it shows the "Project Files Changed" dialog and other times it doesn't).
I'd love to hear of other approaches. Thanks!