本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.ANNOTATION_DEF属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.ANNOTATION_DEF属性的具体用法?Java TokenTypes.ANNOTATION_DEF怎么用?Java TokenTypes.ANNOTATION_DEF使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.ANNOTATION_DEF属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInBlockOf
/**
* Returns whether a node is directly contained within a specified block.
*
* @param node the node to check if directly contained within a specified block.
* @param tokenType type of token.
* @return a {@code boolean} value
*/
private static boolean isInBlockOf(DetailAST node, int tokenType) {
boolean returnValue = false;
// Loop up looking for a containing interface block
for (DetailAST token = node.getParent();
token != null && !returnValue;
token = token.getParent()) {
final int type = token.getType();
if (type == tokenType) {
returnValue = true;
}
else if (type == TokenTypes.CLASS_DEF
|| type == TokenTypes.ENUM_DEF
|| type == TokenTypes.INTERFACE_DEF
|| type == TokenTypes.ANNOTATION_DEF
|| type == TokenTypes.LITERAL_NEW) {
break;
}
}
return returnValue;
}
示例2: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.TYPECAST,
TokenTypes.LITERAL_THROWS,
TokenTypes.IMPLEMENTS_CLAUSE,
TokenTypes.TYPE_ARGUMENT,
TokenTypes.LITERAL_NEW,
TokenTypes.DOT,
TokenTypes.ANNOTATION_FIELD_DEF,
};
}
示例3: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final UnusedImportsCheck testCheckObject =
new UnusedImportsCheck();
final int[] actual = testCheckObject.getAcceptableTokens();
final int[] expected = {
TokenTypes.IDENT,
TokenTypes.IMPORT,
TokenTypes.STATIC_IMPORT,
// Definitions that may contain Javadoc...
TokenTypes.PACKAGE_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例4: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final MethodCountCheck methodCountCheckObj =
new MethodCountCheck();
final int[] actual = methodCountCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.CLASS_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.METHOD_DEF,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例5: testVersions
@Test
public void testVersions() {
final DetailAST ast = new DetailAST();
final int[] validTypes = {
TokenTypes.PACKAGE_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ANNOTATION_DEF,
};
for (int type: validTypes) {
ast.setType(type);
assertTrue("Invalid ast type for current tag: " + ast.getType(),
JavadocTagInfo.VERSION.isValidOn(ast));
}
ast.setType(TokenTypes.LAMBDA);
assertFalse("Should return false when ast type is invalid for current tag",
JavadocTagInfo.VERSION.isValidOn(ast));
}
示例6: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IDENT :
processIdent(ast);
break;
case TokenTypes.CLASS_DEF :
case TokenTypes.INTERFACE_DEF :
case TokenTypes.ENUM_DEF :
case TokenTypes.ANNOTATION_DEF :
case TokenTypes.SLIST :
case TokenTypes.METHOD_DEF :
case TokenTypes.CTOR_DEF :
case TokenTypes.LITERAL_FOR :
current.push(frames.get(ast));
break;
default :
// do nothing
}
}
示例7: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final MissingDeprecatedCheck checkObj = new MissingDeprecatedCheck();
final int[] expected = {
TokenTypes.INTERFACE_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
}
示例8: testAuthor
@Test
public void testAuthor() {
final DetailAST ast = new DetailAST();
final int[] validTypes = {
TokenTypes.PACKAGE_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ANNOTATION_DEF,
};
for (int type: validTypes) {
ast.setType(type);
assertTrue("Invalid ast type for current tag: " + ast.getType(),
JavadocTagInfo.AUTHOR.isValidOn(ast));
}
ast.setType(TokenTypes.LAMBDA);
assertFalse("Should return false when ast type is invalid for current tag",
JavadocTagInfo.AUTHOR.isValidOn(ast));
}
示例9: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final UnusedImportsCheck testCheckObject =
new UnusedImportsCheck();
final int[] actual = testCheckObject.getRequiredTokens();
final int[] expected = {
TokenTypes.IDENT,
TokenTypes.IMPORT,
TokenTypes.STATIC_IMPORT,
// Definitions that may contain Javadoc...
TokenTypes.PACKAGE_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
};
assertArrayEquals("Default required tokens are invalid", expected, actual);
}
示例10: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final OuterTypeNumberCheck checkObj = new OuterTypeNumberCheck();
final int[] expected = {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ANNOTATION_DEF,
};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
}
示例11: getAcceptableTokens
@Override
public final int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
};
}
示例12: leaveToken
@Override
public void leaveToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.CLASS_DEF:
case TokenTypes.INTERFACE_DEF:
case TokenTypes.ANNOTATION_DEF:
case TokenTypes.ENUM_DEF:
leaveClassDef();
break;
default:
// Do nothing
}
}
示例13: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.PACKAGE_DEF,
TokenTypes.IMPORT,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.TYPE,
TokenTypes.LITERAL_NEW,
TokenTypes.LITERAL_THROWS,
TokenTypes.ANNOTATION_DEF,
};
}
示例14: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.ANNOTATION_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.PACKAGE_DEF,
TokenTypes.VARIABLE_DEF,
};
}
示例15: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.METHOD_DEF,
};
}