Class DetailNodeTreeStringPrinter

java.lang.Object
com.puppycrawl.tools.checkstyle.DetailNodeTreeStringPrinter

public final class DetailNodeTreeStringPrinter extends Object
Parses file as javadoc DetailNode tree and prints to system output stream.
  • Field Details

  • Constructor Details

  • Method Details

    • printFileAst

      public static String printFileAst(File file) throws IOException
      Parse a file and print the parse tree.
      Parameters:
      file - the file to print.
      Returns:
      parse tree as a string
      Throws:
      IOException - if the file could not be read.
    • parseJavadocAsDetailNode

      public static DetailNode parseJavadocAsDetailNode(DetailAST blockComment)
      Parse block comment DetailAST as Javadoc DetailNode tree.
      Parameters:
      blockComment - DetailAST
      Returns:
      DetailNode tree
      Throws:
      IllegalArgumentException - if there is an error parsing the Javadoc.
    • parseJavadocAsDetailNode

      private static DetailNode parseJavadocAsDetailNode(String javadocComment)
      Parse javadoc comment to DetailNode tree.
      Parameters:
      javadocComment - javadoc comment content
      Returns:
      tree
    • getParseErrorMessage

      Builds violation base on ParseErrorMessage's violation key, its arguments, etc.
      Parameters:
      parseErrorMessage - ParseErrorMessage
      Returns:
      error violation
    • printTree

      public static String printTree(DetailNode ast, String rootPrefix, String prefix)
      Print AST.
      Parameters:
      ast - the root AST node.
      rootPrefix - prefix for the root node
      prefix - prefix for other nodes
      Returns:
      string AST.
    • getIndentation

      private static String getIndentation(DetailNode node)
      Get indentation for a node.
      Parameters:
      node - the DetailNode to get the indentation for.
      Returns:
      the indentation in String format.
    • parseFile

      private static DetailNode parseFile(File file) throws IOException
      Parse a file and return the parse tree.
      Parameters:
      file - the file to parse.
      Returns:
      the root node of the parse tree.
      Throws:
      IOException - if the file could not be read.