private void doComplete(CompletionInitializationContextImpl initContext, boolean hasModifiers, boolean isValidContext, long startingTime) {
    Editor editor = initContext.getEditor();
    CompletionAssertions.checkEditorValid(editor);

    LookupImpl lookup = obtainLookup(editor, initContext.getProject());

    CompletionPhase phase = CompletionServiceImpl.getCompletionPhase();
    if (phase instanceof CompletionPhase.CommittingDocuments p) {
      if (phase.indicator != null) {
        phase.indicator.closeAndFinish(false);
      }
      p.replaced = true;
    }
    else {
      CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass());
    }

    CompletionProgressIndicator indicator = new CompletionProgressIndicator(editor, initContext.getCaret(),
                                                                            initContext.getInvocationCount(), this,
                                                                            initContext.getOffsetMap(),
                                                                            initContext.getHostOffsets(),
                                                                            hasModifiers, lookup);


    if (synchronous && isValidContext) {
      OffsetsInFile hostCopyOffsets = withTimeout(calcSyncTimeOut(startingTime), () -> {
        PsiDocumentManager.getInstance(initContext.getProject()).commitAllDocuments();
        return CompletionInitializationUtil.insertDummyIdentifier(initContext, indicator).get();
      });
      if (hostCopyOffsets != null) {
        trySynchronousCompletion(initContext, hasModifiers, startingTime, indicator, hostCopyOffsets);
        return;
      }
    }
    scheduleContributorsAfterAsyncCommit(initContext, indicator, hasModifiers);
  }
private void doComplete(CompletionInitializationContextImpl initContext, boolean hasModifiers, boolean isValidContext, long startingTime)