Runnable (final @NotNull Runnable runnable, @NotNull ModalityState modalityState) { return new Runnable() { @Override public void run() { if (isWriteSafeModality(modalityState)) { ApplicationManager.getApplication().assertWriteIntentLockAcquired(); runWithWritingAllowed(runnable); } else { runnable.run(); } } @Override public String toString() { return runnable.toString(); } }; }