public class Position extends Object
This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Modifier and Type | Class and Description |
---|---|
static interface |
Position.LineMap |
static class |
Position.LineTabMapImpl
A LineMap that handles tab expansion correctly.
|
Modifier and Type | Field and Description |
---|---|
static int |
FIRSTCOLUMN |
static int |
FIRSTLINE |
static int |
FIRSTPOS |
static int |
LINESHIFT |
static int |
MAXCOLUMN |
static int |
MAXLINE |
static int |
MAXPOS |
static int |
NOPOS |
Modifier and Type | Method and Description |
---|---|
static int |
encodePosition(int line,
int col)
Encode line and column numbers in an integer as:
line-number << LINESHIFT + column-number . |
static Position.LineMap |
makeLineMap(char[] src,
int max,
boolean expandTabs)
A two-way map between line/column numbers and positions,
derived from a scan done at creation time.
|
public static final int NOPOS
public static final int FIRSTPOS
public static final int FIRSTLINE
public static final int FIRSTCOLUMN
public static final int LINESHIFT
public static final int MAXCOLUMN
public static final int MAXLINE
public static final int MAXPOS
public static Position.LineMap makeLineMap(char[] src, int max, boolean expandTabs)
Notes: The first character position FIRSTPOS is at (FIRSTLINE,FIRSTCOLUMN). No account is taken of Unicode escapes.
src
- Source charactersmax
- Number of characters to readexpandTabs
- If true, expand tabs when calculating columnspublic static int encodePosition(int line, int col)
line-number << LINESHIFT + column-number
.
NOPOS
represents an undefined position.line
- number of line (first is 1)col
- number of character on line (first is 1)NOPOS
if the line or column number is too big to
represent in the encoded formatIllegalArgumentException
- if line or col is less than 1Copyright © 2017 earcam. All rights reserved.