Indexing issue


In my plug-in I'm copying numerous models, rebuilding them and performing some operations on them in a loop. It's a huge plug-in and the whole process takes over an hour. But during this process at some point MPS points out that "Generation is not available until indices are built", probably when plug-in is trying to rebuild some model. How to wait for the indices to get build before performing any operation or rebuilding the newly copied model?

Or if some one can explain how does indices building works in MPS?

1 comment

Hi Hassan,

In Idea based IDEs (and so in MPS) such state is called Dumb mode. This mode is active while indices are build and so functionality is limited.

If you triggering build from your code, then you can do this things:

  • Before building, check current state using com.intellij.openapi.project.DumbService#isDumb() method.
  • Wrap run of your code with one of methods:
    com.intellij.openapi.project.DumbService#runWhenSmart -  for run as soon as possible (but need to check that you have not entered another dumb mode)
    com.intellij.openapi.project.DumbService#repeatUntilPassesInSmartMode - to pause your thread and wait until it can be runned (checks and reschedule if new dumb mode was started)
    - schedule runnable for later on EventDispatchThread when there is no dumb mode.
  • Use com.intellij.openapi.project.DumbService.DumbModeListener to get events on enter/exit dumb mode.

Please sign in to leave a comment.