Package com.puppycrawl.tools.checkstyle
Class AstTreeStringPrinter
- java.lang.Object
-
- com.puppycrawl.tools.checkstyle.AstTreeStringPrinter
-
public final class AstTreeStringPrinter extends Object
Class for printing AST to String.- Author:
- Vladislav Lisetskii
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
printAst(FileText text, boolean withComments)
Parse a file and print the parse tree.static String
printFileAst(File file, boolean withComments)
Parse a file and print the parse tree.static String
printJavaAndJavadocTree(File file)
Prints full AST (java + comments + javadoc) of the java file.
-
-
-
Method Detail
-
printFileAst
public static String printFileAst(File file, boolean withComments) throws IOException, CheckstyleException
Parse a file and print the parse tree.- Parameters:
file
- the file to print.withComments
- true to include comments to AST- 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
public static String printJavaAndJavadocTree(File file) throws IOException, CheckstyleException
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
public static String printAst(FileText text, boolean withComments) throws CheckstyleException
Parse a file and print the parse tree.- Parameters:
text
- the text to parse.withComments
- true to include comments to AST- Returns:
- the AST of the file in String form.
- Throws:
CheckstyleException
- if the file is not a Java source.
-
-