public class TokenScanner
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DOCUMENT_ERROR |
static int |
END_OF_FILE |
static int |
LEXICAL_ERROR |
| Constructor and Description |
|---|
TokenScanner(Scanner scanner)
Creates a TokenScanner
|
| Modifier and Type | Method and Description |
|---|---|
static IStatus |
createError(int code,
java.lang.String message,
java.lang.Throwable throwable) |
int |
getCurrentEndOffset() |
int |
getCurrentLength() |
int |
getCurrentStartOffset() |
int |
getNextEndOffset(int offset,
boolean ignoreComments)
Reads the next token from the given offset and returns the offset after the token.
|
int |
getNextStartOffset(int offset,
boolean ignoreComments)
Reads the next token from the given offset and returns the start offset of the token.
|
int |
getPreviousTokenEndOffset(int token,
int startOffset)
Reads from the given offset until a token is reached and returns the offset after the previous token.
|
Scanner |
getScanner()
Returns the wrapped scanner
|
int |
getTokenEndOffset(int token,
int startOffset)
Reads from the given offset until a token is reached and returns the offset after the token.
|
int |
getTokenStartOffset(int token,
int startOffset)
Reads from the given offset until a token is reached and returns the start offset of the token.
|
static boolean |
isComment(int token) |
static boolean |
isModifier(int token) |
int |
readNext(boolean ignoreComments)
Reads the next token.
|
int |
readNext(int offset,
boolean ignoreComments)
Reads the next token from the given offset.
|
void |
readToToken(int tok)
Reads until a token is reached.
|
void |
readToToken(int tok,
int offset)
Reads until a token is reached, starting from the given offset.
|
void |
setOffset(int offset)
Sets the scanner offset to the given offset.
|
public static final int END_OF_FILE
public static final int LEXICAL_ERROR
public static final int DOCUMENT_ERROR
public TokenScanner(Scanner scanner)
scanner - The scanner to be wrappedpublic Scanner getScanner()
public void setOffset(int offset)
offset - The offset to setpublic int getCurrentEndOffset()
public int getCurrentStartOffset()
public int getCurrentLength()
public int readNext(boolean ignoreComments)
throws CoreException
ignoreComments - If set, comments will be overreadCoreException - Thrown when the end of the file has been reached (code END_OF_FILE)
or a lexical error was detected while scanning (code LEXICAL_ERROR)public int readNext(int offset,
boolean ignoreComments)
throws CoreException
offset - The offset to start reading from.ignoreComments - If set, comments will be overread.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE)
or a lexical error was detected while scanning (code LEXICAL_ERROR)public int getNextStartOffset(int offset,
boolean ignoreComments)
throws CoreException
offset - The offset to start reading from.ignoreComments - If set, comments will be overreadCoreException - Thrown when the end of the file has been reached (code END_OF_FILE)
or a lexical error was detected while scanning (code LEXICAL_ERROR)public int getNextEndOffset(int offset,
boolean ignoreComments)
throws CoreException
offset - The offset to start reading from.ignoreComments - If set, comments will be overreadCoreException - Thrown when the end of the file has been reached (code END_OF_FILE)
or a lexical error was detected while scanning (code LEXICAL_ERROR)public void readToToken(int tok)
throws CoreException
tok - The token to read to.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE)
or a lexical error was detected while scanning (code LEXICAL_ERROR)public void readToToken(int tok,
int offset)
throws CoreException
tok - The token to read to.offset - The offset to start reading from.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE)
or a lexical error was detected while scanning (code LEXICAL_ERROR)public int getTokenStartOffset(int token,
int startOffset)
throws CoreException
token - The token to be found.startOffset - The offset to start reading from.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE)
or a lexical error was detected while scanning (code LEXICAL_ERROR)public int getTokenEndOffset(int token,
int startOffset)
throws CoreException
token - The token to be found.startOffset - Offset to start reading fromCoreException - Thrown when the end of the file has been reached (code END_OF_FILE)
or a lexical error was detected while scanning (code LEXICAL_ERROR)public int getPreviousTokenEndOffset(int token,
int startOffset)
throws CoreException
token - The token to be found.startOffset - The offset to start scanning from.CoreException - Thrown when the end of the file has been reached (code END_OF_FILE)
or a lexical error was detected while scanning (code LEXICAL_ERROR)public static boolean isComment(int token)
public static boolean isModifier(int token)
public static IStatus createError(int code,
java.lang.String message,
java.lang.Throwable throwable)