private static Iterator<TextRange> gapIterator(final Iterator<TextRange> base) {
    return new Iterator<TextRange>() {
      private final Iterator<TextRange> myIt = base;
      private TextRange myPrev = myIt.hasNext() ? myIt.next() : null;

      @Override
      public boolean hasNext() {
        return myPrev != null && myIt.hasNext();
      }

      @Override
      public TextRange next() {
        TextRange cur = myIt.next();
        TextRange res = TextRange.create(myPrev.getEndOffset(), cur.getStartOffset());
        myPrev = cur;
        return res;
      }

      @Override
      public void remove() {
        throw new UnsupportedOperationException();
      }
    };
  }
private static Iterator<TextRange> gapIterator(final Iterator<TextRange> base)