Package com.puppycrawl.tools.checkstyle
Class AstTreeStringPrinter
java.lang.Object
com.puppycrawl.tools.checkstyle.AstTreeStringPrinter
Class for printing AST to String.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringprintAst(FileText text, JavaParser.Options options) Parse a file and print the parse tree.static StringprintBranch(DetailAST node) Print branch info from root down to givennode.static StringprintFileAst(File file, JavaParser.Options options) Parse a file and print the parse tree.static StringprintJavaAndJavadocTree(File file) Prints full AST (java + comments + javadoc) of the java file.
-
Method Details
-
printFileAst
public static String printFileAst(File file, JavaParser.Options options) throws IOException, CheckstyleException Parse a file and print the parse tree.- Parameters:
file- the file to print.options-JavaParser.Optionsto control the inclusion of comment nodes.- Returns:
- the AST of the file in String form.
- Throws:
IOException- if the file could not be read.CheckstyleException- if the file is not a Java source.
-
printJavaAndJavadocTree
Prints full AST (java + comments + javadoc) of the java file.- Parameters:
file- java file- Returns:
- Full tree
- Throws:
IOException- Failed to open a fileCheckstyleException- error while parsing the file
-
printAst
Parse a file and print the parse tree.- Parameters:
text- the text to parse.options-JavaParser.Optionsto control the inclusion of comment nodes.- Returns:
- the AST of the file in String form.
- Throws:
CheckstyleException- if the file is not a Java source.
-
printBranch
Print branch info from root down to givennode.- Parameters:
node- last item of the branch- Returns:
- branch as string
-