Search in sources :

Example 1 with DetailNode

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;
}
Also used : JavadocDetailNodeParser(com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser) DetailNode(com.puppycrawl.tools.checkstyle.api.DetailNode)

Example 2 with DetailNode

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;
}
Also used : DetailNode(com.puppycrawl.tools.checkstyle.api.DetailNode)

Example 3 with DetailNode

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;
}
Also used : DetailNode(com.puppycrawl.tools.checkstyle.api.DetailNode)

Example 4 with DetailNode

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);
        }
    }
}
Also used : DetailNode(com.puppycrawl.tools.checkstyle.api.DetailNode)

Example 5 with DetailNode

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);
        }
    }
}
Also used : DetailNode(com.puppycrawl.tools.checkstyle.api.DetailNode) JavadocNodeImpl(com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocNodeImpl)

Aggregations

DetailNode (com.puppycrawl.tools.checkstyle.api.DetailNode)48 Test (org.junit.jupiter.api.Test)7 DetailAST (com.puppycrawl.tools.checkstyle.api.DetailAST)5 JavadocNodeImpl (com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocNodeImpl)4 ArrayDeque (java.util.ArrayDeque)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 Matcher (java.util.regex.Matcher)2 FileStatefulCheck (com.puppycrawl.tools.checkstyle.FileStatefulCheck)1 JavadocDetailNodeParser (com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser)1 JavadocTokenTypes (com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes)1 TokenTypes (com.puppycrawl.tools.checkstyle.api.TokenTypes)1 AbstractJavadocCheck (com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck)1 JavadocParser (com.puppycrawl.tools.checkstyle.grammar.javadoc.JavadocParser)1 TokenUtil (com.puppycrawl.tools.checkstyle.utils.TokenUtil)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Deque (java.util.Deque)1 HashMap (java.util.HashMap)1