use of com.puppycrawl.tools.checkstyle.api.DetailNode in project checkstyle by checkstyle.
the class ParseTreeTablePresentation method getJavadocTree.
/**
* Gets Javadoc (DetailNode) tree of specified block comments.
* @param blockComment Javadoc comment as a block comment
* @return DetailNode tree
*/
private DetailNode getJavadocTree(DetailAST blockComment) {
DetailNode javadocTree = blockCommentToJavadocTree.get(blockComment);
if (javadocTree == null) {
javadocTree = new JavadocDetailNodeParser().parseJavadocAsDetailNode(blockComment).getTree();
blockCommentToJavadocTree.put(blockComment, javadocTree);
}
return javadocTree;
}
use of com.puppycrawl.tools.checkstyle.api.DetailNode in project checkstyle by checkstyle.
the class JavadocUtils method getPreviousSibling.
/**
* Gets previous sibling of specified node.
* @param node DetailNode
* @return previous sibling
*/
public static DetailNode getPreviousSibling(DetailNode node) {
final DetailNode parent = node.getParent();
final int previousSiblingIndex = node.getIndex() - 1;
final DetailNode[] children = parent.getChildren();
if (previousSiblingIndex >= 0) {
return children[previousSiblingIndex];
}
return null;
}
use of com.puppycrawl.tools.checkstyle.api.DetailNode in project checkstyle by checkstyle.
the class JavadocUtils method findFirstToken.
/**
* Returns the first child token that has a specified type.
* @param detailNode
* Javadoc AST node
* @param type
* the token type to match
* @return the matching token, or null if no match
*/
public static DetailNode findFirstToken(DetailNode detailNode, int type) {
DetailNode returnValue = null;
DetailNode node = getFirstChild(detailNode);
while (node != null) {
if (node.getType() == type) {
returnValue = node;
break;
}
node = getNextSibling(node);
}
return returnValue;
}
use of com.puppycrawl.tools.checkstyle.api.DetailNode in project contribution by checkstyle.
the class JavadocTreePrinter method printTree.
public static void printTree(DetailNode aRoot) {
if (aRoot.getChildren().length != 0) {
for (DetailNode node : aRoot.getChildren()) {
System.out.println(getLevel(node) + node.toString() + " : [" + node.getText().replaceAll("\n", "\\\\n").replaceAll("\r", "\\\\r").replaceAll("\t", "\\\\t") + "]");
if (node.getType() == JavadocTokenTypes.TEXT) {
continue;
}
printTree(node);
}
}
}
use of com.puppycrawl.tools.checkstyle.api.DetailNode in project checkstyle by checkstyle.
the class JavadocDetailNodeParser method adjustFirstLineToJavadocIndent.
/**
* Adjust first line nodes to javadoc indent.
*
* @param tree DetailNode tree root
* @param javadocColumnNumber javadoc indent
*/
private void adjustFirstLineToJavadocIndent(DetailNode tree, int javadocColumnNumber) {
if (tree.getLineNumber() == blockCommentLineNumber) {
((JavadocNodeImpl) tree).setColumnNumber(tree.getColumnNumber() + javadocColumnNumber);
final DetailNode[] children = tree.getChildren();
for (DetailNode child : children) {
adjustFirstLineToJavadocIndent(child, javadocColumnNumber);
}
}
}
Aggregations