My Clojure plugin has an integration with Leiningen, which is a Maven-like build tool for Clojure. One thing that I can't get to work correctly is importing new modules from the project structure dialog. Leiningen is famously slow to start up, and its build file is not declarative so I have to invoke it to get the project details for a new module. This can take 5-10 seconds, so I don't want to block the UI while that is happening. I invoke lein in a background task which works fine for all use cases except this one - ProjectImportBuilder.commit() requires me to return a list of the created modules.
I've tried various approaches here, either creating temporary modules which will later be updated by the asynchronous project sync, or returning an empty list and just allowing the modules to be created later, but I can't get the project structure UI to update with the later changes that happen when the project is finally synchronised. Even if I create everything using the passed modifiable models (via an IdeModifiableModelsProvider), the UI doesn't update. I've also tried obtaining the ModulesConfigurator via the ProjectStructureConfigurable when it exists and the UI is active, but I can't seem to get it to refresh the UI.
Is there any way to achieve this?