|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.caja.lexer.FilePosition
public final class FilePosition
The range of characters in a source file occupied by a token or a group of tokens.
Fields are 1 indexed since that is how most text editors display line and character (UTF-16 code-unit) positions. The start numbers are inclusive, and the end numbers are exclusive, so the number of characters in a token is (startCharInFile - endCharInFile).
Line numbers are 1 greater than the number of line breaks where a line-break is defined greedily as one of {{{CR}}}, {{{LF}}}, {{{CRLF}}}. Bash, javascript, or python style line-continuations like
a, b, c = 0, 1, \ 2are treated as line breaks. Line numbers are determined solely based on the characters in the file and do not represent a logical unit of a program.
File Positions are independent of the language being parsed.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.google.caja.reporting.MessagePart |
---|
MessagePart.Factory |
Field Summary | |
---|---|
private SourceBreaks |
breaks
|
private int |
length
|
private int |
startCharInFile
|
static FilePosition |
UNKNOWN
|
Constructor Summary | |
---|---|
FilePosition(SourceBreaks breaks,
int startCharInFile,
int length)
|
Method Summary | |
---|---|
static FilePosition |
between(FilePosition a,
FilePosition b)
|
int |
endCharInFile()
|
int |
endCharInLine()
|
int |
endLineNo()
|
static FilePosition |
endOf(FilePosition fp)
|
static FilePosition |
endOfOrNull(FilePosition fp)
|
boolean |
equals(java.lang.Object o)
|
void |
format(MessageContext context,
java.lang.Appendable out)
Formats this part to out. |
void |
formatShort(java.lang.Appendable out)
|
static FilePosition |
fromLinePositions(InputSource source,
int startLineNo,
int startCharInLine,
int endLineNo,
int endCharInLine)
Produce a FilePosition divorced from SourceBreaks to ease testing. |
(package private) SourceBreaks |
getBreaks()
|
int |
hashCode()
|
static FilePosition |
instance(InputSource source,
int lineNo,
int charInFile,
int charInLine)
|
static FilePosition |
instance(InputSource source,
int lineNo,
int charInFile,
int charInLine,
int length)
|
int |
length()
|
InputSource |
source()
|
static FilePosition |
span(FilePosition start,
FilePosition end)
|
int |
startCharInFile()
1 greater than the number of characters since the beginning of the file. |
int |
startCharInLine()
1 greater than the number of characters since the last newline character. |
int |
startLineNo()
1 greater than the number of newlines between the start of the token and the beginning of the file. |
static FilePosition |
startOf(FilePosition fp)
|
static FilePosition |
startOfFile(InputSource source)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final FilePosition UNKNOWN
private final SourceBreaks breaks
private final int startCharInFile
private final int length
Constructor Detail |
---|
FilePosition(SourceBreaks breaks, int startCharInFile, int length)
Method Detail |
---|
SourceBreaks getBreaks()
public InputSource source()
public int startLineNo()
public int startCharInFile()
public int startCharInLine()
public int endLineNo()
public int endCharInFile()
public int endCharInLine()
public int length()
public static FilePosition between(FilePosition a, FilePosition b)
public static FilePosition instance(InputSource source, int lineNo, int charInFile, int charInLine)
public static FilePosition instance(InputSource source, int lineNo, int charInFile, int charInLine, int length)
public static FilePosition fromLinePositions(InputSource source, int startLineNo, int startCharInLine, int endLineNo, int endCharInLine)
public static FilePosition startOfFile(InputSource source)
public static FilePosition span(FilePosition start, FilePosition end)
public static FilePosition startOf(FilePosition fp)
public static FilePosition endOf(FilePosition fp)
public static FilePosition endOfOrNull(FilePosition fp)
public final void format(MessageContext context, java.lang.Appendable out) throws java.io.IOException
MessagePart
format
in interface MessagePart
out
- receives the formatted form of this.
java.io.IOException
public final void formatShort(java.lang.Appendable out) throws java.io.IOException
java.io.IOException
public final java.lang.String toString()
toString
in class java.lang.Object
public final boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |