void (@NotNull Document document, final boolean executeInBulk, @NotNull Runnable task) { if (executeInBulk == document.isInBulkUpdate()) { task.run(); return; } //noinspection deprecation document.setInBulkUpdate(executeInBulk); try { task.run(); } finally { //noinspection deprecation document.setInBulkUpdate(!executeInBulk); } }