本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.VARIABLE_DEF属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.VARIABLE_DEF属性的具体用法?Java TokenTypes.VARIABLE_DEF怎么用?Java TokenTypes.VARIABLE_DEF使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.VARIABLE_DEF属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final UnusedImportsCheck testCheckObject =
new UnusedImportsCheck();
final int[] actual = testCheckObject.getRequiredTokens();
final int[] expected = {
TokenTypes.IDENT,
TokenTypes.IMPORT,
TokenTypes.STATIC_IMPORT,
// Definitions that may contain Javadoc...
TokenTypes.PACKAGE_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
};
assertArrayEquals("Default required tokens are invalid", expected, actual);
}
示例2: searchVariableUsageExpressions
/**
* Searches variable usages starting from specified statement.
* @param variableAst Variable that is used.
* @param statementAst DetailAST to start searching from.
* @return entry which contains list with found expressions that use the variable
* and distance from specified statement to first found expression.
*/
private static Entry<List<DetailAST>, Integer>
searchVariableUsageExpressions(final DetailAST variableAst, final DetailAST statementAst) {
final List<DetailAST> variableUsageExpressions = new ArrayList<DetailAST>();
int distance = 0;
DetailAST currentStatementAst = statementAst;
while (currentStatementAst != null
&& currentStatementAst.getType() != TokenTypes.RCURLY) {
if (currentStatementAst.getFirstChild() != null) {
if (isChild(currentStatementAst, variableAst)) {
variableUsageExpressions.add(currentStatementAst);
}
// If expression doesn't contain variable and this variable
// hasn't been met yet, than distance + 1.
else if (variableUsageExpressions.isEmpty()
&& currentStatementAst.getType() != TokenTypes.VARIABLE_DEF) {
distance++;
}
}
currentStatementAst = currentStatementAst.getNextSibling();
}
return new SimpleEntry<List<DetailAST>, Integer>(variableUsageExpressions, distance);
}
示例3: 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);
}
示例4: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final RedundantModifierCheck redundantModifierCheckObj = new RedundantModifierCheck();
final int[] actual = redundantModifierCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.METHOD_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.RESOURCE,
};
Assert.assertArrayEquals("Invalid acceptable tokens", expected, actual);
}
示例5: visitToken
@Override
public void visitToken(final DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.VARIABLE_DEF:
case TokenTypes.PARAMETER_DEF:
currentFrame.addField(ast);
break;
case TokenTypes.METHOD_CALL:
processMethodCall(ast);
break;
case TokenTypes.SLIST:
processSlist(ast);
break;
case TokenTypes.LITERAL_NEW:
processLiteralNew(ast);
break;
default:
processFrame(ast);
}
}
示例6: getDefaultTokens
/** @see com.puppycrawl.tools.checkstyle.api.Check */
public int[] getDefaultTokens()
{
return new int[] {
TokenTypes.VARIABLE_DEF,
};
}
示例7: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
};
}
示例8: findContainingConstantDef
/**
* Finds the constant definition that contains aAST.
* @param ast the AST
* @return the constant def or null if ast is not contained in a constant definition.
*/
private static DetailAST findContainingConstantDef(DetailAST ast) {
DetailAST varDefAST = ast;
while (varDefAST != null
&& varDefAST.getType() != TokenTypes.VARIABLE_DEF
&& varDefAST.getType() != TokenTypes.ENUM_CONSTANT_DEF) {
varDefAST = varDefAST.getParent();
}
DetailAST constantDef = null;
// no containing variable definition?
if (varDefAST != null) {
// implicit constant?
if (ScopeUtils.isInInterfaceOrAnnotationBlock(varDefAST)
|| varDefAST.getType() == TokenTypes.ENUM_CONSTANT_DEF) {
constantDef = varDefAST;
}
else {
// explicit constant
final DetailAST modifiersAST = varDefAST.findFirstToken(TokenTypes.MODIFIERS);
if (modifiersAST.findFirstToken(TokenTypes.FINAL) != null) {
constantDef = varDefAST;
}
}
}
return constantDef;
}
示例9: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final MemberNameCheck memberNameCheckObj = new MemberNameCheck();
final int[] actual = memberNameCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.VARIABLE_DEF,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例10: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.INSTANCE_INIT,
TokenTypes.STATIC_INIT,
TokenTypes.PACKAGE_DEF,
TokenTypes.IMPORT,
TokenTypes.VARIABLE_DEF,
TokenTypes.CTOR_CALL,
TokenTypes.SUPER_CTOR_CALL,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_BREAK,
TokenTypes.LITERAL_CONTINUE,
TokenTypes.LITERAL_RETURN,
TokenTypes.LITERAL_THROW,
TokenTypes.LITERAL_SYNCHRONIZED,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_FINALLY,
TokenTypes.EXPR,
TokenTypes.LABELED_STAT,
TokenTypes.LITERAL_CASE,
TokenTypes.LITERAL_DEFAULT,
};
}
示例11: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.VARIABLE_DEF,
TokenTypes.IMPORT,
};
}
示例12: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final JavadocVariableCheck javadocVariableCheck = new JavadocVariableCheck();
final int[] actual = javadocVariableCheck.getRequiredTokens();
final int[] expected = {
TokenTypes.VARIABLE_DEF,
};
assertArrayEquals("Default required tokens are invalid", expected, actual);
}
示例13: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.IDENT,
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.SLIST,
TokenTypes.OBJBLOCK,
TokenTypes.LITERAL_BREAK,
TokenTypes.VARIABLE_DEF,
};
}
示例14: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.IDENT,
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.SLIST,
TokenTypes.OBJBLOCK,
TokenTypes.LITERAL_BREAK,
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
};
}
示例15: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.MODIFIERS,
TokenTypes.OBJBLOCK,
TokenTypes.VARIABLE_DEF,
};
}