本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.LITERAL_FALSE属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.LITERAL_FALSE属性的具体用法?Java TokenTypes.LITERAL_FALSE怎么用?Java TokenTypes.LITERAL_FALSE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.LITERAL_FALSE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateNonObjects
/**
* Checks for explicit initializations made to 'false', '0' and '\0'.
* @param ast token being checked for explicit initializations
*/
private void validateNonObjects(DetailAST ast) {
final DetailAST ident = ast.findFirstToken(TokenTypes.IDENT);
final DetailAST assign = ast.findFirstToken(TokenTypes.ASSIGN);
final DetailAST exprStart =
assign.getFirstChild().getFirstChild();
final DetailAST type = ast.findFirstToken(TokenTypes.TYPE);
final int primitiveType = type.getFirstChild().getType();
if (primitiveType == TokenTypes.LITERAL_BOOLEAN
&& exprStart.getType() == TokenTypes.LITERAL_FALSE) {
log(ident, MSG_KEY, ident.getText(), "false");
}
if (isNumericType(primitiveType) && isZero(exprStart)) {
log(ident, MSG_KEY, ident.getText(), "0");
}
if (primitiveType == TokenTypes.LITERAL_CHAR
&& isZeroChar(exprStart)) {
log(ident, MSG_KEY, ident.getText(), "\\0");
}
}
示例2: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.EXPR,
TokenTypes.IDENT,
TokenTypes.NUM_DOUBLE,
TokenTypes.NUM_FLOAT,
TokenTypes.NUM_INT,
TokenTypes.NUM_LONG,
TokenTypes.STRING_LITERAL,
TokenTypes.LITERAL_NULL,
TokenTypes.LITERAL_FALSE,
TokenTypes.LITERAL_TRUE,
TokenTypes.ASSIGN,
TokenTypes.BAND_ASSIGN,
TokenTypes.BOR_ASSIGN,
TokenTypes.BSR_ASSIGN,
TokenTypes.BXOR_ASSIGN,
TokenTypes.DIV_ASSIGN,
TokenTypes.MINUS_ASSIGN,
TokenTypes.MOD_ASSIGN,
TokenTypes.PLUS_ASSIGN,
TokenTypes.SL_ASSIGN,
TokenTypes.SR_ASSIGN,
TokenTypes.STAR_ASSIGN,
TokenTypes.LAMBDA,
};
}
示例3: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.EXPR,
TokenTypes.IDENT,
TokenTypes.NUM_DOUBLE,
TokenTypes.NUM_FLOAT,
TokenTypes.NUM_INT,
TokenTypes.NUM_LONG,
TokenTypes.STRING_LITERAL,
TokenTypes.LITERAL_NULL,
TokenTypes.LITERAL_FALSE,
TokenTypes.LITERAL_TRUE,
TokenTypes.ASSIGN,
TokenTypes.BAND_ASSIGN,
TokenTypes.BOR_ASSIGN,
TokenTypes.BSR_ASSIGN,
TokenTypes.BXOR_ASSIGN,
TokenTypes.DIV_ASSIGN,
TokenTypes.MINUS_ASSIGN,
TokenTypes.MOD_ASSIGN,
TokenTypes.PLUS_ASSIGN,
TokenTypes.SL_ASSIGN,
TokenTypes.SR_ASSIGN,
TokenTypes.STAR_ASSIGN,
TokenTypes.LAMBDA,
};
}
示例4: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {TokenTypes.LITERAL_TRUE, TokenTypes.LITERAL_FALSE};
}
示例5: isBooleanLiteralType
/**
* Checks if a token type is a literal true or false.
* @param tokenType the TokenType
* @return true iff tokenType is LITERAL_TRUE or LITERAL_FALSE
*/
private static boolean isBooleanLiteralType(final int tokenType) {
final boolean isTrue = tokenType == TokenTypes.LITERAL_TRUE;
final boolean isFalse = tokenType == TokenTypes.LITERAL_FALSE;
return isTrue || isFalse;
}