本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.PLUS属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.PLUS属性的具体用法?Java TokenTypes.PLUS怎么用?Java TokenTypes.PLUS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.PLUS属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: containsAllSafeTokens
/**
* Looks for all "safe" Token combinations in the argument
* expression branch.
* @param expr the argument expression
* @return - true if any child matches the set of tokens, false if not
*/
private static boolean containsAllSafeTokens(final DetailAST expr) {
DetailAST arg = expr.getFirstChild();
arg = skipVariableAssign(arg);
boolean argIsNotNull = false;
if (arg.getType() == TokenTypes.PLUS) {
DetailAST child = arg.getFirstChild();
while (child != null
&& !argIsNotNull) {
argIsNotNull = child.getType() == TokenTypes.STRING_LITERAL
|| child.getType() == TokenTypes.IDENT;
child = child.getNextSibling();
}
}
return argIsNotNull
|| !arg.branchContains(TokenTypes.IDENT)
&& !arg.branchContains(TokenTypes.LITERAL_NULL);
}
示例2: findPreviousStatement
/**
* Finds a previous statement of the comment.
* Uses root token of the line while searching.
* @param comment comment.
* @param root root token of the line.
* @return previous statement of the comment or null if previous statement was not found.
*/
private DetailAST findPreviousStatement(DetailAST comment, DetailAST root) {
DetailAST previousStatement = null;
if (root.getLineNo() >= comment.getLineNo()) {
// ATTENTION: parent of the comment is below the comment in case block
// See https://github.com/checkstyle/checkstyle/issues/851
previousStatement = getPrevStatementFromSwitchBlock(comment);
}
final DetailAST tokenWhichBeginsTheLine;
if (root.getType() == TokenTypes.EXPR
&& root.getFirstChild().getFirstChild() != null) {
if (root.getFirstChild().getType() == TokenTypes.LITERAL_NEW) {
tokenWhichBeginsTheLine = root.getFirstChild();
}
else {
tokenWhichBeginsTheLine = findTokenWhichBeginsTheLine(root);
}
}
else if (root.getType() == TokenTypes.PLUS) {
tokenWhichBeginsTheLine = root.getFirstChild();
}
else {
tokenWhichBeginsTheLine = root;
}
if (tokenWhichBeginsTheLine != null
&& !isComment(tokenWhichBeginsTheLine)
&& isOnPreviousLineIgnoringComments(comment, tokenWhichBeginsTheLine)) {
previousStatement = tokenWhichBeginsTheLine;
}
return previousStatement;
}
示例3: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.QUESTION, // '?'
TokenTypes.COLON, // ':' (not reported for a case)
TokenTypes.EQUAL, // "=="
TokenTypes.NOT_EQUAL, // "!="
TokenTypes.DIV, // '/'
TokenTypes.PLUS, //' +' (unary plus is UNARY_PLUS)
TokenTypes.MINUS, // '-' (unary minus is UNARY_MINUS)
TokenTypes.STAR, // '*'
TokenTypes.MOD, // '%'
TokenTypes.SR, // ">>"
TokenTypes.BSR, // ">>>"
TokenTypes.GE, // ">="
TokenTypes.GT, // ">"
TokenTypes.SL, // "<<"
TokenTypes.LE, // "<="
TokenTypes.LT, // '<'
TokenTypes.BXOR, // '^'
TokenTypes.BOR, // '|'
TokenTypes.LOR, // "||"
TokenTypes.BAND, // '&'
TokenTypes.LAND, // "&&"
TokenTypes.TYPE_EXTENSION_AND,
TokenTypes.LITERAL_INSTANCEOF,
};
}
示例4: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.QUESTION, // '?'
TokenTypes.COLON, // ':' (not reported for a case)
TokenTypes.EQUAL, // "=="
TokenTypes.NOT_EQUAL, // "!="
TokenTypes.DIV, // '/'
TokenTypes.PLUS, //' +' (unary plus is UNARY_PLUS)
TokenTypes.MINUS, // '-' (unary minus is UNARY_MINUS)
TokenTypes.STAR, // '*'
TokenTypes.MOD, // '%'
TokenTypes.SR, // ">>"
TokenTypes.BSR, // ">>>"
TokenTypes.GE, // ">="
TokenTypes.GT, // ">"
TokenTypes.SL, // "<<"
TokenTypes.LE, // "<="
TokenTypes.LT, // '<'
TokenTypes.BXOR, // '^'
TokenTypes.BOR, // '|'
TokenTypes.LOR, // "||"
TokenTypes.BAND, // '&'
TokenTypes.LAND, // "&&"
TokenTypes.LITERAL_INSTANCEOF,
TokenTypes.TYPE_EXTENSION_AND,
TokenTypes.ASSIGN, // '='
TokenTypes.DIV_ASSIGN, // "/="
TokenTypes.PLUS_ASSIGN, // "+="
TokenTypes.MINUS_ASSIGN, //"-="
TokenTypes.STAR_ASSIGN, // "*="
TokenTypes.MOD_ASSIGN, // "%="
TokenTypes.SR_ASSIGN, // ">>="
TokenTypes.BSR_ASSIGN, // ">>>="
TokenTypes.SL_ASSIGN, // "<<="
TokenTypes.BXOR_ASSIGN, // "^="
TokenTypes.BOR_ASSIGN, // "|="
TokenTypes.BAND_ASSIGN, // "&="
TokenTypes.METHOD_REF, // "::"
};
}
示例5: 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,
};
}
示例6: 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,
};
}
示例7: 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);
}