本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.SLIST属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.SLIST属性的具体用法?Java TokenTypes.SLIST怎么用?Java TokenTypes.SLIST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.SLIST属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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());
}
}
示例2: 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
}
}
示例3: findLeftCurly
/**
* Calculates the left curly corresponding to the block to be checked.
*
* @param ast a {@code DetailAST} value
* @return the left curly corresponding to the block to be checked
*/
private static DetailAST findLeftCurly(DetailAST ast) {
final DetailAST leftCurly;
final DetailAST slistAST = ast.findFirstToken(TokenTypes.SLIST);
if ((ast.getType() == TokenTypes.LITERAL_CASE
|| ast.getType() == TokenTypes.LITERAL_DEFAULT)
&& ast.getNextSibling() != null
&& ast.getNextSibling().getFirstChild() != null
&& ast.getNextSibling().getFirstChild().getType() == TokenTypes.SLIST) {
leftCurly = ast.getNextSibling().getFirstChild();
}
else if (slistAST == null) {
leftCurly = ast.findFirstToken(TokenTypes.LCURLY);
}
else {
leftCurly = slistAST;
}
return leftCurly;
}
示例4: getNextToken
/**
* Get the token to start counting the number of lines to add to the distance aim from.
* @param checkedStatement the checked statement.
* @return the token to start counting the number of lines to add to the distance aim from.
*/
private DetailAST getNextToken(DetailAST checkedStatement) {
DetailAST nextToken;
if (checkedStatement.getType() == TokenTypes.SLIST
|| checkedStatement.getType() == TokenTypes.ARRAY_INIT
|| checkedStatement.getType() == TokenTypes.CASE_GROUP) {
nextToken = checkedStatement.getFirstChild();
}
else {
nextToken = checkedStatement.getNextSibling();
}
if (nextToken != null && isComment(nextToken) && isTrailingComment(nextToken)) {
nextToken = nextToken.getNextSibling();
}
return nextToken;
}
示例5: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.METHOD_CALL,
TokenTypes.CLASS_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_TRY,
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.SLIST,
TokenTypes.ENUM_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.LITERAL_NEW,
};
}
示例6: 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);
}
}
示例7: isSingleLineCase
/**
* Checks if current case statement is single-line statement, e.g.:
* <p>
* {@code
* case 1: doSomeStuff(); break;
* case 2: doSomeStuff(); break;
* case 3: ;
* }
* </p>
* @param literalCase {@link TokenTypes#LITERAL_CASE case statement}.
* @return true if current case statement is single-line statement.
*/
private static boolean isSingleLineCase(DetailAST literalCase) {
boolean result = false;
final DetailAST slist = literalCase.getNextSibling();
if (slist == null) {
result = true;
}
else {
final DetailAST block = slist.getFirstChild();
if (block.getType() != TokenTypes.SLIST) {
final DetailAST caseBreak = slist.findFirstToken(TokenTypes.LITERAL_BREAK);
if (caseBreak != null) {
final boolean atOneLine = literalCase.getLineNo() == block.getLineNo();
result = atOneLine && block.getLineNo() == caseBreak.getLineNo();
}
}
}
return result;
}
示例8: 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
}
}
示例9: makeElseBlock
/**
* defines an anonymous block to enclose the scope of an else block
*
* @param tree the SymTabAST to process
* @return <code>void</code>
* @see #makeBlock(SymTabAST)
* @see #walkTree(SymTabAST, boolean)
*/
public void makeElseBlock(SymTabAST tree) {
if (tree.getType() == TokenTypes.SLIST) {
BlockDef block = makeBlock(tree);
symbolTable.pushScope( block );
walkTree(tree, false);
symbolTable.popScope();
}
else {
walkTree(tree, false);
}
}
示例10: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.INSTANCE_INIT,
TokenTypes.STATIC_INIT,
TokenTypes.SLIST,
};
}
示例11: 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;
}
示例12: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final AvoidNestedBlocksCheck constantNameCheckObj = new AvoidNestedBlocksCheck();
final int[] actual = constantNameCheckObj.getAcceptableTokens();
final int[] expected = {TokenTypes.SLIST };
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例13: isPartOfDoubleBraceInitializerForPreviousToken
/**
* Check if given ast is part of double brace initializer and if it
* should omit checking if previous token is separated by whitespace.
* @param ast ast to check
* @return true if it should omit checking for previous token, false otherwise
*/
private static boolean isPartOfDoubleBraceInitializerForPreviousToken(DetailAST ast) {
final boolean initializerBeginsAfterClassBegins = ast.getType() == TokenTypes.SLIST
&& ast.getParent().getType() == TokenTypes.INSTANCE_INIT;
final boolean classEndsAfterInitializerEnds = ast.getType() == TokenTypes.RCURLY
&& ast.getPreviousSibling() != null
&& ast.getPreviousSibling().getType() == TokenTypes.INSTANCE_INIT;
return initializerBeginsAfterClassBegins || classEndsAfterInitializerEnds;
}
示例14: 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,
};
}
示例15: 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,
};
}