本文整理汇总了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();
}
}
示例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());
}
}
}
示例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;
}
示例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;
}