public static boolean isInsideEventProcessing() {
    Application application = ApplicationManager.getApplication();
    if (!application.isWriteAccessAllowed()) return false;

    MessageBus bus = application.getMessageBus();
    return bus.hasUndeliveredEvents(VirtualFileManager.VFS_CHANGES) ||
           bus.hasUndeliveredEvents(PsiModificationTracker.TOPIC) ||
           bus.hasUndeliveredEvents(ModuleRootListener.TOPIC) ||
           bus.hasUndeliveredEvents(AdditionalLibraryRootsListener.TOPIC);
  }
public static boolean isInsideEventProcessing()