com.sun.source.util.DocTreePathScanner Java Examples

The following examples show how to use com.sun.source.util.DocTreePathScanner. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DocTreePathHandle.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static DocTreePath getChild(@NonNull DocCommentTree t, final int index) {
    final DocTreePath[] result = new DocTreePath[1];

    t.accept(new DocTreePathScanner<DocTreePath, Void>() {
        int count = 0;
        @Override
        public DocTreePath scan(DocTree node, Void p) {
            if(index == count) {
                result[0] = getCurrentPath();
            }
            return null;
        }
    }, null);

    return result[0];
}
 
Example #2
Source File: JavadocCompletionQuery.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private DocTreePath getTag(final JavadocContext jdctx, final int offset) {
    final DocTreePath[] result = new DocTreePath[1];
    final int normalizedOffset = skipWhitespacesBackwards(jdctx, offset);
    new DocTreePathScanner<Void, Void>() {
        @Override public Void scan(DocTree node, Void p) {
            if (   node != null
                && jdctx.positions.getStartPosition(jdctx.javac.getCompilationUnit(), jdctx.comment, node) <= normalizedOffset
                && jdctx.positions.getEndPosition(jdctx.javac.getCompilationUnit(), jdctx.comment, node) >= normalizedOffset) {
                result[0] = new DocTreePath(getCurrentPath(), node);
                return super.scan(node, p);
            }
            
            return null;
        }
    }.scan(new DocTreePath(jdctx.javadocFor, jdctx.comment), null);
    
    return result[0];
}