ChangeApplier (@NotNull List<? extends @NotNull VFileEvent> events) { List<VFileContentChangeEvent> contentChangedEvents = new ArrayList<>(); List<VFileEvent> beforeEvents = new ArrayList<>(); List<VFileEvent> afterEvents = new ArrayList<>(); for (VFileEvent event : events) { ProgressManager.checkCanceled(); if (event instanceof VFileContentChangeEvent contentChangeEvent) { if (processBeforeContentsChange()) { VirtualFile file = contentChangeEvent.getFile(); if (isUnderMyVcs(file)) { contentChangedEvents.add(contentChangeEvent); } } } else if (isEventAccepted(event)) { if (isBeforeEvent(event)) { beforeEvents.add(event); } if (isAfterEvent(event)) { afterEvents.add(event); } } } if (contentChangedEvents.isEmpty() && beforeEvents.isEmpty() && afterEvents.isEmpty()) { return null; } return new ChangeApplier() { @Override public void beforeVfsChange() { beforeContentsChange(contentChangedEvents); myProcessor.processBeforeEvents(beforeEvents); } @Override public void afterVfsChange() { myEventsToProcess.addAll(afterEvents); } }; }