本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.RESOURCE_SPECIFICATION属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.RESOURCE_SPECIFICATION属性的具体用法?Java TokenTypes.RESOURCE_SPECIFICATION怎么用?Java TokenTypes.RESOURCE_SPECIFICATION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.RESOURCE_SPECIFICATION属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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,
};
}
示例2: checkTry
/**
* Checks if a given try/catch/finally block terminated by return, throw or,
* if allowed break, continue.
* @param ast loop to check
* @param useBreak should we consider break as terminator.
* @param useContinue should we consider continue as terminator.
* @return true if try/catch/finally block is terminated.
*/
private boolean checkTry(final DetailAST ast, boolean useBreak,
boolean useContinue) {
final DetailAST finalStmt = ast.getLastChild();
boolean isTerminated = false;
if (finalStmt.getType() == TokenTypes.LITERAL_FINALLY) {
isTerminated = isTerminated(finalStmt.findFirstToken(TokenTypes.SLIST),
useBreak, useContinue);
}
if (!isTerminated) {
DetailAST firstChild = ast.getFirstChild();
if (firstChild.getType() == TokenTypes.RESOURCE_SPECIFICATION) {
firstChild = firstChild.getNextSibling();
}
isTerminated = isTerminated(firstChild,
useBreak, useContinue);
DetailAST catchStmt = ast.findFirstToken(TokenTypes.LITERAL_CATCH);
while (catchStmt != null
&& isTerminated
&& catchStmt.getType() == TokenTypes.LITERAL_CATCH) {
final DetailAST catchBody =
catchStmt.findFirstToken(TokenTypes.SLIST);
isTerminated = isTerminated(catchBody, useBreak, useContinue);
catchStmt = catchStmt.getNextSibling();
}
}
return isTerminated;
}
示例3: checkIndentation
@Override
public void checkIndentation() {
super.checkIndentation();
if (getMainAst().getFirstChild().getType() == TokenTypes.RESOURCE_SPECIFICATION) {
checkTryResParen(getTryResLparen(), "lparen");
checkTryResParen(getTryResRparen(), "rparen");
checkTryResources(getMainAst().getFirstChild());
}
}
示例4: getDetailsForTryCatchFinally
/**
* Collects validation details for LITERAL_TRY, LITERAL_CATCH, and LITERAL_FINALLY.
* @param ast a {@code DetailAST} value
* @return object containing all details to make a validation
*/
private static Details getDetailsForTryCatchFinally(DetailAST ast) {
boolean shouldCheckLastRcurly = false;
final DetailAST rcurly;
final DetailAST lcurly;
DetailAST nextToken;
final int tokenType = ast.getType();
if (tokenType == TokenTypes.LITERAL_TRY) {
if (ast.getFirstChild().getType() == TokenTypes.RESOURCE_SPECIFICATION) {
lcurly = ast.getFirstChild().getNextSibling();
}
else {
lcurly = ast.getFirstChild();
}
nextToken = lcurly.getNextSibling();
rcurly = lcurly.getLastChild();
if (nextToken == null) {
shouldCheckLastRcurly = true;
nextToken = getNextToken(ast);
}
}
else if (tokenType == TokenTypes.LITERAL_CATCH) {
nextToken = ast.getNextSibling();
lcurly = ast.getLastChild();
rcurly = lcurly.getLastChild();
if (nextToken == null) {
shouldCheckLastRcurly = true;
nextToken = getNextToken(ast);
}
}
else {
shouldCheckLastRcurly = true;
nextToken = getNextToken(ast);
lcurly = ast.getFirstChild();
rcurly = lcurly.getLastChild();
}
return new Details(lcurly, rcurly, nextToken, shouldCheckLastRcurly);
}
示例5: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.METHOD_CALL:
processLeft(ast);
processRight(ast.findFirstToken(TokenTypes.RPAREN));
break;
case TokenTypes.DOT:
case TokenTypes.EXPR:
case TokenTypes.QUESTION:
processExpression(ast);
break;
case TokenTypes.LITERAL_FOR:
visitLiteralFor(ast);
break;
case TokenTypes.ANNOTATION:
case TokenTypes.ENUM_CONSTANT_DEF:
case TokenTypes.LITERAL_NEW:
case TokenTypes.LITERAL_SYNCHRONIZED:
case TokenTypes.LAMBDA:
visitTokenWithOptionalParentheses(ast);
break;
case TokenTypes.RESOURCE_SPECIFICATION:
visitResourceSpecification(ast);
break;
default:
processLeft(ast.findFirstToken(TokenTypes.LPAREN));
processRight(ast.findFirstToken(TokenTypes.RPAREN));
}
}