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

changeset 1
9a66ca7c79fa
child 554
9d9f26857129
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/com/sun/source/util/SourcePositions.java	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,86 @@
     1.4 +/*
     1.5 + * Copyright 2005-2006 Sun Microsystems, Inc.  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.  Sun designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.26 + * have any questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.source.util;
    1.30 +
    1.31 +import com.sun.source.tree.*;
    1.32 +
    1.33 +/**
    1.34 + * Provides methods to obtain the position of a Tree within a CompilationUnit.
    1.35 + * A position is defined as a simple character offset from the start of a
    1.36 + * CompilationUnit where the first character is at offset 0.
    1.37 + *
    1.38 + * @author Peter von der Ahé
    1.39 + * @since 1.6
    1.40 + */
    1.41 +public interface SourcePositions {
    1.42 +
    1.43 +    /**
    1.44 +     * Gets the starting position of tree within file.  If tree is not found within
    1.45 +     * file, or if the starting position is not available,
    1.46 +     * return {@link javax.tools.Diagnostic#NOPOS}.
    1.47 +     * The returned position must be at the start of the yield of this tree, that
    1.48 +     * is for any sub-tree of this tree, the following must hold:
    1.49 +     *
    1.50 +     * <p>
    1.51 +     * {@code tree.getStartPosition() <= subtree.getStartPosition()} or <br>
    1.52 +     * {@code tree.getStartPosition() == NOPOS} or <br>
    1.53 +     * {@code subtree.getStartPosition() == NOPOS}
    1.54 +     * </p>
    1.55 +     *
    1.56 +     * @param file CompilationUnit in which to find tree.
    1.57 +     * @param tree tree for which a position is sought.
    1.58 +     * @return the start position of tree.
    1.59 +     */
    1.60 +     long getStartPosition(CompilationUnitTree file, Tree tree);
    1.61 +
    1.62 +    /**
    1.63 +     * Gets the ending position of tree within file.  If tree is not found within
    1.64 +     * file, or if the starting position is not available,
    1.65 +     * return {@link javax.tools.Diagnostic#NOPOS}.
    1.66 +     * The returned position must be at the end of the yield of this tree,
    1.67 +     * that is for any sub-tree of this tree, the following must hold:
    1.68 +     *
    1.69 +     * <p>
    1.70 +     * {@code tree.getEndPosition() >= subtree.getEndPosition()} or <br>
    1.71 +     * {@code tree.getEndPosition() == NOPOS} or <br>
    1.72 +     * {@code subtree.getEndPosition() == NOPOS}
    1.73 +     * </p>
    1.74 +     *
    1.75 +     * In addition, the following must hold:
    1.76 +     *
    1.77 +     * <p>
    1.78 +     * {@code tree.getStartPosition() <= tree.getEndPosition()}  or <br>
    1.79 +     * {@code tree.getStartPosition() == NOPOS} or <br>
    1.80 +     * {@code tree.getEndPosition() == NOPOS}
    1.81 +     * </p>
    1.82 +     *
    1.83 +     * @param file CompilationUnit in which to find tree.
    1.84 +     * @param tree tree for which a position is sought.
    1.85 +     * @return the end position of tree.
    1.86 +     */
    1.87 +     long getEndPosition(CompilationUnitTree file, Tree tree);
    1.88 +
    1.89 +}

mercurial