public class SourceTokenSearcher extends Object
| Constructor and Description |
|---|
SourceTokenSearcher() |
| Modifier and Type | Method and Description |
|---|---|
static TSourceToken |
backforwardSearch(TSourceToken token,
int backsearchSize,
String text)
backward search the source token
|
static TSourceToken |
backforwardSearchNotWhitespaceAndReturnToken(TSourceToken endToken,
int backforwardSearchSize,
String text) |
static TSourceToken |
backforwardSearchSolid(TSourceToken token,
int solidSteps,
String text)
Search backward from
token for the token whose text is
text, counting only solid tokens: whitespace, line breaks and
comments do not consume a step. |
static TSourceToken |
firstNotWhitespaceAndReturnToken(TSourceTokenList list,
int startPos,
int endPos)
get first token which is not whitespace and return token
|
static TSourceToken |
firstSelectedToken(TSourceTokenList list,
int startPos,
int endPos,
String text) |
static TSourceToken |
firstSelectNotWhitespaceAndReturnToken(TSourceTokenList list,
int startPos,
String text)
forward search the token which is the first not whitespace or return
token, and its value is a fixed text
|
static TSourceToken |
forwardSearch(TSourceToken token,
int forwardSearchSize,
String text)
forward search the source token
|
static TSourceToken |
forwardSearchSolid(TSourceToken token,
int solidSteps,
String text)
|
static int |
indexOf(TSourceTokenList list,
int startPos,
int endPos,
ETokenType type)
search the source token in the source token list from the top
|
static int |
indexOf(TSourceTokenList list,
int startPos,
int endPos,
String text)
search the source token in the source token list from the top
|
static int |
indexOf(TSourceTokenList list,
int startPos,
String text)
search the source token in the source token list from the top
|
static boolean |
isNewLineToken(TSourceToken token) |
static boolean |
isSimpleComment(TSourceToken token) |
static int |
lastIndexOf(TSourceTokenList list,
int startPos,
int endPos,
String text)
search the source token in the source token list from the end
|
static int |
lastIndexOf(TSourceTokenList list,
int endPos,
String text)
search the source token in the source token list from the end
|
static TSourceToken |
lastNotWhitespaceAndReturnToken(TSourceTokenList list,
int endPos)
get last token which is not whitespace and return token
|
static TSourceToken |
lastNotWhitespaceAndReturnToken(TSourceTokenList list,
int startPos,
int endPos)
get last token which is not whitespace and return token
|
static TSourceToken |
lastSelectedNotWhitespaceAndReturnToken(TSourceTokenList list,
int endPos,
String text)
backward search the token which is the first not whitespace or return
token, and its value is a fixed text
|
static TSourceToken |
lastSelectedNotWhitespaceAndReturnToken(TSourceToken token,
String text)
backward search the token which is the first not whitespace or return
token, and its value is a fixed text
|
static TSourceToken |
lastSelectedToken(TSourceTokenList list,
int startPos,
int endPos,
String text) |
public SourceTokenSearcher()
public static int indexOf(TSourceTokenList list, int startPos, int endPos, String text)
list - startPos - endPos - text - public static int indexOf(TSourceTokenList list, int startPos, int endPos, ETokenType type)
list - startPos - endPos - type - public static int indexOf(TSourceTokenList list, int startPos, String text)
list - startPos - text - public static TSourceToken backforwardSearch(TSourceToken token, int backsearchSize, String text)
backsearchSize - text - public static TSourceToken forwardSearch(TSourceToken token, int forwardSearchSize, String text)
token - forwardSearchSize - text - public static int lastIndexOf(TSourceTokenList list, int startPos, int endPos, String text)
list - startPos - endPos - text - public static int lastIndexOf(TSourceTokenList list, int endPos, String text)
list - endPos - text - public static TSourceToken lastNotWhitespaceAndReturnToken(TSourceTokenList list, int startPos, int endPos)
list - startPos - endPos - public static TSourceToken lastNotWhitespaceAndReturnToken(TSourceTokenList list, int endPos)
list - endPos - public static TSourceToken lastSelectedNotWhitespaceAndReturnToken(TSourceTokenList list, int endPos, String text)
list - endPos - the fixed valuepublic static TSourceToken firstNotWhitespaceAndReturnToken(TSourceTokenList list, int startPos, int endPos)
list - startPos - endPos - public static TSourceToken firstSelectNotWhitespaceAndReturnToken(TSourceTokenList list, int startPos, String text)
list - startPos - text - public static TSourceToken lastSelectedNotWhitespaceAndReturnToken(TSourceToken token, String text)
token - text - public static boolean isNewLineToken(TSourceToken token)
public static boolean isSimpleComment(TSourceToken token)
public static TSourceToken backforwardSearchSolid(TSourceToken token, int solidSteps, String text)
token for the token whose text is
text, counting only solid tokens: whitespace, line breaks and
comments do not consume a step. backforwardSearch(gudusoft.gsqlparser.TSourceToken, int, java.lang.String) counts every
token, so a comment sitting between the searched keyword and its
anchor pushed the keyword out of the window and the caller received
null (NullPointerException in CTEProcessor and
AppendLineAfterInsertTableNameProcessor on real-world scripts).public static TSourceToken forwardSearchSolid(TSourceToken token, int solidSteps, String text)
public static TSourceToken backforwardSearchNotWhitespaceAndReturnToken(TSourceToken endToken, int backforwardSearchSize, String text)
public static TSourceToken lastSelectedToken(TSourceTokenList list, int startPos, int endPos, String text)
public static TSourceToken firstSelectedToken(TSourceTokenList list, int startPos, int endPos, String text)