private static Pair<TextRange[], TextRange> getRanges(int[] starts, int[] ends) {
    if (starts.length == 0) {
      return Pair.create(TextRange.EMPTY_ARRAY, TextRange.EMPTY_RANGE);
    }
    final TextRange[] ranges = new TextRange[starts.length];
    int startOffset = Integer.MAX_VALUE;
    int endOffset = Integer.MIN_VALUE;
    for (int i = 0; i < starts.length; ++i) {
      int start = starts[i];
      int end = ends[i];
      ranges[i] = new TextRange(start, end);
      startOffset = Math.min(startOffset, start);
      endOffset = Math.max(endOffset, end);
    }
    return Pair.create(ranges, new TextRange(startOffset, endOffset));
  }
private static Pair<TextRange[], TextRange> getRanges(int[] starts, int[] ends)