List<VFileEvent> (@NotNull Runnable action) { List<VFileEvent> allEvents = Collections.synchronizedList(new ArrayList<>()); MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(); connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() { @Override public void after(@NotNull List<? extends @NotNull VFileEvent> events) { allEvents.addAll(events); } }); try { action.run(); } finally { connection.disconnect(); } return allEvents; }