class DefinitionsTokenStream extends TokenStream {

    /**
     * Defines the ultimate queue of tokens to be produced by
     * {@link #incrementToken()}.
     */
    private final List<PendingToken> events = new ArrayList<>();

    private final CharTermAttribute termAtt = addAttribute(
        CharTermAttribute.class);
    private final OffsetAttribute offsetAtt = addAttribute(
        OffsetAttribute.class);
    private final PositionIncrementAttribute posIncrAtt = addAttribute(
        PositionIncrementAttribute.class);

    private int offset;

    /**
     * Initializes the stream by merging {@code defs} with cross-referenced
     * line offsets read from {@code src}.
     * @param defs a defined instance
     * @param src a defined instance
     * @param wrapper an optional instance
     * @throws IOException if I/O error occurs
     */
    public void initialize(Definitions defs, StreamSource src,
            ReaderWrapper wrapper) throws IOException {<FILL_FUNCTION_BODY>}

    /**
     * Publishes the next, pending token from
     * {@link #initialize(org.opengrok.indexer.analysis.Definitions, org.opengrok.indexer.analysis.StreamSource,
     * org.opengrok.indexer.util.ReaderWrapper)},
     * if one is available.
     * @return false if no more tokens; otherwise true
     * @throws IOException in case of I/O error
     */
    @Override
    public final boolean incrementToken() throws IOException {
        if (offset < events.size()) {
            PendingToken tok = events.get(offset++);
            setAttribs(tok);
            return true;
        }

        clearAttributes();
        return false;
    }

    private void setAttribs(PendingToken tok) {
        clearAttributes();

        this.posIncrAtt.setPositionIncrement(1);
        this.termAtt.setEmpty();
        this.termAtt.append(tok.str);
        this.offsetAtt.setOffset(tok.start, tok.end);
    }

    private void createTokens(Definitions defs, LineBreaker brk) {
        for (Definitions.Tag tag : defs.getTags()) {
            // Shift from ctags's convention.
            int lineno = tag.line - 1;

            if (lineno >= 0 && lineno < brk.count() && tag.symbol != null &&
                    tag.text != null) {
                int lineoff = brk.getOffset(lineno);
                if (tag.lineStart >= 0) {
                    PendingToken tok = new PendingToken(tag.symbol, lineoff +
                        tag.lineStart, lineoff + tag.lineEnd);
                    events.add(tok);
                }
            }
        }

        events.sort(PendingTokenOffsetsComparator.INSTANCE);
    }
}

        if (defs == null) {
            throw new IllegalArgumentException("`defs' is null");
        }
        if (src == null) {
            throw new IllegalArgumentException("`src' is null");
        }

        events.clear();
        offset = 0;

        LineBreaker brk = new LineBreaker();
        brk.reset(src, wrapper);
        createTokens(defs, brk);
    
<no_super_class>