本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.ANNOTATION_ARRAY_INIT属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.ANNOTATION_ARRAY_INIT属性的具体用法?Java TokenTypes.ANNOTATION_ARRAY_INIT怎么用?Java TokenTypes.ANNOTATION_ARRAY_INIT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.ANNOTATION_ARRAY_INIT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkTrailingComma
/**
* Checks to see if the trailing comma is present if required or
* prohibited.
*
* @param annotation the annotation token
*/
private void checkTrailingComma(final DetailAST annotation) {
if (trailingArrayComma != TrailingArrayComma.IGNORE) {
DetailAST child = annotation.getFirstChild();
while (child != null) {
DetailAST arrayInit = null;
if (child.getType() == TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR) {
arrayInit = child.findFirstToken(TokenTypes.ANNOTATION_ARRAY_INIT);
}
else if (child.getType() == TokenTypes.ANNOTATION_ARRAY_INIT) {
arrayInit = child;
}
if (arrayInit != null) {
logCommaViolation(arrayInit);
}
child = child.getNextSibling();
}
}
}
示例2: getAnnotationValues
/**
* Returns the annotation values represented by an AST.
* @param ast an AST node for an EXPR or ANNOTATION_ARRAY_INIT
* @return the list of Java string represented by the given AST for an
* expression or annotation array initializer
* @throws IllegalArgumentException if the AST is invalid
*/
private static List<String> getAnnotationValues(DetailAST ast) {
final List<String> annotationValues;
switch (ast.getType()) {
case TokenTypes.EXPR:
annotationValues = Collections.singletonList(getStringExpr(ast));
break;
case TokenTypes.ANNOTATION_ARRAY_INIT:
annotationValues = findAllExpressionsInChildren(ast);
break;
default:
throw new IllegalArgumentException(
"Expression or annotation array initializer AST expected: " + ast);
}
return annotationValues;
}
示例3: getAllAnnotationValues
/**
* Get all annotation values.
* @param ast annotation token
* @return list values
*/
private static List<String> getAllAnnotationValues(DetailAST ast) {
// get values of annotation
List<String> values = null;
final DetailAST lparenAST = ast.findFirstToken(TokenTypes.LPAREN);
if (lparenAST != null) {
final DetailAST nextAST = lparenAST.getNextSibling();
final int nextType = nextAST.getType();
switch (nextType) {
case TokenTypes.EXPR:
case TokenTypes.ANNOTATION_ARRAY_INIT:
values = getAnnotationValues(nextAST);
break;
case TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR:
// expected children: IDENT ASSIGN ( EXPR |
// ANNOTATION_ARRAY_INIT )
values = getAnnotationValues(getNthChild(nextAST, 2));
break;
case TokenTypes.RPAREN:
// no value present (not valid Java)
break;
default:
// unknown annotation value type (new syntax?)
throw new IllegalArgumentException("Unexpected AST: " + nextAST);
}
}
return values;
}
示例4: isArrayInitialization
/**
* Is array initialization.
* @param currentType current token
* @param parentType parent token
* @return true is current token inside array initialization
*/
private static boolean isArrayInitialization(int currentType, int parentType) {
return (currentType == TokenTypes.RCURLY || currentType == TokenTypes.LCURLY)
&& (parentType == TokenTypes.ARRAY_INIT
|| parentType == TokenTypes.ANNOTATION_ARRAY_INIT);
}