java.lang.Object
org.matwoess.jsourceprofiler.tool.instrument.Util

public class Util extends Object
This class contains utility methods for the ParserState.
  • Constructor Details

    • Util

      public Util()
  • Method Details

    • getBlockBegPos

      public static CodePosition getBlockBegPos(Parser parser, BlockType blockType, boolean isSingleStatement)
      Returns the block begin position, depending on the block type and whether the block is a single statement.

      It returns either the end position of the current token or the start position of the next token.

      Parameters:
      parser - the parser object
      blockType - the type of the block
      isSingleStatement - whether the block is a single statement
      Returns:
      the block begin position
    • getIncInsertOffset

      public static int getIncInsertOffset(Parser parser, BlockType blockType, boolean isSingleStatement)
      Returns the increment insert offset, depending on the block type and whether the block is a single statement.

      It returns either 0 or the difference between the end position of the lookahead token and the block begin position.

      Parameters:
      parser - the parser object
      blockType - the type of the block
      isSingleStatement - whether the block is a single statement
      Returns:
      the increment insert offset