public final class AstTreeStringPrinter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
LINE_SEPARATOR
OS specific line separator.
|
private static java.util.regex.Pattern |
NEWLINE
Newline pattern.
|
private static java.util.regex.Pattern |
RETURN
Return pattern.
|
private static java.util.regex.Pattern |
TAB
Tab pattern.
|
Modifier | Constructor and Description |
---|---|
private |
AstTreeStringPrinter()
Prevent instances.
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
escapeAllControlChars(java.lang.String text)
Replace all control chars with escaped symbols.
|
private static java.lang.String |
getIndentation(DetailAST ast)
Get indentation for an AST node.
|
private static java.lang.String |
getNodeInfo(DetailAST node)
Get string representation of the node as token name,
node text, line number and column number.
|
private static java.lang.String |
parseAndPrintJavadocTree(DetailAST node)
Parses block comment as javadoc and prints its tree.
|
private static DetailAST |
parseFile(java.io.File file,
boolean withComments)
Parse a file and return the parse tree.
|
private static DetailAST |
parseFileText(FileText text,
boolean withComments)
Parse a text and return the parse tree.
|
static java.lang.String |
printAst(FileText text,
boolean withComments)
Parse a file and print the parse tree.
|
static java.lang.String |
printFileAst(java.io.File file,
boolean withComments)
Parse a file and print the parse tree.
|
private static java.lang.String |
printJavaAndJavadocTree(DetailAST ast)
Prints full tree (java + comments + javadoc) of the DetailAST.
|
static java.lang.String |
printJavaAndJavadocTree(java.io.File file)
Prints full AST (java + comments + javadoc) of the java file.
|
private static java.lang.String |
printTree(DetailAST ast)
Print AST.
|
private static final java.util.regex.Pattern NEWLINE
private static final java.util.regex.Pattern RETURN
private static final java.util.regex.Pattern TAB
private static final java.lang.String LINE_SEPARATOR
public static java.lang.String printFileAst(java.io.File file, boolean withComments) throws java.io.IOException, CheckstyleException
file
- the file to print.withComments
- true to include comments to ASTjava.io.IOException
- if the file could not be read.CheckstyleException
- if the file is not a Java source.public static java.lang.String printJavaAndJavadocTree(java.io.File file) throws java.io.IOException, CheckstyleException
file
- java filejava.io.IOException
- Failed to open a fileCheckstyleException
- error while parsing the fileprivate static java.lang.String printJavaAndJavadocTree(DetailAST ast)
ast
- root DetailASTprivate static java.lang.String parseAndPrintJavadocTree(DetailAST node)
node
- block comment beginpublic static java.lang.String printAst(FileText text, boolean withComments) throws CheckstyleException
text
- the text to parse.withComments
- true to include comments to ASTCheckstyleException
- if the file is not a Java source.private static java.lang.String printTree(DetailAST ast)
ast
- the root AST node.private static java.lang.String getNodeInfo(DetailAST node)
node
- DetailASTprivate static java.lang.String getIndentation(DetailAST ast)
ast
- the AST to get the indentation for.private static java.lang.String escapeAllControlChars(java.lang.String text)
text
- the String to process.private static DetailAST parseFile(java.io.File file, boolean withComments) throws java.io.IOException, CheckstyleException
file
- the file to parse.withComments
- true to include comment nodes to the treejava.io.IOException
- if the file could not be read.CheckstyleException
- if the file is not a Java source.private static DetailAST parseFileText(FileText text, boolean withComments) throws CheckstyleException
text
- the text to parse.withComments
- true to include comment nodes to the treeCheckstyleException
- if the file is not a Java source.