本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.STATIC_INIT属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.STATIC_INIT属性的具体用法?Java TokenTypes.STATIC_INIT怎么用?Java TokenTypes.STATIC_INIT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.STATIC_INIT属性的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: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.CTOR_DEF:
case TokenTypes.METHOD_DEF:
case TokenTypes.INSTANCE_INIT:
case TokenTypes.STATIC_INIT:
visitMemberDef(ast);
break;
case TokenTypes.SLIST:
visitSlist(ast);
break;
default:
throw new IllegalStateException(ast.toString());
}
}
示例3: leaveToken
@Override
public void leaveToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.CTOR_DEF:
case TokenTypes.METHOD_DEF:
case TokenTypes.INSTANCE_INIT:
case TokenTypes.STATIC_INIT:
leaveMemberDef(ast);
break;
case TokenTypes.SLIST:
// Do nothing
break;
default:
throw new IllegalStateException(ast.toString());
}
}
示例4: visitSlist
/**
* Process the end of a statement list.
*
* @param ast the token representing the statement list.
*/
private void visitSlist(DetailAST ast) {
if (context.getAST() != null) {
// find member AST for the statement list
final DetailAST contextAST = context.getAST();
DetailAST parent = ast.getParent();
int type = parent.getType();
while (type != TokenTypes.CTOR_DEF
&& type != TokenTypes.METHOD_DEF
&& type != TokenTypes.INSTANCE_INIT
&& type != TokenTypes.STATIC_INIT) {
parent = parent.getParent();
type = parent.getType();
}
if (parent == contextAST) {
context.addCount(ast.getChildCount() / 2);
}
}
}
示例5: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
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,
};
}
示例6: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final NPathComplexityCheck npathComplexityCheckObj = new NPathComplexityCheck();
final int[] actual = npathComplexityCheckObj.getRequiredTokens();
final int[] expected = {
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,
};
Assert.assertNotNull("Required tokens should not be null", actual);
Assert.assertArrayEquals("Invalid required tokens", expected, actual);
}
示例7: 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,
};
}
示例8: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.LITERAL_TRY,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_FINALLY,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_ELSE,
TokenTypes.CLASS_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,
TokenTypes.STATIC_INIT,
TokenTypes.INSTANCE_INIT,
TokenTypes.LAMBDA,
};
}
示例9: visitToken
@Override
public void visitToken(DetailAST ast) {
final int tokenType = ast.getType();
if (tokenType == TokenTypes.CLASS_DEF
|| tokenType == TokenTypes.METHOD_DEF
|| tokenType == TokenTypes.CTOR_DEF
|| tokenType == TokenTypes.STATIC_INIT
|| tokenType == TokenTypes.INSTANCE_INIT) {
//add a counter for this class/method
counters.push(new Counter());
}
//check if token is countable
if (isCountable(ast)) {
//increment the stacked counters
for (final Counter counter : counters) {
counter.increment();
}
}
}
示例10: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_TRY,
TokenTypes.LITERAL_CATCH,
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,
TokenTypes.LITERAL_CASE,
TokenTypes.LITERAL_DEFAULT,
TokenTypes.ARRAY_INIT,
};
}
示例11: isInCodeBlock
/**
* Returns whether the scope of a node is restricted to a code block.
* A code block is a method or constructor body, an initializer block, or lambda body.
*
* @param node the node to check
* @return a {@code boolean} value
*/
public static boolean isInCodeBlock(DetailAST node) {
boolean returnValue = false;
// Loop up looking for a containing code block
for (DetailAST token = node.getParent();
token != null;
token = token.getParent()) {
final int type = token.getType();
if (type == TokenTypes.METHOD_DEF
|| type == TokenTypes.CTOR_DEF
|| type == TokenTypes.INSTANCE_INIT
|| type == TokenTypes.STATIC_INIT
|| type == TokenTypes.LAMBDA) {
returnValue = true;
break;
}
}
return returnValue;
}
示例12: 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,
};
}
示例13: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.INSTANCE_INIT,
TokenTypes.STATIC_INIT,
TokenTypes.SLIST,
};
}
示例14: isClassMemberBlock
/**
* Whether the AST is a class member block.
* @param astType the AST to check.
* @return true if the AST is a class member block.
*/
private static boolean isClassMemberBlock(int astType) {
return astType == TokenTypes.STATIC_INIT
|| astType == TokenTypes.INSTANCE_INIT
|| astType == TokenTypes.METHOD_DEF
|| astType == TokenTypes.CTOR_DEF;
}
示例15: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.CTOR_DEF:
case TokenTypes.METHOD_DEF:
case TokenTypes.INSTANCE_INIT:
case TokenTypes.STATIC_INIT:
visitMethodDef();
break;
default:
visitTokenHook(ast);
}
}