private static Supplier<? extends OffsetsInFile> doInsertDummyIdentifier(CompletionInitializationContext initContext,
                                                                 OffsetsInFile topLevelOffsets,
                                                                 boolean noWriteLock, Consumer<? super Supplier<Disposable>> registerDisposable) {

    CompletionAssertions.checkEditorValid(initContext.getEditor());
    if (initContext.getDummyIdentifier().isEmpty()) {
      return () -> topLevelOffsets;
    }

    Editor editor = initContext.getEditor();
    Editor hostEditor = editor instanceof EditorWindow ? ((EditorWindow)editor).getDelegate() : editor;
    OffsetMap hostMap = topLevelOffsets.getOffsets();

    PsiFile hostCopy = obtainFileCopy(topLevelOffsets.getFile(), noWriteLock);
    Document copyDocument = Objects.requireNonNull(hostCopy.getViewProvider().getDocument());

    String dummyIdentifier = initContext.getDummyIdentifier();
    int startOffset = hostMap.getOffset(CompletionInitializationContext.START_OFFSET);
    int endOffset = hostMap.getOffset(CompletionInitializationContext.SELECTION_END_OFFSET);

    Supplier<OffsetsInFile> apply = topLevelOffsets.replaceInCopy(hostCopy, startOffset, endOffset, dummyIdentifier);


    // despite being non-physical, the copy file should only be modified in a write action,
    // because it's reused in multiple completions and it can also escapes uncontrollably into other threads (e.g. quick doc)

    //kskrygan: this check is non-relevant for CWM (quick doc and other features work separately)
    //and we are trying to avoid useless write locks during completion
    return skipWriteLockIfNeeded(noWriteLock, () -> {
      registerDisposable.accept((Supplier<Disposable>)() -> new OffsetTranslator(hostEditor.getDocument(), initContext.getFile(), copyDocument, startOffset, endOffset, dummyIdentifier));
      OffsetsInFile copyOffsets = apply.get();

      registerDisposable.accept((Supplier<Disposable>)() -> copyOffsets.getOffsets());

      return copyOffsets;
    });
  }
private static Supplier<? extends OffsetsInFile> doInsertDummyIdentifier(CompletionInitializationContext initContext,
                                                                 OffsetsInFile topLevelOffsets,
                                                                 boolean noWriteLock, Consumer<? super Supplier<Disposable>> registerDisposable)