Class SourceTokenOperator

Object
gudusoft.gsqlparser.pp.utils.SourceTokenOperator

public class SourceTokenOperator extends Object
the helper class used for operating the source token
Author:
zhoujun
  • Constructor Details

  • Method Details

    • removeWhitespaceBackward

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

      public static int removeWhitespaceAndReturnFromEnd(GFmtOpt opt, TSourceTokenList list, int end)
      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

      public static int removeWhitespaceAndReturnFromEnd(GFmtOpt opt, TSourceToken token)
      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

      public static int textLengthVT(TSourceTokenList list, int start, int end)
      calculate the text length for all virtual token (which are call before tokens, after tokens and replace token)
      Parameters:
      list -
      start -
      end -
      Returns:
    • curColumnNumberVT

      public static int curColumnNumberVT(TSourceTokenList list, int pos)
      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

      public static int curColumnNumberVT(TSourceToken token)
      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

      public static int curIndentLenVT(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)
      Parameters:
      list -
      pos -
      Returns:
    • curIndentLenVT

      public static int curIndentLenVT(TSourceToken token)
      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

      public static TSourceToken createWhitespaceSourceToken(int length)
      create the white space source token
      Parameters:
      length -
      Returns:
    • createNoFormatFlagToken

    • createReturnSourceToken

    • combineWhitespace

      public static void combineWhitespace(TSourceTokenList list, int startPos, int endPos)
      combine all the white spaces into a single white space
      Parameters:
      list -
      startPos -
      endPos -
    • addBefore

      public static void addBefore(GFmtOpt opt, TSourceToken targetToken, TSourceToken needAddToken)
      insert the source token before the target source token
      Parameters:
      targetToken -
      needAddToken -
    • addAfter

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

      public static void removeAllBeforeTokenVT(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)
      Parameters:
      targetToken -
    • removeThisToken

      public static void removeThisToken(TSourceToken token)