@Override public void fileDeleted(@NotNull final VirtualFileEvent event) { final VirtualFile vFile = event.getFile(); VirtualFile parent = event.getParent(); final PsiDirectory parentDir = getCachedDirectory(parent); final PsiFile psiFile = myFileManager.getCachedPsiFileInner(vFile); if (psiFile != null) { myFileManager.setViewProvider(vFile, null); if (parentDir != null) { ApplicationManager.getApplication() .runWriteAction( new ExternalChangeAction() { @Override public void run() { PsiTreeChangeEventImpl treeEvent = new PsiTreeChangeEventImpl(myManager); treeEvent.setParent(parentDir); treeEvent.setChild(psiFile); myManager.childRemoved(treeEvent); } }); } else if (parent != null) { handleVfsChangeWithoutPsi(parent); } } else { final PsiDirectory psiDir = myFileManager.getCachedDirectory(vFile); if (psiDir != null) { myFileManager.removeInvalidFilesAndDirs(false); if (parentDir != null) { ApplicationManager.getApplication() .runWriteAction( new ExternalChangeAction() { @Override public void run() { PsiTreeChangeEventImpl treeEvent = new PsiTreeChangeEventImpl(myManager); treeEvent.setParent(parentDir); treeEvent.setChild(psiDir); myManager.childRemoved(treeEvent); } }); } } else if (parent != null) { handleVfsChangeWithoutPsi(parent); } } }