equal
deleted
inserted
replaced
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javac.util; |
26 package com.sun.tools.javac.util; |
27 |
27 |
28 import java.util.BitSet; |
28 import java.util.BitSet; |
|
29 |
|
30 import com.sun.tools.javac.util.DefinedBy.Api; |
|
31 |
29 import static com.sun.tools.javac.util.LayoutCharacters.*; |
32 import static com.sun.tools.javac.util.LayoutCharacters.*; |
30 |
33 |
31 /** A class that defines source code positions as simple character |
34 /** A class that defines source code positions as simple character |
32 * offsets from the beginning of the file. The first character |
35 * offsets from the beginning of the file. The first character |
33 * is at position 0. |
36 * is at position 0. |
172 |
175 |
173 public int getStartPosition(int line) { |
176 public int getStartPosition(int line) { |
174 return startPosition[line - FIRSTLINE]; |
177 return startPosition[line - FIRSTLINE]; |
175 } |
178 } |
176 |
179 |
|
180 @DefinedBy(Api.COMPILER_TREE) |
177 public long getStartPosition(long line) { |
181 public long getStartPosition(long line) { |
178 return getStartPosition(longToInt(line)); |
182 return getStartPosition(longToInt(line)); |
179 } |
183 } |
180 |
184 |
181 public int getPosition(int line, int column) { |
185 public int getPosition(int line, int column) { |
182 return startPosition[line - FIRSTLINE] + column - FIRSTCOLUMN; |
186 return startPosition[line - FIRSTLINE] + column - FIRSTCOLUMN; |
183 } |
187 } |
184 |
188 |
|
189 @DefinedBy(Api.COMPILER_TREE) |
185 public long getPosition(long line, long column) { |
190 public long getPosition(long line, long column) { |
186 return getPosition(longToInt(line), longToInt(column)); |
191 return getPosition(longToInt(line), longToInt(column)); |
187 } |
192 } |
188 |
193 |
189 // Cache of last line number lookup |
194 // Cache of last line number lookup |
213 } |
218 } |
214 lastLine = low; |
219 lastLine = low; |
215 return lastLine; // pos is on this line |
220 return lastLine; // pos is on this line |
216 } |
221 } |
217 |
222 |
|
223 @DefinedBy(Api.COMPILER_TREE) |
218 public long getLineNumber(long pos) { |
224 public long getLineNumber(long pos) { |
219 return getLineNumber(longToInt(pos)); |
225 return getLineNumber(longToInt(pos)); |
220 } |
226 } |
221 |
227 |
222 public int getColumnNumber(int pos) { |
228 public int getColumnNumber(int pos) { |
223 return pos - startPosition[getLineNumber(pos) - FIRSTLINE] + FIRSTCOLUMN; |
229 return pos - startPosition[getLineNumber(pos) - FIRSTLINE] + FIRSTCOLUMN; |
224 } |
230 } |
225 |
231 |
|
232 @DefinedBy(Api.COMPILER_TREE) |
226 public long getColumnNumber(long pos) { |
233 public long getColumnNumber(long pos) { |
227 return getColumnNumber(longToInt(pos)); |
234 return getColumnNumber(longToInt(pos)); |
228 } |
235 } |
229 |
236 |
230 private static int longToInt(long longValue) { |
237 private static int longToInt(long longValue) { |