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


Java TokenTypes.COMMENT_CONTENT属性代码示例

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


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

示例1: convertToString

/**
 * Converts given AST node to string representation.
 * @param ast node to be represented as string
 * @return string representation of AST node
 */
private static String convertToString(DetailAST ast) {
    final String tokenText;
    switch (ast.getType()) {
        case TokenTypes.LABELED_STAT:
            tokenText = ast.getFirstChild().getText() + ast.getText();
            break;
        // multiline tokens need to become singlelined
        case TokenTypes.COMMENT_CONTENT:
            tokenText = JavadocUtils.escapeAllControlChars(ast.getText());
            break;
        default:
            tokenText = ast.getText();
            break;
    }
    return tokenText;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:IllegalTokenCheck.java

示例2: printJavaAndJavadocTree

/**
 * Prints full tree (java + comments + javadoc) of the DetailAST.
 * @param ast root DetailAST
 * @return Full tree
 */
private static String printJavaAndJavadocTree(DetailAST ast) {
    final StringBuilder messageBuilder = new StringBuilder(1024);
    DetailAST node = ast;
    while (node != null) {
        messageBuilder.append(getIndentation(node))
            .append(getNodeInfo(node))
            .append(LINE_SEPARATOR);
        if (node.getType() == TokenTypes.COMMENT_CONTENT
                && JavadocUtils.isJavadocComment(node.getParent())) {
            final String javadocTree = parseAndPrintJavadocTree(node);
            messageBuilder.append(javadocTree);
        }
        else {
            messageBuilder.append(printJavaAndJavadocTree(node.getFirstChild()));
        }
        node = node.getNextSibling();
    }
    return messageBuilder.toString();
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:24,代码来源:AstTreeStringPrinter.java

示例3: getChildCount

/**
 * Returns the number of children of parent.
 * @param parent the node to count children for.
 * @return the number of children of the node parent.
 */
public int getChildCount(Object parent) {
    final int result;

    if (parent instanceof DetailNode) {
        result = ((DetailNode) parent).getChildren().length;
    }
    else {
        if (parseMode == ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS
                && ((AST) parent).getType() == TokenTypes.COMMENT_CONTENT
                && JavadocUtils.isJavadocComment(((DetailAST) parent).getParent())) {
            //getChildCount return 0 on COMMENT_CONTENT,
            //but we need to attach javadoc tree, that is separate tree
            result = 1;
        }
        else {
            result = ((DetailAST) parent).getChildCount();
        }
    }

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

示例4: getChildAtDetailAst

/**
 * Gets child of DetailAST node at specified index.
 * @param parent DetailAST node
 * @param index child index
 * @return child DetailsAST or DetailNode if child is Javadoc node
 *         and parseMode is JAVA_WITH_JAVADOC_AND_COMMENTS.
 */
private Object getChildAtDetailAst(DetailAST parent, int index) {
    final Object result;
    if (parseMode == ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS
            && parent.getType() == TokenTypes.COMMENT_CONTENT
            && JavadocUtils.isJavadocComment(parent.getParent())) {
        result = getJavadocTree(parent.getParent());
    }
    else {
        int currentIndex = 0;
        DetailAST child = parent.getFirstChild();
        while (currentIndex < index) {
            child = child.getNextSibling();
            currentIndex++;
        }
        result = child;
    }

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

示例5: getAcceptableTokens

@Override
public int[] getAcceptableTokens() {
    return new int[] {
        TokenTypes.NUM_DOUBLE,
        TokenTypes.NUM_FLOAT,
        TokenTypes.NUM_INT,
        TokenTypes.NUM_LONG,
        TokenTypes.IDENT,
        TokenTypes.COMMENT_CONTENT,
        TokenTypes.STRING_LITERAL,
        TokenTypes.CHAR_LITERAL,
    };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:13,代码来源:IllegalTokenTextCheck.java

示例6: isDistributedExpression

/**
 * Checks whether the previous statement of a comment is a method call chain or
 * string concatenation statement distributed over two ore more lines.
 * @param comment comment to check.
 * @return true if the previous statement is a distributed expression.
 */
private boolean isDistributedExpression(DetailAST comment) {
    DetailAST previousSibling = comment.getPreviousSibling();
    while (previousSibling != null && isComment(previousSibling)) {
        previousSibling = previousSibling.getPreviousSibling();
    }
    boolean isDistributed = false;
    if (previousSibling != null) {
        if (previousSibling.getType() == TokenTypes.SEMI
                && isOnPreviousLineIgnoringComments(comment, previousSibling)) {
            DetailAST currentToken = previousSibling.getPreviousSibling();
            while (currentToken.getFirstChild() != null) {
                currentToken = currentToken.getFirstChild();
            }
            if (currentToken.getType() == TokenTypes.COMMENT_CONTENT) {
                currentToken = currentToken.getParent();
                while (isComment(currentToken)) {
                    currentToken = currentToken.getNextSibling();
                }
            }
            if (previousSibling.getLineNo() != currentToken.getLineNo()) {
                isDistributed = true;
            }
        }
        else {
            isDistributed = isStatementWithPossibleCurlies(previousSibling);
        }
    }
    return isDistributed;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:35,代码来源:CommentsIndentationCheck.java

示例7: isComment

/**
 * Whether the ast is a comment.
 * @param ast the ast to check.
 * @return true if the ast is a comment.
 */
private static boolean isComment(DetailAST ast) {
    final int astType = ast.getType();
    return astType == TokenTypes.SINGLE_LINE_COMMENT
        || astType == TokenTypes.BLOCK_COMMENT_BEGIN
        || astType == TokenTypes.COMMENT_CONTENT
        || astType == TokenTypes.BLOCK_COMMENT_END;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:12,代码来源:CommentsIndentationCheck.java

示例8: testGetRequiredTokens

@Test
public void testGetRequiredTokens() {
    final TodoCommentCheck checkObj = new TodoCommentCheck();
    final int[] expected = {TokenTypes.COMMENT_CONTENT};
    assertArrayEquals("Required tokens differs from expected",
            expected, checkObj.getRequiredTokens());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:7,代码来源:TodoCommentCheckTest.java

示例9: testGetAcceptableTokens

@Test
public void testGetAcceptableTokens() {
    final int[] expected = {TokenTypes.COMMENT_CONTENT };
    final TodoCommentCheck check = new TodoCommentCheck();
    final int[] actual = check.getAcceptableTokens();
    assertEquals("Amount of acceptable tokens differs from expected",
            1, actual.length);
    assertArrayEquals("Acceptable tokens differs from expected",
            expected, actual);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:10,代码来源:TodoCommentCheckTest.java

示例10: testGetTokenNameWithGreatestPossibleId

@Test
public void testGetTokenNameWithGreatestPossibleId() {
    final Integer id = TokenTypes.COMMENT_CONTENT;
    final String tokenName = TokenUtils.getTokenName(id);

    assertEquals("Invalid token name", "COMMENT_CONTENT", tokenName);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:7,代码来源:TokenUtilsTest.java

示例11: getRequiredTokens

@Override
public int[] getRequiredTokens() {
    return new int[] {TokenTypes.COMMENT_CONTENT };
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:4,代码来源:TodoCommentCheck.java

示例12: isCommentType

/**
 * Is argument comment-related type (SINGLE_LINE_COMMENT,
 * BLOCK_COMMENT_BEGIN, BLOCK_COMMENT_END, COMMENT_CONTENT).
 * @param type
 *        token type.
 * @return true if type is comment-related type.
 */
public static boolean isCommentType(int type) {
    return type == TokenTypes.SINGLE_LINE_COMMENT
            || type == TokenTypes.BLOCK_COMMENT_BEGIN
            || type == TokenTypes.BLOCK_COMMENT_END
            || type == TokenTypes.COMMENT_CONTENT;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:13,代码来源:TokenUtils.java


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