本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.LITERAL_FOR属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.LITERAL_FOR属性的具体用法?Java TokenTypes.LITERAL_FOR怎么用?Java TokenTypes.LITERAL_FOR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.LITERAL_FOR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final CyclomaticComplexityCheck cyclomaticComplexityCheckObj =
new CyclomaticComplexityCheck();
final int[] actual = cyclomaticComplexityCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.INSTANCE_INIT,
TokenTypes.STATIC_INIT,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_CASE,
TokenTypes.LITERAL_CATCH,
TokenTypes.QUESTION,
TokenTypes.LAND,
TokenTypes.LOR,
};
Assert.assertArrayEquals("Invalid acceptable tokens", expected, actual);
}
示例2: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.STATIC_INIT,
TokenTypes.INSTANCE_INIT,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_SWITCH,
TokenTypes.CASE_GROUP,
TokenTypes.LITERAL_TRY,
TokenTypes.LITERAL_CATCH,
TokenTypes.QUESTION,
TokenTypes.LITERAL_RETURN,
TokenTypes.LITERAL_DEFAULT,
};
}
示例3: makeAcceptableTokens
/**
* Returns array of acceptable tokens.
* @return acceptableTokens.
*/
private static int[] makeAcceptableTokens() {
return new int[] {TokenTypes.ANNOTATION,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.CTOR_CALL,
TokenTypes.CTOR_DEF,
TokenTypes.DOT,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.EXPR,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_NEW,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_SYNCHRONIZED,
TokenTypes.LITERAL_WHILE,
TokenTypes.METHOD_CALL,
TokenTypes.METHOD_DEF,
TokenTypes.QUESTION,
TokenTypes.RESOURCE_SPECIFICATION,
TokenTypes.SUPER_CTOR_CALL,
TokenTypes.LAMBDA,
};
}
示例4: 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
}
}
示例5: leaveToken
@Override
public void leaveToken(DetailAST ast) {
switch (ast.getType()) {
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.pop();
break;
default :
// do nothing
}
}
示例6: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.INTERFACE_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_TRY,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_FINALLY,
TokenTypes.LITERAL_SYNCHRONIZED,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_FOR,
TokenTypes.STATIC_INIT,
TokenTypes.OBJBLOCK,
TokenTypes.LAMBDA,
};
}
示例7: 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,
};
}
示例8: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_TRY,
TokenTypes.LITERAL_FINALLY,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_FOR,
TokenTypes.INSTANCE_INIT,
TokenTypes.STATIC_INIT,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_SYNCHRONIZED,
};
}
示例9: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_CASE,
TokenTypes.LITERAL_DEFAULT,
TokenTypes.LAMBDA,
};
}
示例10: leaveToken
@Override
public void leaveToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.LITERAL_WHILE:
case TokenTypes.LITERAL_DO:
case TokenTypes.LITERAL_FOR:
case TokenTypes.LITERAL_IF:
case TokenTypes.LITERAL_SWITCH:
leaveConditional();
break;
case TokenTypes.LITERAL_TRY:
leaveMultiplyingConditional();
break;
case TokenTypes.LITERAL_RETURN:
case TokenTypes.QUESTION:
leaveUnitaryOperator();
break;
case TokenTypes.LITERAL_CATCH:
leaveAddingConditional();
break;
case TokenTypes.LITERAL_DEFAULT:
leaveBranch();
break;
case TokenTypes.LITERAL_ELSE:
case TokenTypes.CASE_GROUP:
leaveBranch();
branchVisited = false;
break;
case TokenTypes.CTOR_DEF:
case TokenTypes.METHOD_DEF:
case TokenTypes.INSTANCE_INIT:
case TokenTypes.STATIC_INIT:
leaveMethodDef(ast);
break;
default:
break;
}
}
示例11: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.LITERAL_FOR,
TokenTypes.SLIST,
TokenTypes.IDENT,
};
}
示例12: getDetails
/**
* Collects validation Details.
* @param ast a {@code DetailAST} value
* @return object containing all details to make a validation
*/
private static Details getDetails(DetailAST ast) {
final Details details;
switch (ast.getType()) {
case TokenTypes.LITERAL_TRY:
case TokenTypes.LITERAL_CATCH:
case TokenTypes.LITERAL_FINALLY:
details = getDetailsForTryCatchFinally(ast);
break;
case TokenTypes.LITERAL_IF:
case TokenTypes.LITERAL_ELSE:
details = getDetailsForIfElse(ast);
break;
case TokenTypes.LITERAL_DO:
case TokenTypes.LITERAL_WHILE:
case TokenTypes.LITERAL_FOR:
details = getDetailsForLoops(ast);
break;
case TokenTypes.LAMBDA:
details = getDetailsForLambda(ast);
break;
default:
details = getDetailsForOthers(ast);
break;
}
return details;
}
示例13: isStatementWithPossibleCurlies
/**
* Whether the statement can have or always have curly brackets.
* @param previousSibling the statement to check.
* @return true if the statement can have or always have curly brackets.
*/
private static boolean isStatementWithPossibleCurlies(DetailAST previousSibling) {
return previousSibling.getType() == TokenTypes.LITERAL_IF
|| previousSibling.getType() == TokenTypes.LITERAL_TRY
|| previousSibling.getType() == TokenTypes.LITERAL_FOR
|| previousSibling.getType() == TokenTypes.LITERAL_DO
|| previousSibling.getType() == TokenTypes.LITERAL_WHILE
|| previousSibling.getType() == TokenTypes.LITERAL_SWITCH
|| isDefinition(previousSibling);
}
示例14: getDistToVariableUsageInChildNode
/**
* Returns the distance to variable usage for in the child node.
* @param childNode child node.
* @param varIdent variable variable identifier.
* @param currentDistToVarUsage current distance to the variable usage.
* @return the distance to variable usage for in the child node.
*/
private static int getDistToVariableUsageInChildNode(DetailAST childNode, DetailAST varIdent,
int currentDistToVarUsage) {
DetailAST examineNode = childNode;
if (examineNode.getType() == TokenTypes.LABELED_STAT) {
examineNode = examineNode.getFirstChild().getNextSibling();
}
int resultDist = currentDistToVarUsage;
switch (examineNode.getType()) {
case TokenTypes.VARIABLE_DEF:
resultDist++;
break;
case TokenTypes.SLIST:
resultDist = 0;
break;
case TokenTypes.LITERAL_FOR:
case TokenTypes.LITERAL_WHILE:
case TokenTypes.LITERAL_DO:
case TokenTypes.LITERAL_IF:
case TokenTypes.LITERAL_SWITCH:
if (isVariableInOperatorExpr(examineNode, varIdent)) {
resultDist++;
}
else {
// variable usage is in inner scope
// reset counters, because we can't determine distance
resultDist = 0;
}
break;
default:
if (examineNode.findFirstToken(TokenTypes.SLIST) == null) {
resultDist++;
}
else {
resultDist = 0;
}
}
return resultDist;
}
示例15: handleBlock
/**
* processes a <code>BlockDef</code> and resolves references in it
*
* @param block the <code>BlockDef</code> to process
*/
protected void handleBlock(BlockDef block) {
SymTabAST node = block.getTreeNode();
switch (node.getType()) {
case TokenTypes.LITERAL_FOR :
handleFor(block);
break;
case TokenTypes.LITERAL_IF :
handleIf(block);
break;
case TokenTypes.LITERAL_WHILE :
handleWhileAndSynchronized(block);
break;
case TokenTypes.LITERAL_DO :
handleDoWhile(block);
break;
case TokenTypes.LITERAL_TRY :
case TokenTypes.LITERAL_FINALLY :
SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);
handleSList(slist, block);
break;
case TokenTypes.LITERAL_CATCH :
handleCatch(block);
break;
case TokenTypes.LITERAL_SWITCH :
handleSwitch(block);
break;
case TokenTypes.SLIST :
handleSList(node, block);
break;
case TokenTypes.EXPR :
resolveExpression(node, block, null, true);
break;
case TokenTypes.INSTANCE_INIT :
case TokenTypes.STATIC_INIT :
handleSList((SymTabAST) node.getFirstChild(), block);
break;
case TokenTypes.LITERAL_SYNCHRONIZED :
handleWhileAndSynchronized(block);
break;
case TokenTypes.LITERAL_ASSERT :
handleAssert(block);
break;
default :
if (mInitialized) {
final Log log = mLogFactory.getInstance(this.getClass());
log.error(
"Unhandled block "
+ block
+ " of type "
+ node.getType());
}
}
}