static @Nullable Segment getUpdatedRange(@NotNull PsiFile containingFile,
                                           @NotNull Segment segment,
                                           boolean isSegmentGreedy,
                                           @NotNull FrozenDocument frozen,
                                           @NotNull List<? extends DocumentEvent> events) {
    SelfElementInfo info = new SelfElementInfo(ProperTextRange.create(segment), new Identikit() {
      @Override
      public @Nullable PsiElement findPsiElement(@NotNull PsiFile file, int startOffset, int endOffset) {
        return null;
      }

      @Override
      public @NotNull Language getFileLanguage() {
        throw new IllegalStateException();
      }

      @Override
      public boolean isForPsiFile() {
        return false;
      }
    }, containingFile, isSegmentGreedy);
    List<SelfElementInfo> infos = Collections.singletonList(info);

    boolean greedy = info.isGreedy();
    int start = info.getPsiStartOffset();
    int end = info.getPsiEndOffset();
    boolean surviveOnExternalChange = events.stream().anyMatch(event-> isWholeDocumentReplace(frozen, (DocumentEventImpl)event));
    ManualRangeMarker marker = new ManualRangeMarker(start, end, greedy, greedy, surviveOnExternalChange, null);

    UpdatedRanges ranges = new UpdatedRanges(0, frozen, infos, new ManualRangeMarker[]{marker});
    // NB: convert events from completion to whole doc change event to more precise translation
    List<DocumentEvent> newEvents =
      ContainerUtil.map(events, event -> isWholeDocumentReplace(frozen, (DocumentEventImpl)event)
                                         ? new DocumentEventImpl(event.getDocument(), event.getOffset(), event.getOldFragment(),
                                                                 event.getNewFragment(), event.getOldTimeStamp(), true,
                                                                 ((DocumentEventImpl)event).getInitialStartOffset(),
                                                                 ((DocumentEventImpl)event).getInitialOldLength(),
                                                                 event.getMoveOffset()) : event);
    UpdatedRanges updated = applyEvents(newEvents, ranges);
    return updated.myMarkers[0];
  }
static @Nullable Segment getUpdatedRange(@NotNull PsiFile containingFile,
                                           @NotNull Segment segment,
                                           boolean isSegmentGreedy,
                                           @NotNull FrozenDocument frozen,
                                           @NotNull List<? extends DocumentEvent> events)