src/share/classes/com/sun/source/util/DocSourcePositions.java

changeset 0
959103a6100f
child 2525
2eb010b6cb22
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/com/sun/source/util/DocSourcePositions.java	Wed Apr 27 01:34:52 2016 +0800
     1.3 @@ -0,0 +1,98 @@
     1.4 +/*
     1.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.source.util;
    1.30 +
    1.31 +import com.sun.source.doctree.DocCommentTree;
    1.32 +import com.sun.source.doctree.DocTree;
    1.33 +import com.sun.source.tree.CompilationUnitTree;
    1.34 +
    1.35 +/**
    1.36 + * Provides methods to obtain the position of a DocTree within a javadoc comment.
    1.37 + * A position is defined as a simple character offset from the start of a
    1.38 + * CompilationUnit where the first character is at offset 0.
    1.39 + *
    1.40 + * @since 1.8
    1.41 + */
    1.42 +@jdk.Exported
    1.43 +public interface DocSourcePositions extends SourcePositions {
    1.44 +
    1.45 +    /**
    1.46 +     * Gets the starting position of the tree within the comment within the file.  If tree is not found within
    1.47 +     * file, or if the starting position is not available,
    1.48 +     * return {@link javax.tools.Diagnostic#NOPOS}.
    1.49 +     * The given tree should be under the given comment tree, and the given documentation
    1.50 +     * comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) }
    1.51 +     * for a tree under the given file.
    1.52 +     * The returned position must be at the start of the yield of this tree, that
    1.53 +     * is for any sub-tree of this tree, the following must hold:
    1.54 +     *
    1.55 +     * <p>
    1.56 +     * {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br>
    1.57 +     * {@code tree.getStartPosition() == NOPOS} or <br>
    1.58 +     * {@code subtree.getStartPosition() == NOPOS}
    1.59 +     * </p>
    1.60 +     *
    1.61 +     * @param file CompilationUnit in which to find tree.
    1.62 +     * @param comment the comment tree that encloses the tree for which the
    1.63 +     *                position is being sought
    1.64 +     * @param tree tree for which a position is sought.
    1.65 +     * @return the start position of tree.
    1.66 +     */
    1.67 +    long getStartPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree);
    1.68 +
    1.69 +    /**
    1.70 +     * Gets the ending position of the tree within the comment within the file.  If tree is not found within
    1.71 +     * file, or if the ending position is not available,
    1.72 +     * return {@link javax.tools.Diagnostic#NOPOS}.
    1.73 +     * The given tree should be under the given comment tree, and the given documentation
    1.74 +     * comment tree should be returned from a {@link DocTrees#getDocCommentTree(com.sun.source.util.TreePath) }
    1.75 +     * for a tree under the given file.
    1.76 +     * The returned position must be at the end of the yield of this tree,
    1.77 +     * that is for any sub-tree of this tree, the following must hold:
    1.78 +     *
    1.79 +     * <p>
    1.80 +     * {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br>
    1.81 +     * {@code tree.getEndPosition() == NOPOS} or <br>
    1.82 +     * {@code subtree.getEndPosition() == NOPOS}
    1.83 +     * </p>
    1.84 +     *
    1.85 +     * In addition, the following must hold:
    1.86 +     *
    1.87 +     * <p>
    1.88 +     * {@code tree.getStartPosition() <= tree.getEndPosition()}  or <br>
    1.89 +     * {@code tree.getStartPosition() == NOPOS} or <br>
    1.90 +     * {@code tree.getEndPosition() == NOPOS}
    1.91 +     * </p>
    1.92 +     *
    1.93 +     * @param file CompilationUnit in which to find tree.
    1.94 +     * @param comment the comment tree that encloses the tree for which the
    1.95 +     *                position is being sought
    1.96 +     * @param tree tree for which a position is sought.
    1.97 +     * @return the start position of tree.
    1.98 +     */
    1.99 +    long getEndPosition(CompilationUnitTree file, DocCommentTree comment, DocTree tree);
   1.100 +
   1.101 +}

mercurial