void (@NotNull MultiMap<VirtualDirectoryImpl, VFileDeleteEvent> deletions) { for (Map.Entry<VirtualDirectoryImpl, Collection<VFileDeleteEvent>> entry : deletions.entrySet()) { VirtualDirectoryImpl parent = entry.getKey(); Collection<VFileDeleteEvent> deleteEvents = entry.getValue(); // no valid containing directory; applying events the old way - one by one if (parent == null || !parent.isValid()) { deleteEvents.forEach(this::applyEvent); return; } int parentId = getFileId(parent); List<CharSequence> childrenNamesDeleted = new ArrayList<>(deleteEvents.size()); IntSet childrenIdsDeleted = new IntOpenHashSet(deleteEvents.size()); List<ChildInfo> deleted = new ArrayList<>(deleteEvents.size()); for (VFileDeleteEvent event : deleteEvents) { VirtualFile file = event.getFile(); int id = getFileId(file); childrenNamesDeleted.add(file.getNameSequence()); childrenIdsDeleted.add(id); vfsPeer.deleteRecordRecursively(id); invalidateSubtree(file, "Bulk file deletions", event); deleted.add(new ChildInfoImpl(id, ChildInfoImpl.UNKNOWN_ID_YET, null, null, null)); } deleted.sort(ChildInfo.BY_ID); vfsPeer.update(parent, parentId, oldChildren -> oldChildren.subtract(deleted)); parent.removeChildren(childrenIdsDeleted, childrenNamesDeleted); } }