1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/source/tree/LineMap.java Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,78 @@ 1.4 +/* 1.5 + * Copyright 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.tree; 1.30 + 1.31 +/** 1.32 + * Provides methods to convert between character positions and line numbers 1.33 + * for a compilation unit. 1.34 + * 1.35 + * @since 1.6 1.36 + */ 1.37 +public interface LineMap { 1.38 + /** 1.39 + * Find the start position of a line. 1.40 + * 1.41 + * @param line line number (beginning at 1) 1.42 + * @return position of first character in line 1.43 + * @throws IndexOutOfBoundsException 1.44 + * if <tt>lineNumber < 1</tt> 1.45 + * if <tt>lineNumber > no. of lines</tt> 1.46 + */ 1.47 + long getStartPosition(long line); 1.48 + 1.49 + /** 1.50 + * Find the position corresponding to a (line,column). 1.51 + * 1.52 + * @param line line number (beginning at 1) 1.53 + * @param column tab-expanded column number (beginning 1) 1.54 + * 1.55 + * @return position of character 1.56 + * @throws IndexOutOfBoundsException 1.57 + * if {@code line < 1} 1.58 + * if {@code line > no. of lines} 1.59 + */ 1.60 + long getPosition(long line, long column); 1.61 + 1.62 + /** 1.63 + * Find the line containing a position; a line termination 1.64 + * character is on the line it terminates. 1.65 + * 1.66 + * @param pos character offset of the position 1.67 + * @return the line number of pos (first line is 1) 1.68 + */ 1.69 + long getLineNumber(long pos); 1.70 + 1.71 + /** 1.72 + * Find the column for a character position. 1.73 + * Tab characters preceding the position on the same line 1.74 + * will be expanded when calculating the column number. 1.75 + * 1.76 + * @param pos character offset of the position 1.77 + * @return the tab-expanded column number of pos (first column is 1) 1.78 + */ 1.79 + long getColumnNumber(long pos); 1.80 + 1.81 +}