本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.FOR_EACH_CLAUSE属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.FOR_EACH_CLAUSE属性的具体用法?Java TokenTypes.FOR_EACH_CLAUSE怎么用?Java TokenTypes.FOR_EACH_CLAUSE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.FOR_EACH_CLAUSE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.OBJBLOCK,
TokenTypes.LITERAL_FOR,
TokenTypes.FOR_ITERATOR,
TokenTypes.FOR_EACH_CLAUSE,
TokenTypes.ASSIGN,
TokenTypes.PLUS_ASSIGN,
TokenTypes.MINUS_ASSIGN,
TokenTypes.STAR_ASSIGN,
TokenTypes.DIV_ASSIGN,
TokenTypes.MOD_ASSIGN,
TokenTypes.SR_ASSIGN,
TokenTypes.BSR_ASSIGN,
TokenTypes.SL_ASSIGN,
TokenTypes.BAND_ASSIGN,
TokenTypes.BXOR_ASSIGN,
TokenTypes.BOR_ASSIGN,
TokenTypes.INC,
TokenTypes.POST_INC,
TokenTypes.DEC,
TokenTypes.POST_DEC,
};
}
示例2: visitToken
@Override
public void visitToken(DetailAST ast) {
// don't flag interfaces
final DetailAST container = ast.getParent().getParent();
if (container.getType() != TokenTypes.INTERFACE_DEF) {
if (ast.getType() == TokenTypes.LITERAL_CATCH) {
visitCatch(ast);
}
else if (ast.getType() == TokenTypes.FOR_EACH_CLAUSE) {
visitForEachClause(ast);
}
else {
visitMethod(ast);
}
}
}
示例3: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.OBJBLOCK:
enterBlock();
break;
case TokenTypes.LITERAL_FOR:
case TokenTypes.FOR_ITERATOR:
case TokenTypes.FOR_EACH_CLAUSE:
//we need that Tokens only at leaveToken()
break;
case TokenTypes.ASSIGN:
case TokenTypes.PLUS_ASSIGN:
case TokenTypes.MINUS_ASSIGN:
case TokenTypes.STAR_ASSIGN:
case TokenTypes.DIV_ASSIGN:
case TokenTypes.MOD_ASSIGN:
case TokenTypes.SR_ASSIGN:
case TokenTypes.BSR_ASSIGN:
case TokenTypes.SL_ASSIGN:
case TokenTypes.BAND_ASSIGN:
case TokenTypes.BXOR_ASSIGN:
case TokenTypes.BOR_ASSIGN:
case TokenTypes.INC:
case TokenTypes.POST_INC:
case TokenTypes.DEC:
case TokenTypes.POST_DEC:
checkIdent(ast);
break;
default:
throw new IllegalStateException(ILLEGAL_TYPE_OF_TOKEN + ast);
}
}
示例4: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.LITERAL_CATCH,
TokenTypes.FOR_EACH_CLAUSE,
};
}
示例5: leaveToken
@Override
public void leaveToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.FOR_ITERATOR:
leaveForIter(ast.getParent());
break;
case TokenTypes.FOR_EACH_CLAUSE:
if (!skipEnhancedForLoopVariable) {
final DetailAST paramDef = ast.findFirstToken(TokenTypes.VARIABLE_DEF);
leaveForEach(paramDef);
}
break;
case TokenTypes.LITERAL_FOR:
if (!getCurrentVariables().isEmpty()) {
leaveForDef(ast);
}
break;
case TokenTypes.OBJBLOCK:
exitBlock();
break;
case TokenTypes.ASSIGN:
case TokenTypes.PLUS_ASSIGN:
case TokenTypes.MINUS_ASSIGN:
case TokenTypes.STAR_ASSIGN:
case TokenTypes.DIV_ASSIGN:
case TokenTypes.MOD_ASSIGN:
case TokenTypes.SR_ASSIGN:
case TokenTypes.BSR_ASSIGN:
case TokenTypes.SL_ASSIGN:
case TokenTypes.BAND_ASSIGN:
case TokenTypes.BXOR_ASSIGN:
case TokenTypes.BOR_ASSIGN:
case TokenTypes.INC:
case TokenTypes.POST_INC:
case TokenTypes.DEC:
case TokenTypes.POST_DEC:
//we need that Tokens only at visitToken()
break;
default:
throw new IllegalStateException(ILLEGAL_TYPE_OF_TOKEN + ast);
}
}
示例6: isForLoopVariable
/**
* Checks if a variable is the loop's one.
* @param variableDef variable definition.
* @return true if a variable is the loop's one.
*/
private static boolean isForLoopVariable(DetailAST variableDef) {
final int parentType = variableDef.getParent().getType();
return parentType == TokenTypes.FOR_INIT
|| parentType == TokenTypes.FOR_EACH_CLAUSE;
}
示例7: shouldCheckEnhancedForLoopVariable
/**
* Determines whether enhanced for-loop variable should be checked or not.
* @param ast The ast to compare.
* @return true if enhanced for-loop variable should be checked.
*/
private boolean shouldCheckEnhancedForLoopVariable(DetailAST ast) {
return validateEnhancedForLoopVariable
|| ast.getParent().getType() != TokenTypes.FOR_EACH_CLAUSE;
}
示例8: isColonOfForEach
/**
* Whether colon belongs to for-each.
* @param currentType current
* @param parentType parent
* @return true if current token in colon of for-each token
*/
private boolean isColonOfForEach(int currentType, int parentType) {
return currentType == TokenTypes.COLON
&& parentType == TokenTypes.FOR_EACH_CLAUSE
&& ignoreEnhancedForColon;
}