@Override
    public void rootsChanged(@NotNull ModuleRootEvent event) {
      if (LOG.isTraceEnabled()) LOG.trace("rootsChanged call");
      PsiManagerImpl psiManager = (PsiManagerImpl)PsiManager.getInstance(myListenerProject);
      FileManagerImpl fileManager = (FileManagerImpl)psiManager.getFileManager();
      fileManager.dispatchPendingEvents();

      if (event.isCausedByFileTypesChange()) return;
      if (LOG.isTraceEnabled()) LOG.trace("Event is not caused by file types change");
      ApplicationManager.getApplication().runWriteAction(
        (ExternalChangeAction)() -> {
          depthCounter--;
          if (LOG.isTraceEnabled()) LOG.trace("depthCounter decreased " + depthCounter);
          assert depthCounter >= 0 : "unbalanced `beforeRootsChange`/`rootsChanged`: " + depthCounter;
          if (depthCounter > 0) return;

          DebugUtil.performPsiModification(null, fileManager::possiblyInvalidatePhysicalPsi);

          PsiTreeChangeEventImpl treeEvent = new PsiTreeChangeEventImpl(psiManager);
          treeEvent.setPropertyName(PsiTreeChangeEvent.PROP_ROOTS);
          psiManager.propertyChanged(treeEvent);
        }
      );
    }
@Override
    public void rootsChanged(@NotNull ModuleRootEvent event)