private static @NotNull List<ResultItem> merge(@Nullable List<ResultItem> resultItems, @NotNull Result newResult, int entireLength, @NotNull Filter filter) {
    List<ResultItem> newItems = newResult.getResultItems();
    if (resultItems == null) {
      resultItems = new ArrayList<>(newItems.size());
    }
    //noinspection ForLoopReplaceableByForEach
    for (int i = 0; i < newItems.size(); i++) {
      ResultItem item = newItems.get(i);
      if ((item.getHyperlinkInfo() == null || !intersects(resultItems, item)) && checkOffsetsCorrect(item, entireLength, filter)) {
        resultItems.add(item);
      }
    }
    return resultItems;
  }
private static @NotNull List<ResultItem> merge(@Nullable List<ResultItem> resultItems, @NotNull Result newResult, int entireLength, @NotNull Filter filter)