Class ParserUtil

java.lang.Object
com.puppycrawl.tools.checkstyle.utils.ParserUtil

public final class ParserUtil extends Object
Contains utility methods for parser to use while creating ast.
  • Field Details

  • Constructor Details

    • ParserUtil

      private ParserUtil()
      Stop instances being created.
  • Method Details

    • createBlockCommentNode

      public static DetailAST createBlockCommentNode(String content)
      Create block comment from string content.
      Parameters:
      content - comment content.
      Returns:
      DetailAST block comment
    • createBlockCommentNode

      public static DetailAST createBlockCommentNode(org.antlr.v4.runtime.CommonToken token)
      Create block comment from token.
      Parameters:
      token - Token object.
      Returns:
      DetailAST with BLOCK_COMMENT type.
    • countLinesColumns

      private static Map.Entry<Integer,Integer> countLinesColumns(String text, int initialLinesCnt, int initialColumnsCnt)
      Count lines and columns (in last line) in text.
      Parameters:
      text - String.
      initialLinesCnt - initial value of lines counter.
      initialColumnsCnt - initial value of columns counter.
      Returns:
      entry(pair), key is line counter, value is column counter.