Table of Contents

Class SourceTokenOperator

Namespace
gudusoft.gsqlparser.pp.utils
Assembly
gudusoft.gsqlparser.dll

the helper class used for operating the source token

@author zhoujun

public class SourceTokenOperator
Inheritance
SourceTokenOperator
Inherited Members

Methods

addAfter(GFmtOpt, TSourceToken, TSourceToken)

public static void addAfter(GFmtOpt opt, TSourceToken targetToken, TSourceToken needAddToken)

Parameters

opt GFmtOpt
targetToken TSourceToken
needAddToken TSourceToken

addBefore(GFmtOpt, TSourceToken, TSourceToken)

insert the source token before the target source token

public static void addBefore(GFmtOpt opt, TSourceToken targetToken, TSourceToken needAddToken)

Parameters

opt GFmtOpt
targetToken TSourceToken
needAddToken TSourceToken

combineWhitespace(TSourceTokenList, int, int)

combine all the white spaces into a single white space

public static void combineWhitespace(TSourceTokenList list, int startPos, int endPos)

Parameters

list TSourceTokenList
startPos int
endPos int

createNoFormatFlagToken()

public static TSourceToken createNoFormatFlagToken()

Returns

TSourceToken

createReturnSourceToken()

public static TSourceToken createReturnSourceToken()

Returns

TSourceToken

createWhitespaceSourceToken(int)

create the white space source token

public static TSourceToken createWhitespaceSourceToken(int length)

Parameters

length int

@return

Returns

TSourceToken

curColumnNumberVT(TSourceToken)

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)

public static int curColumnNumberVT(TSourceToken token)

Parameters

token TSourceToken

@return

Returns

int

curColumnNumberVT(TSourceTokenList, int)

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)

public static int curColumnNumberVT(TSourceTokenList list, int pos)

Parameters

list TSourceTokenList
pos int

@return

Returns

int

curIndentLenVT(TSourceToken)

calculate the current indent length VT is the abbr for "virtual token" (which contains before tokens, after tokens and replace token)

public static int curIndentLenVT(TSourceToken token)

Parameters

token TSourceToken

@return

Returns

int

curIndentLenVT(TSourceTokenList, int)

calculate the current indent length VT is the abbr for "virtual token" (which contains before tokens, after tokens and replace token)

public static int curIndentLenVT(TSourceTokenList list, int pos)

Parameters

list TSourceTokenList
pos int

@return

Returns

int

removeAllBeforeTokenVT(GFmtOpt, TSourceToken)

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)

public static void removeAllBeforeTokenVT(GFmtOpt opt, TSourceToken targetToken)

Parameters

opt GFmtOpt
targetToken TSourceToken

removeThisToken(TSourceToken)

public static void removeThisToken(TSourceToken token)

Parameters

token TSourceToken

removeWhitespaceAndReturn(GFmtOpt, TSourceTokenList, int, int)

remove the white space and the return token

public static void removeWhitespaceAndReturn(GFmtOpt opt, TSourceTokenList list, int start, int end)

Parameters

opt GFmtOpt
list TSourceTokenList
start int
end int

removeWhitespaceAndReturnFormBeforeAndAfter(GFmtOpt, TSourceToken)

remove the white space and the return token before this token and after this token

public static void removeWhitespaceAndReturnFormBeforeAndAfter(GFmtOpt opt, TSourceToken token)

Parameters

opt GFmtOpt
token TSourceToken

removeWhitespaceAndReturnFromEnd(GFmtOpt, TSourceToken)

remove the white space and the return token from the end

public static int removeWhitespaceAndReturnFromEnd(GFmtOpt opt, TSourceToken token)

Parameters

opt GFmtOpt
token TSourceToken

Returns

int

the pos which is not whitespace and return token in the source token list

removeWhitespaceAndReturnFromEnd(GFmtOpt, TSourceTokenList, int)

remove the white space and the return token from the end

public static int removeWhitespaceAndReturnFromEnd(GFmtOpt opt, TSourceTokenList list, int end)

Parameters

opt GFmtOpt
list TSourceTokenList
end int

Returns

int

the pos which is not white space and return token in the source token list

removeWhitespaceAndReturnFromStart(GFmtOpt, TSourceTokenList, int)

remove the white space and the return token from the end

public static int removeWhitespaceAndReturnFromStart(GFmtOpt opt, TSourceTokenList list, int startPos)

Parameters

opt GFmtOpt
list TSourceTokenList
startPos int

Returns

int

removeWhitespaceBackward(GFmtOpt, TSourceTokenList, int)

public static int removeWhitespaceBackward(GFmtOpt opt, TSourceTokenList list, int end)

Parameters

opt GFmtOpt
list TSourceTokenList
end int

Returns

int

textLengthVT(TSourceTokenList, int, int)

calculate the text length for all virtual token (which are call before tokens, after tokens and replace token)

public static int textLengthVT(TSourceTokenList list, int start, int end)

Parameters

list TSourceTokenList
start int
end int

@return

Returns

int