本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.LCURLY属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.LCURLY属性的具体用法?Java TokenTypes.LCURLY怎么用?Java TokenTypes.LCURLY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.LCURLY属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitToken
@Override
public void visitToken(DetailAST ast) {
final DetailAST leftCurly = findLeftCurly(ast);
if (leftCurly != null) {
if (option == BlockOption.STATEMENT) {
final boolean emptyBlock;
if (leftCurly.getType() == TokenTypes.LCURLY) {
emptyBlock = leftCurly.getNextSibling().getType() != TokenTypes.CASE_GROUP;
}
else {
emptyBlock = leftCurly.getChildCount() <= 1;
}
if (emptyBlock) {
log(leftCurly.getLineNo(),
leftCurly.getColumnNo(),
MSG_KEY_BLOCK_NO_STATEMENT,
ast.getText());
}
}
else if (!hasText(leftCurly)) {
log(leftCurly.getLineNo(),
leftCurly.getColumnNo(),
MSG_KEY_BLOCK_EMPTY,
ast.getText());
}
}
}
示例2: isPartOfDoubleBraceInitializerForNextToken
/**
* Check if given ast is part of double brace initializer and if it
* should omit checking if next token is separated by whitespace.
* See <a href="https://github.com/checkstyle/checkstyle/pull/2845">
* PR#2845</a> for more information why this function was needed.
* @param ast ast to check
* @return true if it should omit checking for next token, false otherwise
*/
private static boolean isPartOfDoubleBraceInitializerForNextToken(DetailAST ast) {
final boolean classBeginBeforeInitializerBegin = ast.getType() == TokenTypes.LCURLY
&& ast.getNextSibling().getType() == TokenTypes.INSTANCE_INIT;
final boolean initalizerEndsBeforeClassEnds = ast.getType() == TokenTypes.RCURLY
&& ast.getParent().getType() == TokenTypes.SLIST
&& ast.getParent().getParent().getType() == TokenTypes.INSTANCE_INIT
&& ast.getParent().getParent().getNextSibling().getType() == TokenTypes.RCURLY;
return classBeginBeforeInitializerBegin || initalizerEndsBeforeClassEnds;
}
示例3: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.ASSIGN,
TokenTypes.BAND,
TokenTypes.BAND_ASSIGN,
TokenTypes.BOR,
TokenTypes.BOR_ASSIGN,
TokenTypes.BSR,
TokenTypes.BSR_ASSIGN,
TokenTypes.BXOR,
TokenTypes.BXOR_ASSIGN,
TokenTypes.COLON,
TokenTypes.DIV,
TokenTypes.DIV_ASSIGN,
TokenTypes.DO_WHILE,
TokenTypes.EQUAL,
TokenTypes.GE,
TokenTypes.GT,
TokenTypes.LAMBDA,
TokenTypes.LAND,
TokenTypes.LCURLY,
TokenTypes.LE,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_FINALLY,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_RETURN,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_SYNCHRONIZED,
TokenTypes.LITERAL_TRY,
TokenTypes.LITERAL_WHILE,
TokenTypes.LOR,
TokenTypes.LT,
TokenTypes.MINUS,
TokenTypes.MINUS_ASSIGN,
TokenTypes.MOD,
TokenTypes.MOD_ASSIGN,
TokenTypes.NOT_EQUAL,
TokenTypes.PLUS,
TokenTypes.PLUS_ASSIGN,
TokenTypes.QUESTION,
TokenTypes.RCURLY,
TokenTypes.SL,
TokenTypes.SLIST,
TokenTypes.SL_ASSIGN,
TokenTypes.SR,
TokenTypes.SR_ASSIGN,
TokenTypes.STAR,
TokenTypes.STAR_ASSIGN,
TokenTypes.LITERAL_ASSERT,
TokenTypes.TYPE_EXTENSION_AND,
};
}
示例4: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.ASSIGN,
TokenTypes.ARRAY_INIT,
TokenTypes.BAND,
TokenTypes.BAND_ASSIGN,
TokenTypes.BOR,
TokenTypes.BOR_ASSIGN,
TokenTypes.BSR,
TokenTypes.BSR_ASSIGN,
TokenTypes.BXOR,
TokenTypes.BXOR_ASSIGN,
TokenTypes.COLON,
TokenTypes.DIV,
TokenTypes.DIV_ASSIGN,
TokenTypes.DO_WHILE,
TokenTypes.EQUAL,
TokenTypes.GE,
TokenTypes.GT,
TokenTypes.LAMBDA,
TokenTypes.LAND,
TokenTypes.LCURLY,
TokenTypes.LE,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_FINALLY,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_RETURN,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_SYNCHRONIZED,
TokenTypes.LITERAL_TRY,
TokenTypes.LITERAL_WHILE,
TokenTypes.LOR,
TokenTypes.LT,
TokenTypes.MINUS,
TokenTypes.MINUS_ASSIGN,
TokenTypes.MOD,
TokenTypes.MOD_ASSIGN,
TokenTypes.NOT_EQUAL,
TokenTypes.PLUS,
TokenTypes.PLUS_ASSIGN,
TokenTypes.QUESTION,
TokenTypes.RCURLY,
TokenTypes.SL,
TokenTypes.SLIST,
TokenTypes.SL_ASSIGN,
TokenTypes.SR,
TokenTypes.SR_ASSIGN,
TokenTypes.STAR,
TokenTypes.STAR_ASSIGN,
TokenTypes.LITERAL_ASSERT,
TokenTypes.TYPE_EXTENSION_AND,
TokenTypes.WILDCARD_TYPE,
TokenTypes.GENERIC_START,
TokenTypes.GENERIC_END,
TokenTypes.ELLIPSIS,
};
}
示例5: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final WhitespaceAroundCheck whitespaceAroundCheckObj = new WhitespaceAroundCheck();
final int[] actual = whitespaceAroundCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.ASSIGN,
TokenTypes.ARRAY_INIT,
TokenTypes.BAND,
TokenTypes.BAND_ASSIGN,
TokenTypes.BOR,
TokenTypes.BOR_ASSIGN,
TokenTypes.BSR,
TokenTypes.BSR_ASSIGN,
TokenTypes.BXOR,
TokenTypes.BXOR_ASSIGN,
TokenTypes.COLON,
TokenTypes.DIV,
TokenTypes.DIV_ASSIGN,
TokenTypes.DO_WHILE,
TokenTypes.EQUAL,
TokenTypes.GE,
TokenTypes.GT,
TokenTypes.LAMBDA,
TokenTypes.LAND,
TokenTypes.LCURLY,
TokenTypes.LE,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_FINALLY,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_RETURN,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_SYNCHRONIZED,
TokenTypes.LITERAL_TRY,
TokenTypes.LITERAL_WHILE,
TokenTypes.LOR,
TokenTypes.LT,
TokenTypes.MINUS,
TokenTypes.MINUS_ASSIGN,
TokenTypes.MOD,
TokenTypes.MOD_ASSIGN,
TokenTypes.NOT_EQUAL,
TokenTypes.PLUS,
TokenTypes.PLUS_ASSIGN,
TokenTypes.QUESTION,
TokenTypes.RCURLY,
TokenTypes.SL,
TokenTypes.SLIST,
TokenTypes.SL_ASSIGN,
TokenTypes.SR,
TokenTypes.SR_ASSIGN,
TokenTypes.STAR,
TokenTypes.STAR_ASSIGN,
TokenTypes.LITERAL_ASSERT,
TokenTypes.TYPE_EXTENSION_AND,
TokenTypes.WILDCARD_TYPE,
TokenTypes.GENERIC_START,
TokenTypes.GENERIC_END,
TokenTypes.ELLIPSIS,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例6: isInEmptyCodeBlock
/**
* Checks whether comment is placed in the empty code block.
* For example:
* <p>
* ...
* {@code
* // empty code block
* }
* ...
* </p>
* Note, the method does not treat empty case blocks.
* @param prevStmt previous statement.
* @param nextStmt next statement.
* @return true if comment is placed in the empty code block.
*/
private static boolean isInEmptyCodeBlock(DetailAST prevStmt, DetailAST nextStmt) {
return prevStmt != null
&& nextStmt != null
&& (prevStmt.getType() == TokenTypes.SLIST
|| prevStmt.getType() == TokenTypes.LCURLY
|| prevStmt.getType() == TokenTypes.ARRAY_INIT
|| prevStmt.getType() == TokenTypes.OBJBLOCK)
&& nextStmt.getType() == TokenTypes.RCURLY;
}
示例7: isEmptyType
/**
* Test if the given {@code DetailAST} is part of an empty block.
* An example empty block might look like the following
* <p>
* <pre> class Foo {}</pre>
* </p>
*
* @param ast ast the {@code DetailAST} to test.
* @return {@code true} if {@code ast} makes up part of an
* empty block contained under a {@code match} token type
* node.
*/
private static boolean isEmptyType(DetailAST ast) {
final int type = ast.getType();
final DetailAST nextSibling = ast.getNextSibling();
final DetailAST previousSibling = ast.getPreviousSibling();
return type == TokenTypes.LCURLY
&& nextSibling.getType() == TokenTypes.RCURLY
|| type == TokenTypes.RCURLY
&& previousSibling != null
&& previousSibling.getType() == TokenTypes.LCURLY;
}
示例8: isArrayInitialization
/**
* Is array initialization.
* @param currentType current token
* @param parentType parent token
* @return true is current token inside array initialization
*/
private static boolean isArrayInitialization(int currentType, int parentType) {
return (currentType == TokenTypes.RCURLY || currentType == TokenTypes.LCURLY)
&& (parentType == TokenTypes.ARRAY_INIT
|| parentType == TokenTypes.ANNOTATION_ARRAY_INIT);
}