boolean finishCommit(@NotNull Document document,
                       @NotNull List<? extends BooleanRunnable> finishProcessors,
                       @NotNull List<? extends BooleanRunnable> reparseInjectedProcessors,
                       boolean synchronously,
                       @NotNull Object reason) {
    assert !myProject.isDisposed() : "Already disposed";
    if (isEventSystemEnabled(document)) {
      ThreadingAssertions.assertEventDispatchThread();
    }
    boolean[] ok = {true};
    if (synchronously) {
      ok[0] = finishCommitInWriteAction(document, finishProcessors, reparseInjectedProcessors, true);
    }
    else {
      ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(document, myProject) {
        @Override
        public void run() {
          ok[0] = finishCommitInWriteAction(document, finishProcessors, reparseInjectedProcessors, false);
        }
      });
    }

    if (ok[0]) {
      // run after commit actions outside write action
      runAfterCommitActions(document);
      if (DebugUtil.DO_EXPENSIVE_CHECKS && !ApplicationManagerEx.isInStressTest()) {
        checkAllElementsValid(document, reason);
      }
    }
    return ok[0];
  }
boolean finishCommit(@NotNull Document document,
                       @NotNull List<? extends BooleanRunnable> finishProcessors,
                       @NotNull List<? extends BooleanRunnable> reparseInjectedProcessors,
                       boolean synchronously,
                       @NotNull Object reason)