langtools/src/jdk.compiler/share/classes/com/sun/source/util/DocTreePath.java
author chegar
Sun, 17 Aug 2014 15:52:32 +0100
changeset 25874 83c19f00452c
parent 25287 langtools/src/share/classes/com/sun/source/util/DocTreePath.java@d2440361b323
child 29291 076c277565f7
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
     1
/*
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
     2
 * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
     4
 *
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    10
 *
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    15
 * accompanied this code).
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    16
 *
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    20
 *
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    23
 * questions.
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    24
 */
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    25
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    26
package com.sun.source.util;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    27
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    28
import com.sun.source.doctree.DocCommentTree;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    29
import com.sun.source.doctree.DocTree;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    30
import java.util.Iterator;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    31
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    32
/**
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    33
 * A path of tree nodes, typically used to represent the sequence of ancestor
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    34
 * nodes of a tree node up to the top level DocCommentTree node.
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    35
 *
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    36
 * @since 1.8
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    37
 */
20612
4761f3ff7afb 8025913: Rename jdk.Supported to jdk.Exported
darcy
parents: 17549
diff changeset
    38
@jdk.Exported
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    39
public class DocTreePath implements Iterable<DocTree> {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    40
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    41
     * Returns a documentation tree path for a tree node within a compilation unit,
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    42
     * or {@code null} if the node is not found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    43
     * @param treePath the path for the node with which the doc comment is associated
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    44
     * @param doc the doc comment associated with the node
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    45
     * @param target a node within the doc comment
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    46
     * @return a path identifying the target within the tree
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    47
     */
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    48
    public static DocTreePath getPath(TreePath treePath, DocCommentTree doc, DocTree target) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    49
        return getPath(new DocTreePath(treePath, doc), target);
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    50
    }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    51
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    52
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    53
     * Returns a documentation tree path for a tree node within a subtree
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    54
     * identified by a DocTreePath object, or {@code null} if the node is not found.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    55
     * @param path a path identifying a node within a doc comment tree
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    56
     * @param target a node to be located within the given node
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
    57
     * @return a path identifying the target node
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    58
     */
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    59
    public static DocTreePath getPath(DocTreePath path, DocTree target) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    60
        path.getClass();
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    61
        target.getClass();
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    62
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    63
        class Result extends Error {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    64
            static final long serialVersionUID = -5942088234594905625L;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    65
            DocTreePath path;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    66
            Result(DocTreePath path) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    67
                this.path = path;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    68
            }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    69
        }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    70
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    71
        class PathFinder extends DocTreePathScanner<DocTreePath,DocTree> {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    72
            public DocTreePath scan(DocTree tree, DocTree target) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    73
                if (tree == target) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    74
                    throw new Result(new DocTreePath(getCurrentPath(), target));
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    75
                }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    76
                return super.scan(tree, target);
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    77
            }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    78
        }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    79
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    80
        if (path.getLeaf() == target) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    81
            return path;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    82
        }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    83
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    84
        try {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    85
            new PathFinder().scan(path, target);
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    86
        } catch (Result result) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    87
            return result.path;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    88
        }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    89
        return null;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    90
    }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    91
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    92
    /**
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    93
     * Creates a DocTreePath for a root node.
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    94
     *
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    95
     * @param treePath the TreePath from which the root node was created.
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    96
     * @param t the DocCommentTree to create the path for.
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    97
     */
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    98
    public DocTreePath(TreePath treePath, DocCommentTree t) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
    99
        treePath.getClass();
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   100
        t.getClass();
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   101
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   102
        this.treePath = treePath;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   103
        this.docComment = t;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   104
        this.parent = null;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   105
        this.leaf = t;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   106
    }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   107
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   108
    /**
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   109
     * Creates a DocTreePath for a child node.
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
   110
     * @param p the parent node
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
   111
     * @param t the child node
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   112
     */
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   113
    public DocTreePath(DocTreePath p, DocTree t) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   114
        if (t.getKind() == DocTree.Kind.DOC_COMMENT) {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   115
            throw new IllegalArgumentException("Use DocTreePath(TreePath, DocCommentTree) to construct DocTreePath for a DocCommentTree.");
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   116
        } else {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   117
            treePath = p.treePath;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   118
            docComment = p.docComment;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   119
            parent = p;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   120
        }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   121
        leaf = t;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   122
    }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   123
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   124
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
   125
     * Returns the TreePath associated with this path.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
   126
     * @return the TreePath for this DocTreePath
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   127
     */
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   128
    public TreePath getTreePath() {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   129
        return treePath;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   130
    }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   131
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   132
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
   133
     * Returns the DocCommentTree associated with this path.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
   134
     * @return the DocCommentTree for this DocTreePath
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   135
     */
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   136
    public DocCommentTree getDocComment() {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   137
        return docComment;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   138
    }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   139
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   140
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
   141
     * Returns the leaf node for this path.
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
   142
     * @return the DocTree for this DocTreePath
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   143
     */
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   144
    public DocTree getLeaf() {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   145
        return leaf;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   146
    }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   147
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   148
    /**
25287
d2440361b323 8046614: Fill in missing doc comments
jjg
parents: 20612
diff changeset
   149
     * Returns the path for the enclosing node, or {@code null} if there is no enclosing node.
17549
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   150
     * @return DocTreePath of parent
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   151
     */
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   152
    public DocTreePath getParentPath() {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   153
        return parent;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   154
    }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   155
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   156
    public Iterator<DocTree> iterator() {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   157
        return new Iterator<DocTree>() {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   158
            public boolean hasNext() {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   159
                return next != null;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   160
            }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   161
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   162
            public DocTree next() {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   163
                DocTree t = next.leaf;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   164
                next = next.parent;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   165
                return t;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   166
            }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   167
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   168
            public void remove() {
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   169
                throw new UnsupportedOperationException();
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   170
            }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   171
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   172
            private DocTreePath next = DocTreePath.this;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   173
        };
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   174
    }
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   175
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   176
    private final TreePath treePath;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   177
    private final DocCommentTree docComment;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   178
    private final DocTree leaf;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   179
    private final DocTreePath parent;
65ea6f3b72d9 8009724: Enhance the DocTree API with DocTreePath
jlahoda
parents:
diff changeset
   180
}