private static @NotNull DocumentFragment createDocumentFragment(@NotNull FoldRegion fold) {
    EditorImpl editor = (EditorImpl)fold.getEditor();
    Document document = editor.getDocument();
    FoldingGroup group = fold.getGroup();
    int startOffset = fold.getStartOffset();
    int endOffset = fold.getEndOffset();
    if (group != null) {
      int groupEndOffset = editor.getFoldingModel().getEndOffset(group);
      if (editor.offsetToVisualLine(groupEndOffset) == editor.offsetToVisualLine(startOffset)) {
        endOffset = groupEndOffset;
      }
    }
    return new DocumentFragment(document, startOffset, endOffset);
  }
private static @NotNull DocumentFragment createDocumentFragment(@NotNull FoldRegion fold)