本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.TYPECAST属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.TYPECAST属性的具体用法?Java TokenTypes.TYPECAST怎么用?Java TokenTypes.TYPECAST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.TYPECAST属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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,
};
}
示例2: visitToken
@Override
public void visitToken(DetailAST ast) {
DetailAST nodeWithAnnotations = ast;
if (ast.getType() == TokenTypes.TYPECAST) {
nodeWithAnnotations = ast.findFirstToken(TokenTypes.TYPE);
}
DetailAST modifiersNode = nodeWithAnnotations.findFirstToken(TokenTypes.MODIFIERS);
if (modifiersNode == null) {
modifiersNode = nodeWithAnnotations.findFirstToken(TokenTypes.ANNOTATIONS);
}
if (modifiersNode != null) {
for (DetailAST annotationNode = modifiersNode.getFirstChild();
annotationNode != null;
annotationNode = annotationNode.getNextSibling()) {
if (annotationNode.getType() == TokenTypes.ANNOTATION
&& annotationNode.getLineNo() != getNextNode(annotationNode).getLineNo()) {
log(annotationNode.getLineNo(), MSG_KEY_ANNOTATION_ON_SAME_LINE,
getAnnotationName(annotationNode));
}
}
}
}
示例3: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.ARRAY_INIT,
TokenTypes.AT,
TokenTypes.INC,
TokenTypes.DEC,
TokenTypes.UNARY_MINUS,
TokenTypes.UNARY_PLUS,
TokenTypes.BNOT,
TokenTypes.LNOT,
TokenTypes.DOT,
TokenTypes.TYPECAST,
TokenTypes.ARRAY_DECLARATOR,
TokenTypes.INDEX_OP,
TokenTypes.LITERAL_SYNCHRONIZED,
TokenTypes.METHOD_REF,
};
}
示例4: getWhitespaceFollowedNode
/**
* For a visited ast node returns node that should be checked
* for not being followed by whitespace.
* @param ast
* , visited node.
* @return node before ast.
*/
private static DetailAST getWhitespaceFollowedNode(DetailAST ast) {
final DetailAST whitespaceFollowedAst;
switch (ast.getType()) {
case TokenTypes.TYPECAST:
whitespaceFollowedAst = ast.findFirstToken(TokenTypes.RPAREN);
break;
case TokenTypes.ARRAY_DECLARATOR:
whitespaceFollowedAst = getArrayDeclaratorPreviousElement(ast);
break;
case TokenTypes.INDEX_OP:
whitespaceFollowedAst = getIndexOpPreviousElement(ast);
break;
default:
whitespaceFollowedAst = ast;
}
return whitespaceFollowedAst;
}
示例5: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final AnnotationLocationCheck constantNameCheckObj = new AnnotationLocationCheck();
final int[] actual = constantNameCheckObj.getAcceptableTokens();
final int[] expected = {
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,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例6: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final AnnotationOnSameLineCheck constantNameCheckObj = new AnnotationOnSameLineCheck();
final int[] actual = constantNameCheckObj.getAcceptableTokens();
final int[] expected = {
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,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例7: 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,
};
}
示例8: visitToken
@Override
public void visitToken(DetailAST ast) {
// Strange logic in this method to guard against checking RPAREN tokens
// that are not associated with a TYPECAST token.
if (ast.getType() == TokenTypes.TYPECAST) {
processLeft(ast);
}
else if (ast.getParent().getType() == TokenTypes.TYPECAST
&& ast.getParent().findFirstToken(TokenTypes.RPAREN) == ast) {
processRight(ast);
}
}
示例9: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.COMMA,
TokenTypes.SEMI,
TokenTypes.TYPECAST,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_FOR,
TokenTypes.DO_WHILE,
};
}
示例10: isInTypecast
/**
* Checks whether {@link TokenTypes#RPAREN} is a closing paren
* of a {@link TokenTypes#TYPECAST}.
* @param ast of a {@link TokenTypes#RPAREN} to check.
* @return true if ast is a closing paren of a {@link TokenTypes#TYPECAST}.
*/
private static boolean isInTypecast(DetailAST ast) {
boolean result = false;
if (ast.getParent().getType() == TokenTypes.TYPECAST) {
final DetailAST firstRparen = ast.getParent().findFirstToken(TokenTypes.RPAREN);
if (firstRparen.getLineNo() == ast.getLineNo()
&& firstRparen.getColumnNo() == ast.getColumnNo()) {
result = true;
}
}
return result;
}
示例11: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final TypecastParenPadCheck typecastParenPadCheckObj = new TypecastParenPadCheck();
final int[] actual = typecastParenPadCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.RPAREN,
TokenTypes.TYPECAST,
};
Assert.assertArrayEquals("Invalid acceptable tokens", expected, actual);
}
示例12: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {TokenTypes.RPAREN, TokenTypes.TYPECAST};
}