void (@NotNull ModuleRootEvent event) { if (LOG.isTraceEnabled()) LOG.trace("beforeRootsChanged call"); 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 increased " + depthCounter); if (depthCounter > 1) return; PsiManagerImpl psiManager = (PsiManagerImpl)PsiManager.getInstance(myListenerProject); PsiTreeChangeEventImpl treeEvent = new PsiTreeChangeEventImpl(psiManager); treeEvent.setPropertyName(PsiTreeChangeEvent.PROP_ROOTS); psiManager.beforePropertyChange(treeEvent); } ); }