Class AstTreeStringPrinter


  • public final class AstTreeStringPrinter
    extends java.lang.Object
    Class for printing AST to String.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String printAst​(FileText text, JavaParser.Options options)
      Parse a file and print the parse tree.
      static java.lang.String printBranch​(DetailAST node)
      Print branch info from root down to given node.
      static java.lang.String printFileAst​(java.io.File file, JavaParser.Options options)
      Parse a file and print the parse tree.
      static java.lang.String printJavaAndJavadocTree​(java.io.File file)
      Prints full AST (java + comments + javadoc) of the java file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • printFileAst

        public static java.lang.String printFileAst​(java.io.File file,
                                                    JavaParser.Options options)
                                             throws java.io.IOException,
                                                    CheckstyleException
        Parse a file and print the parse tree.
        Parameters:
        file - the file to print.
        options - JavaParser.Options to control the inclusion of comment nodes.
        Returns:
        the AST of the file in String form.
        Throws:
        java.io.IOException - if the file could not be read.
        CheckstyleException - if the file is not a Java source.
      • printJavaAndJavadocTree

        public static java.lang.String printJavaAndJavadocTree​(java.io.File file)
                                                        throws java.io.IOException,
                                                               CheckstyleException
        Prints full AST (java + comments + javadoc) of the java file.
        Parameters:
        file - java file
        Returns:
        Full tree
        Throws:
        java.io.IOException - Failed to open a file
        CheckstyleException - error while parsing the file
      • printBranch

        public static java.lang.String printBranch​(DetailAST node)
        Print branch info from root down to given node.
        Parameters:
        node - last item of the branch
        Returns:
        branch as string