Package com.puppycrawl.tools.checkstyle
Class DetailNodeTreeStringPrinter
java.lang.Object
com.puppycrawl.tools.checkstyle.DetailNodeTreeStringPrinter
Parses file as javadoc DetailNode tree and prints to system output stream.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringgetIndentation(DetailNode node) Get indentation for a node.private static StringgetParseErrorMessage(JavadocDetailNodeParser.ParseErrorMessage parseErrorMessage) Builds violation base on ParseErrorMessage's violation key, its arguments, etc.private static DetailNodeParse a file and return the parse tree.static DetailNodeparseJavadocAsDetailNode(DetailAST blockComment) Parse block comment DetailAST as Javadoc DetailNode tree.private static DetailNodeparseJavadocAsDetailNode(String javadocComment) Parse javadoc comment to DetailNode tree.static StringprintFileAst(File file) Parse a file and print the parse tree.static StringprintTree(DetailNode ast, String rootPrefix, String prefix) Print AST.
-
Field Details
-
LINE_SEPARATOR
OS specific line separator.
-
-
Constructor Details
-
DetailNodeTreeStringPrinter
private DetailNodeTreeStringPrinter()Prevent instances.
-
-
Method Details
-
printFileAst
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
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
Parse javadoc comment to DetailNode tree.- Parameters:
javadocComment- javadoc comment content- Returns:
- tree
-
getParseErrorMessage
private static String getParseErrorMessage(JavadocDetailNodeParser.ParseErrorMessage parseErrorMessage) Builds violation base on ParseErrorMessage's violation key, its arguments, etc.- Parameters:
parseErrorMessage- ParseErrorMessage- Returns:
- error violation
-
printTree
Print AST.- Parameters:
ast- the root AST node.rootPrefix- prefix for the root nodeprefix- prefix for other nodes- Returns:
- string AST.
-
getIndentation
Get indentation for a node.- Parameters:
node- the DetailNode to get the indentation for.- Returns:
- the indentation in String format.
-
parseFile
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.
-