当前位置: 首页>>代码示例>>Java>>正文


Java DetailNode.getChildren方法代码示例

本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.DetailNode.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java DetailNode.getChildren方法的具体用法?Java DetailNode.getChildren怎么用?Java DetailNode.getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.puppycrawl.tools.checkstyle.api.DetailNode的用法示例。


在下文中一共展示了DetailNode.getChildren方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startsWithInheritDoc

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
 * Checks if the node starts with an {@inheritDoc}.
 * @param root The root node to examine.
 * @return {@code true} if the javadoc starts with an {@inheritDoc}.
 */
private static boolean startsWithInheritDoc(DetailNode root) {
    boolean found = false;
    final DetailNode[] children = root.getChildren();

    for (int i = 0; !found && i < children.length - 1; i++) {
        final DetailNode child = children[i];
        if (child.getType() == JavadocTokenTypes.JAVADOC_INLINE_TAG
                && child.getChildren()[1].getType() == JavadocTokenTypes.INHERIT_DOC_LITERAL) {
            found = true;
        }
        else if (child.getType() != JavadocTokenTypes.LEADING_ASTERISK
                && !CommonUtils.isBlank(child.getText())) {
            break;
        }
    }

    return found;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:SummaryJavadocCheck.java

示例2: getSummarySentence

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
 * Checks if period is at the end of sentence.
 * @param ast Javadoc root node.
 * @return error string
 */
private static String getSummarySentence(DetailNode ast) {
    boolean flag = true;
    final StringBuilder result = new StringBuilder(256);
    for (DetailNode child : ast.getChildren()) {
        if (ALLOWED_TYPES.contains(child.getType())) {
            result.append(child.getText());
        }
        else if (child.getType() == JavadocTokenTypes.HTML_ELEMENT
                && CommonUtils.isBlank(result.toString().trim())) {
            result.append(getStringInsideTag(result.toString(),
                    child.getChildren()[0].getChildren()[0]));
        }
        else if (child.getType() == JavadocTokenTypes.JAVADOC_TAG) {
            flag = false;
        }
        if (!flag) {
            break;
        }
    }
    return result.toString().trim();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:27,代码来源:SummaryJavadocCheck.java

示例3: getFirstSentence

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
 * Finds and returns first sentence.
 * @param ast Javadoc root node.
 * @return first sentence.
 */
private static String getFirstSentence(DetailNode ast) {
    final StringBuilder result = new StringBuilder(256);
    final String periodSuffix = PERIOD + ' ';
    for (DetailNode child : ast.getChildren()) {
        final String text;
        if (child.getChildren().length == 0) {
            text = child.getText();
        }
        else {
            text = getFirstSentence(child);
        }

        if (child.getType() != JavadocTokenTypes.JAVADOC_INLINE_TAG
            && text.contains(periodSuffix)) {
            result.append(text.substring(0, text.indexOf(periodSuffix) + 1));
            break;
        }
        else {
            result.append(text);
        }
    }
    return result.toString();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:29,代码来源:SummaryJavadocCheck.java

示例4: checkOrderInTagSection

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
 * Checks order of atclauses in tag section node.
 * @param javadoc Javadoc root node.
 */
private void checkOrderInTagSection(DetailNode javadoc) {
    int maxIndexOfPreviousTag = 0;

    for (DetailNode node : javadoc.getChildren()) {
        if (node.getType() == JavadocTokenTypes.JAVADOC_TAG) {
            final String tagText = JavadocUtils.getFirstChild(node).getText();
            final int indexOfCurrentTag = tagOrder.indexOf(tagText);

            if (indexOfCurrentTag != -1) {
                if (indexOfCurrentTag < maxIndexOfPreviousTag) {
                    log(node.getLineNumber(), MSG_KEY, tagOrder.toString());
                }
                else {
                    maxIndexOfPreviousTag = indexOfCurrentTag;
                }
            }
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:AtclauseOrderCheck.java

示例5: printTree

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
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);
        }
    }
}
 
开发者ID:checkstyle,项目名称:contribution,代码行数:20,代码来源:JavadocTreePrinter.java

示例6: getFirstChild

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
 * Gets first child node of specified node.
 *
 * @param node DetailNode
 * @return first child
 */
public static DetailNode getFirstChild(DetailNode node) {
    DetailNode resultNode = null;

    if (node.getChildren().length > 0) {
        resultNode = node.getChildren()[0];
    }
    return resultNode;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:15,代码来源:JavadocUtils.java

示例7: getNextSibling

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
 * Gets next sibling of specified node.
 *
 * @param node DetailNode
 * @return next sibling.
 */
public static DetailNode getNextSibling(DetailNode node) {
    DetailNode nextSibling = null;
    final DetailNode parent = node.getParent();
    if (parent != null) {
        final int nextSiblingIndex = node.getIndex() + 1;
        final DetailNode[] children = parent.getChildren();
        if (nextSiblingIndex <= children.length - 1) {
            nextSibling = children[nextSiblingIndex];
        }
    }
    return nextSibling;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:JavadocUtils.java

示例8: getPreviousSibling

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
 * Gets previous sibling of specified node.
 * @param node DetailNode
 * @return previous sibling
 */
public static DetailNode getPreviousSibling(DetailNode node) {
    DetailNode previousSibling = null;
    final int previousSiblingIndex = node.getIndex() - 1;
    if (previousSiblingIndex >= 0) {
        final DetailNode parent = node.getParent();
        final DetailNode[] children = parent.getChildren();
        previousSibling = children[previousSiblingIndex];
    }
    return previousSibling;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:JavadocUtils.java

示例9: adjustFirstLineToJavadocIndent

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:15,代码来源:JavadocDetailNodeParser.java

示例10: findLastPosition

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
/**
 * Finds the last position of node without children.
 * @param detailNode DetailNode node.
 * @return Last position of node without children.
 */
private int findLastPosition(final DetailNode detailNode) {
    final int lastPosition;
    if (detailNode.getChildren().length == 0) {
        lastPosition = lines2position.get(detailNode.getLineNumber())
                + detailNode.getColumnNumber() + detailNode.getText().length();
    }
    else {
        final DetailNode lastChild =
                detailNode.getChildren()[detailNode.getChildren().length - 1];
        lastPosition = findLastPosition(lastChild);
    }
    return lastPosition;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:CodeSelectorPresentation.java

示例11: testDetailNodeLeafSelection

import com.puppycrawl.tools.checkstyle.api.DetailNode; //导入方法依赖的package包/类
@Test
public void testDetailNodeLeafSelection() {
    final DetailNode javadoc = (DetailNode) model.getParseTreeTableModel()
            .getChild(tree.getFirstChild().getNextSibling().getFirstChild(), 0);
    final DetailNode javadocLeaf = javadoc.getChildren()[2];
    final CodeSelectorPresentation selector = new CodeSelectorPresentation(javadocLeaf,
            linesToPosition);
    selector.findSelectionPositions();
    Assert.assertEquals("Invalid selection start", 5, selector.getSelectionStart());
    Assert.assertEquals("Invalid selection end", 19, selector.getSelectionEnd());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:12,代码来源:CodeSelectorPresentationTest.java


注:本文中的com.puppycrawl.tools.checkstyle.api.DetailNode.getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。