int (@NotNull List<? extends CompoundVFileEvent> events, int startIndex, @NotNull MostlySingularMultiMap<String, VFileEvent> filesInvolved, @NotNull Set<? super String> middleDirsInvolved, @NotNull Set<? super VirtualFile> deleted, @NotNull Map<VirtualDirectoryImpl, Object> toCreate, // dir -> VFileCreateEvent|Collection<VFileCreateEvent> in this dir @NotNull Set<? super VFileEvent> eventsToRemove) { // storing all paths from all events (including all parents), // checking each new event's path against this set, and if it's there, this event is conflicting int i; for (i = startIndex; i < events.size(); i++) { VFileEvent event = events.get(i).getFileEvent(); String path = event.getPath(); if (event instanceof VFileDeleteEvent && removeNestedDelete(((VFileDeleteEvent)event).getFile(), deleted)) { eventsToRemove.add(event); continue; } if (event instanceof VFileCreateEvent createEvent) { VirtualDirectoryImpl parent = (VirtualDirectoryImpl)createEvent.getParent(); Object createEvents = toCreate.get(parent); if (createEvents == null) { toCreate.put(parent, createEvent); } else { if (createEvents instanceof VFileCreateEvent prevEvent) { Set<VFileCreateEvent> children = parent.isCaseSensitive() ? new LinkedHashSet<>() : CollectionFactory.createLinkedCustomHashingStrategySet(CASE_INSENSITIVE_STRATEGY); children.add(prevEvent); toCreate.put(parent, children); createEvents = children; } //noinspection unchecked Collection<VFileCreateEvent> children = (Collection<VFileCreateEvent>)createEvents; if (!children.add(createEvent)) { eventsToRemove.add(createEvent); continue; } } } if (eventConflictsWithPrevious(event, path, filesInvolved, middleDirsInvolved)) { break; } // Some events are composite (e.g. `VFileMoveEvent` = `VFileDeleteEvent` + `VFileCreateEvent`), // so both paths should be checked for conflicts. String path2 = getAlternativePath(event); if (path2 != null && !(SystemInfoRt.isFileSystemCaseSensitive ? path2.equals(path) : path2.equalsIgnoreCase(path)) && eventConflictsWithPrevious(event, path2, filesInvolved, middleDirsInvolved)) { break; } } return i; }