duke@1: /* darcy@1590: * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.source.tree; duke@1: duke@1: /** duke@1: * Provides methods to convert between character positions and line numbers duke@1: * for a compilation unit. duke@1: * duke@1: * @since 1.6 duke@1: */ darcy@2083: @jdk.Exported duke@1: public interface LineMap { duke@1: /** duke@1: * Find the start position of a line. duke@1: * duke@1: * @param line line number (beginning at 1) duke@1: * @return position of first character in line duke@1: * @throws IndexOutOfBoundsException jjg@1326: * if {@code lineNumber < 1} jjg@1326: * if {@code lineNumber > no. of lines} duke@1: */ duke@1: long getStartPosition(long line); duke@1: duke@1: /** duke@1: * Find the position corresponding to a (line,column). duke@1: * duke@1: * @param line line number (beginning at 1) duke@1: * @param column tab-expanded column number (beginning 1) duke@1: * duke@1: * @return position of character duke@1: * @throws IndexOutOfBoundsException duke@1: * if {@code line < 1} duke@1: * if {@code line > no. of lines} duke@1: */ duke@1: long getPosition(long line, long column); duke@1: duke@1: /** duke@1: * Find the line containing a position; a line termination duke@1: * character is on the line it terminates. duke@1: * duke@1: * @param pos character offset of the position duke@1: * @return the line number of pos (first line is 1) duke@1: */ duke@1: long getLineNumber(long pos); duke@1: duke@1: /** duke@1: * Find the column for a character position. duke@1: * Tab characters preceding the position on the same line duke@1: * will be expanded when calculating the column number. duke@1: * duke@1: * @param pos character offset of the position duke@1: * @return the tab-expanded column number of pos (first column is 1) duke@1: */ duke@1: long getColumnNumber(long pos); duke@1: duke@1: }