本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.RESOURCE属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.RESOURCE属性的具体用法?Java TokenTypes.RESOURCE怎么用?Java TokenTypes.RESOURCE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.RESOURCE属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.METHOD_DEF,
TokenTypes.VARIABLE_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.RESOURCE,
};
}
示例3: visitToken
@Override
public void visitToken(DetailAST ast) {
if (ast.getType() == TokenTypes.INTERFACE_DEF) {
checkInterfaceModifiers(ast);
}
else if (ast.getType() == TokenTypes.ENUM_DEF) {
checkEnumDef(ast);
}
else {
if (ast.getType() == TokenTypes.CTOR_DEF) {
if (isEnumMember(ast)) {
checkEnumConstructorModifiers(ast);
}
else {
checkClassConstructorModifiers(ast);
}
}
else if (ast.getType() == TokenTypes.METHOD_DEF) {
processMethods(ast);
}
else if (ast.getType() == TokenTypes.RESOURCE) {
processResources(ast);
}
if (isInterfaceOrAnnotationMember(ast)) {
processInterfaceOrAnnotation(ast);
}
}
}
示例4: checkTryResources
/**
* Checks indentation of resources parameters in try resources.
*
* @param resourcesSpecAst Resource specification ast
*/
private void checkTryResources(final DetailAST resourcesSpecAst) {
final DetailAST resourcesAst = resourcesSpecAst.findFirstToken(TokenTypes.RESOURCES);
final int indentation = getIndent().getFirstIndentLevel()
+ getIndentCheck().getLineWrappingIndentation();
final IndentLevel expectedResourceIndent = new IndentLevel(indentation);
final String subType = "resource";
DetailAST resourceAst = resourcesAst.getFirstChild();
while (resourceAst != null) {
if (resourceAst.getType() == TokenTypes.RESOURCE) {
final DetailAST nextSibling;
if (resourceAst.getNextSibling() == null) {
nextSibling = getTryResRparen();
}
else {
nextSibling = resourceAst.getNextSibling();
}
if (isOnStartOfLine(resourceAst)) {
checkChildIndentation(resourceAst, subType, expectedResourceIndent);
checkWrappingIndentation(
resourceAst,
nextSibling,
getIndentCheck().getLineWrappingIndentation(),
expectedResourceIndent.getFirstIndentLevel(),
true);
}
else {
checkWrappingIndentation(resourceAst, nextSibling);
}
}
resourceAst = resourceAst.getNextSibling();
}
}
示例5: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.RESOURCE,
};
}
示例6: mustCheckName
@Override
protected final boolean mustCheckName(DetailAST ast) {
final DetailAST modifiersAST =
ast.findFirstToken(TokenTypes.MODIFIERS);
final boolean isFinal = ast.getType() == TokenTypes.RESOURCE
|| modifiersAST.findFirstToken(TokenTypes.FINAL) != null;
return isFinal && ScopeUtils.isLocalVariableDef(ast);
}
示例7: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final LocalFinalVariableNameCheck localFinalVariableNameCheckObj =
new LocalFinalVariableNameCheck();
final int[] actual = localFinalVariableNameCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.RESOURCE,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}