void () { Application app = ApplicationManager.getApplication(); Disposer.register(app, AsyncEventSupport::ensureAllEventsProcessed); app.getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() { @Override public void before(@NotNull List<? extends @NotNull VFileEvent> events) { if (ourAsyncProcessedEvents.contains(events)) { return; } List<AsyncFileListener.ChangeApplier> appliers = runAsyncListeners(events); ourAppliers.put(events, appliers); beforeVfsChange(appliers); } @Override public void after(@NotNull List<? extends @NotNull VFileEvent> events) { if (ourAsyncProcessedEvents.contains(events)) { return; } List<AsyncFileListener.ChangeApplier> appliers = ourAppliers.remove(events); afterVfsChange(appliers); } }); }