Package gudusoft.gsqlparser.pp.utils
Class SourceTokenOperator
Object
gudusoft.gsqlparser.pp.utils.SourceTokenOperator
the helper class used for operating the source token
- Author:
- zhoujun
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddAfter(GFmtOpt opt, TSourceToken targetToken, TSourceToken needAddToken) static voidaddBefore(GFmtOpt opt, TSourceToken targetToken, TSourceToken needAddToken) insert the source token before the target source tokenstatic voidcombineWhitespace(TSourceTokenList list, int startPos, int endPos) combine all the white spaces into a single white spacestatic TSourceTokenstatic TSourceTokenstatic TSourceTokencreateWhitespaceSourceToken(int length) create the white space source tokenstatic intcurColumnNumberVT(TSourceToken token) calcaulate the text length from a given position to the line start.static intcurColumnNumberVT(TSourceTokenList list, int pos) calcaulate the text length from a given position to the line start.static intcurIndentLenVT(TSourceToken token) calculate the current indent length VT is the abbr for "virtual token" (which contains before tokens, after tokens and replace token)static intcurIndentLenVT(TSourceTokenList list, int pos) calculate the current indent length VT is the abbr for "virtual token" (which contains before tokens, after tokens and replace token)static voidremoveAllBeforeTokenVT(GFmtOpt opt, TSourceToken targetToken) remove all source token in the before source token list VT is the abbr for "virtual token" (that this method will operates before tokens, after tokens and replace token)static voidremoveThisToken(TSourceToken token) static voidremoveWhitespaceAndReturn(GFmtOpt opt, TSourceTokenList list, int start, int end) remove the white space and the return tokenstatic voidremove the white space and the return token before this token and after this tokenstatic intremoveWhitespaceAndReturnFromEnd(GFmtOpt opt, TSourceToken token) remove the white space and the return token from the endstatic intremoveWhitespaceAndReturnFromEnd(GFmtOpt opt, TSourceTokenList list, int end) remove the white space and the return token from the endstatic intremoveWhitespaceAndReturnFromStart(GFmtOpt opt, TSourceTokenList list, int startPos) remove the white space and the return token from the endstatic intremoveWhitespaceBackward(GFmtOpt opt, TSourceTokenList list, int end) static inttextLengthVT(TSourceTokenList list, int start, int end) calculate the text length for all virtual token (which are call before tokens, after tokens and replace token)
-
Constructor Details
-
SourceTokenOperator
public SourceTokenOperator()
-
-
Method Details
-
removeWhitespaceBackward
-
removeWhitespaceAndReturnFromEnd
remove the white space and the return token from the end- Parameters:
list-end-- Returns:
- the pos which is not white space and return token in the source token list
-
removeWhitespaceAndReturnFromEnd
remove the white space and the return token from the end- Parameters:
token-- Returns:
- the pos which is not whitespace and return token in the source token list
-
removeWhitespaceAndReturnFormBeforeAndAfter
remove the white space and the return token before this token and after this token- Parameters:
opt-token-
-
removeWhitespaceAndReturn
public static void removeWhitespaceAndReturn(GFmtOpt opt, TSourceTokenList list, int start, int end) remove the white space and the return token- Parameters:
list-start-end-
-
removeWhitespaceAndReturnFromStart
public static int removeWhitespaceAndReturnFromStart(GFmtOpt opt, TSourceTokenList list, int startPos) remove the white space and the return token from the end- Parameters:
list-
-
textLengthVT
calculate the text length for all virtual token (which are call before tokens, after tokens and replace token)- Parameters:
list-start-end-- Returns:
-
curColumnNumberVT
calcaulate the text length from a given position to the line start. VT is the abbr for "virtual token" (which contains before tokens, after tokens and replace token)- Parameters:
list-pos-- Returns:
-
curColumnNumberVT
calcaulate the text length from a given position to the line start. VT is the abbr for "virtual token" (which contains before tokens, after tokens and replace token)- Parameters:
token-- Returns:
-
curIndentLenVT
calculate the current indent length VT is the abbr for "virtual token" (which contains before tokens, after tokens and replace token)- Parameters:
list-pos-- Returns:
-
curIndentLenVT
calculate the current indent length VT is the abbr for "virtual token" (which contains before tokens, after tokens and replace token)- Parameters:
token-- Returns:
-
createWhitespaceSourceToken
create the white space source token- Parameters:
length-- Returns:
-
createNoFormatFlagToken
-
createReturnSourceToken
-
combineWhitespace
combine all the white spaces into a single white space- Parameters:
list-startPos-endPos-
-
addBefore
insert the source token before the target source token- Parameters:
targetToken-needAddToken-
-
addAfter
-
removeAllBeforeTokenVT
remove all source token in the before source token list VT is the abbr for "virtual token" (that this method will operates before tokens, after tokens and replace token)- Parameters:
targetToken-
-
removeThisToken
-