ModCommand (@NotNull ActionContext context, @NotNull Consumer<@NotNull ModPsiUpdater> updater) { var runnable = new Runnable() { private ModPsiUpdaterImpl myUpdater; @Override public void run() { myUpdater = new ModPsiUpdaterImpl(context); updater.accept(myUpdater); } void dispose() { if (myUpdater != null) { Disposer.dispose(myUpdater); } } }; try { PostprocessReformattingAspect.getInstance(context.project()).postponeFormattingInside(runnable); return runnable.myUpdater.getCommand(); } finally { runnable.dispose(); } }