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


Java TokenTypes.ANNOTATIONS属性代码示例

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


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

示例1: checkAnnotationIndentation

/**
 * Checks line wrapping into annotations.
 *
 * @param atNode at-clause node.
 * @param firstNodesOnLines map which contains
 *     first nodes as values and line numbers as keys.
 * @param indentLevel line wrapping indentation.
 */
private void checkAnnotationIndentation(DetailAST atNode,
        NavigableMap<Integer, DetailAST> firstNodesOnLines, int indentLevel) {
    final int firstNodeIndent = getLineStart(atNode);
    final int currentIndent = firstNodeIndent + indentLevel;
    final Collection<DetailAST> values = firstNodesOnLines.values();
    final DetailAST lastAnnotationNode = atNode.getParent().getLastChild();
    final int lastAnnotationLine = lastAnnotationNode.getLineNo();

    final Iterator<DetailAST> itr = values.iterator();
    while (firstNodesOnLines.size() > 1) {
        final DetailAST node = itr.next();

        final DetailAST parentNode = node.getParent();
        final boolean isCurrentNodeCloseAnnotationAloneInLine =
            node.getLineNo() == lastAnnotationLine
                && isEndOfScope(lastAnnotationNode, node);
        if (isCurrentNodeCloseAnnotationAloneInLine
                || node.getType() == TokenTypes.AT
                && (parentNode.getParent().getType() == TokenTypes.MODIFIERS
                    || parentNode.getParent().getType() == TokenTypes.ANNOTATIONS)
                || node.getLineNo() == atNode.getLineNo()) {
            logWarningMessage(node, firstNodeIndent);
        }
        else {
            logWarningMessage(node, currentIndent);
        }
        itr.remove();
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:37,代码来源:LineWrappingHandler.java

示例2: visitToken

@Override
public void visitToken(DetailAST ast) {
    final DetailAST whitespaceFollowedAst = getWhitespaceFollowedNode(ast);

    if (whitespaceFollowedAst.getNextSibling() == null
            || whitespaceFollowedAst.getNextSibling().getType() != TokenTypes.ANNOTATIONS) {
        final int whitespaceColumnNo = getPositionAfter(whitespaceFollowedAst);
        final int whitespaceLineNo = whitespaceFollowedAst.getLineNo();

        if (hasTrailingWhitespace(ast, whitespaceColumnNo, whitespaceLineNo)) {
            log(whitespaceLineNo, whitespaceColumnNo,
                    MSG_KEY, whitespaceFollowedAst.getText());
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:15,代码来源:NoWhitespaceAfterCheck.java

示例3: getAnnotationTarget

/**
 * Get target of annotation.
 * @param ast the AST node to get the child of
 * @return get target of annotation
 */
private static DetailAST getAnnotationTarget(DetailAST ast) {
    final DetailAST targetAST;
    final DetailAST parentAST = ast.getParent();
    switch (parentAST.getType()) {
        case TokenTypes.MODIFIERS:
        case TokenTypes.ANNOTATIONS:
            targetAST = getAcceptableParent(parentAST);
            break;
        default:
            // unexpected container type
            throw new IllegalArgumentException("Unexpected container AST: " + parentAST);
    }
    return targetAST;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:19,代码来源:SuppressWarningsHolder.java

示例4: isOnEnumConstant

/**
 * Node is on enum constant.
 * @param blockComment DetailAST
 * @return true if node is before enum constant
 */
public static boolean isOnEnumConstant(DetailAST blockComment) {
    final boolean isOnPlainConst = blockComment.getParent() != null
            && blockComment.getParent().getType() == TokenTypes.ENUM_CONSTANT_DEF
            && getPrevSiblingSkipComments(blockComment).getType() == TokenTypes.ANNOTATIONS
            && getPrevSiblingSkipComments(blockComment).getChildCount() == 0;
    final boolean isOnConstWithAnnotation = !isOnPlainConst && blockComment.getParent() != null
            && blockComment.getParent().getType() == TokenTypes.ANNOTATION
            && blockComment.getParent().getParent().getParent().getType()
                == TokenTypes.ENUM_CONSTANT_DEF;
    return isOnPlainConst || isOnConstWithAnnotation;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:BlockCommentPosition.java


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