本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.ASSIGN属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.ASSIGN属性的具体用法?Java TokenTypes.ASSIGN怎么用?Java TokenTypes.ASSIGN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.ASSIGN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
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, // "&="
};
}
示例2: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.ASSIGN,
TokenTypes.PLUS_ASSIGN,
TokenTypes.MINUS_ASSIGN,
TokenTypes.STAR_ASSIGN,
TokenTypes.DIV_ASSIGN,
TokenTypes.MOD_ASSIGN,
TokenTypes.SR_ASSIGN,
TokenTypes.BSR_ASSIGN,
TokenTypes.SL_ASSIGN,
TokenTypes.BAND_ASSIGN,
TokenTypes.BXOR_ASSIGN,
TokenTypes.BOR_ASSIGN,
TokenTypes.INC,
TokenTypes.POST_INC,
TokenTypes.DEC,
TokenTypes.POST_DEC,
};
}
示例3: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.OBJBLOCK,
TokenTypes.LITERAL_FOR,
TokenTypes.FOR_ITERATOR,
TokenTypes.FOR_EACH_CLAUSE,
TokenTypes.ASSIGN,
TokenTypes.PLUS_ASSIGN,
TokenTypes.MINUS_ASSIGN,
TokenTypes.STAR_ASSIGN,
TokenTypes.DIV_ASSIGN,
TokenTypes.MOD_ASSIGN,
TokenTypes.SR_ASSIGN,
TokenTypes.BSR_ASSIGN,
TokenTypes.SL_ASSIGN,
TokenTypes.BAND_ASSIGN,
TokenTypes.BXOR_ASSIGN,
TokenTypes.BOR_ASSIGN,
TokenTypes.INC,
TokenTypes.POST_INC,
TokenTypes.DEC,
TokenTypes.POST_DEC,
};
}
示例4: skipVariableAssign
/**
* Skips over an inner assign portion of an argument expression.
* @param currentAST current token in the argument expression
* @return the next relevant token
*/
private static DetailAST skipVariableAssign(final DetailAST currentAST) {
DetailAST result = currentAST;
if (currentAST.getType() == TokenTypes.ASSIGN
&& currentAST.getFirstChild().getType() == TokenTypes.IDENT) {
result = currentAST.getFirstChild().getNextSibling();
}
return result;
}
示例5: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.CTOR_DEF:
case TokenTypes.METHOD_DEF:
visitMethodDef(ast);
break;
case TokenTypes.ASSIGN:
case TokenTypes.PLUS_ASSIGN:
case TokenTypes.MINUS_ASSIGN:
case TokenTypes.STAR_ASSIGN:
case TokenTypes.DIV_ASSIGN:
case TokenTypes.MOD_ASSIGN:
case TokenTypes.SR_ASSIGN:
case TokenTypes.BSR_ASSIGN:
case TokenTypes.SL_ASSIGN:
case TokenTypes.BAND_ASSIGN:
case TokenTypes.BXOR_ASSIGN:
case TokenTypes.BOR_ASSIGN:
visitAssign(ast);
break;
case TokenTypes.INC:
case TokenTypes.POST_INC:
case TokenTypes.DEC:
case TokenTypes.POST_DEC:
visitIncDec(ast);
break;
default:
throw new IllegalStateException(ast.toString());
}
}
示例6: leaveToken
@Override
public void leaveToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.CTOR_DEF:
case TokenTypes.METHOD_DEF:
leaveMethodDef();
break;
case TokenTypes.ASSIGN:
case TokenTypes.PLUS_ASSIGN:
case TokenTypes.MINUS_ASSIGN:
case TokenTypes.STAR_ASSIGN:
case TokenTypes.DIV_ASSIGN:
case TokenTypes.MOD_ASSIGN:
case TokenTypes.SR_ASSIGN:
case TokenTypes.BSR_ASSIGN:
case TokenTypes.SL_ASSIGN:
case TokenTypes.BAND_ASSIGN:
case TokenTypes.BXOR_ASSIGN:
case TokenTypes.BOR_ASSIGN:
case TokenTypes.INC:
case TokenTypes.POST_INC:
case TokenTypes.DEC:
case TokenTypes.POST_DEC:
// Do nothing
break;
default:
throw new IllegalStateException(ast.toString());
}
}
示例7: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.OBJBLOCK:
enterBlock();
break;
case TokenTypes.LITERAL_FOR:
case TokenTypes.FOR_ITERATOR:
case TokenTypes.FOR_EACH_CLAUSE:
//we need that Tokens only at leaveToken()
break;
case TokenTypes.ASSIGN:
case TokenTypes.PLUS_ASSIGN:
case TokenTypes.MINUS_ASSIGN:
case TokenTypes.STAR_ASSIGN:
case TokenTypes.DIV_ASSIGN:
case TokenTypes.MOD_ASSIGN:
case TokenTypes.SR_ASSIGN:
case TokenTypes.BSR_ASSIGN:
case TokenTypes.SL_ASSIGN:
case TokenTypes.BAND_ASSIGN:
case TokenTypes.BXOR_ASSIGN:
case TokenTypes.BOR_ASSIGN:
case TokenTypes.INC:
case TokenTypes.POST_INC:
case TokenTypes.DEC:
case TokenTypes.POST_DEC:
checkIdent(ast);
break;
default:
throw new IllegalStateException(ILLEGAL_TYPE_OF_TOKEN + ast);
}
}
示例8: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.EXPR,
TokenTypes.IDENT,
TokenTypes.NUM_DOUBLE,
TokenTypes.NUM_FLOAT,
TokenTypes.NUM_INT,
TokenTypes.NUM_LONG,
TokenTypes.STRING_LITERAL,
TokenTypes.LITERAL_NULL,
TokenTypes.LITERAL_FALSE,
TokenTypes.LITERAL_TRUE,
TokenTypes.ASSIGN,
TokenTypes.BAND_ASSIGN,
TokenTypes.BOR_ASSIGN,
TokenTypes.BSR_ASSIGN,
TokenTypes.BXOR_ASSIGN,
TokenTypes.DIV_ASSIGN,
TokenTypes.MINUS_ASSIGN,
TokenTypes.MOD_ASSIGN,
TokenTypes.PLUS_ASSIGN,
TokenTypes.SL_ASSIGN,
TokenTypes.SR_ASSIGN,
TokenTypes.STAR_ASSIGN,
TokenTypes.LAMBDA,
};
}
示例9: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.EXPR,
TokenTypes.IDENT,
TokenTypes.NUM_DOUBLE,
TokenTypes.NUM_FLOAT,
TokenTypes.NUM_INT,
TokenTypes.NUM_LONG,
TokenTypes.STRING_LITERAL,
TokenTypes.LITERAL_NULL,
TokenTypes.LITERAL_FALSE,
TokenTypes.LITERAL_TRUE,
TokenTypes.ASSIGN,
TokenTypes.BAND_ASSIGN,
TokenTypes.BOR_ASSIGN,
TokenTypes.BSR_ASSIGN,
TokenTypes.BXOR_ASSIGN,
TokenTypes.DIV_ASSIGN,
TokenTypes.MINUS_ASSIGN,
TokenTypes.MOD_ASSIGN,
TokenTypes.PLUS_ASSIGN,
TokenTypes.SL_ASSIGN,
TokenTypes.SR_ASSIGN,
TokenTypes.STAR_ASSIGN,
TokenTypes.LAMBDA,
};
}
示例10: visitToken
@Override
public void visitToken(DetailAST ast) {
final int type = ast.getType();
final DetailAST parent = ast.getParent();
if (type == TokenTypes.LAMBDA && isLambdaSingleParameterSurrounded(ast)) {
log(ast, MSG_LAMBDA, ast.getText());
}
else if (type != TokenTypes.ASSIGN
|| parent.getType() != TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR) {
final boolean surrounded = isSurrounded(ast);
// An identifier surrounded by parentheses.
if (surrounded && type == TokenTypes.IDENT) {
parentToSkip = ast.getParent();
log(ast, MSG_IDENT, ast.getText());
}
// A literal (numeric or string) surrounded by parentheses.
else if (surrounded && isInTokenList(type, LITERALS)) {
parentToSkip = ast.getParent();
if (type == TokenTypes.STRING_LITERAL) {
log(ast, MSG_STRING,
chopString(ast.getText()));
}
else {
log(ast, MSG_LITERAL, ast.getText());
}
}
// The rhs of an assignment surrounded by parentheses.
else if (isInTokenList(type, ASSIGNMENTS)) {
assignDepth++;
final DetailAST last = ast.getLastChild();
if (last.getType() == TokenTypes.RPAREN) {
log(ast, MSG_ASSIGN);
}
}
}
}
示例11: leaveToken
@Override
public void leaveToken(DetailAST ast) {
final int type = ast.getType();
final DetailAST parent = ast.getParent();
// shouldn't process assign in annotation pairs
if (type != TokenTypes.ASSIGN
|| parent.getType() != TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR) {
// An expression is surrounded by parentheses.
if (type == TokenTypes.EXPR) {
// If 'parentToSkip' == 'ast', then we've already logged a
// warning about an immediate child node in visitToken, so we don't
// need to log another one here.
if (parentToSkip != ast && isExprSurrounded(ast)) {
if (assignDepth >= 1) {
log(ast, MSG_ASSIGN);
}
else if (ast.getParent().getType() == TokenTypes.LITERAL_RETURN) {
log(ast, MSG_RETURN);
}
else {
log(ast, MSG_EXPR);
}
}
parentToSkip = null;
}
else if (isInTokenList(type, ASSIGNMENTS)) {
assignDepth--;
}
}
}
示例12: getIndentImpl
@Override
protected IndentLevel getIndentImpl() {
final DetailAST parentAST = getMainAst().getParent();
final int type = parentAST.getType();
final IndentLevel indentLevel;
if (type == TokenTypes.LITERAL_NEW || type == TokenTypes.ASSIGN) {
// note: assumes new or assignment is line to align with
indentLevel = new IndentLevel(getLineStart(parentAST));
}
else {
// at this point getParent() is instance of BlockParentHandler
indentLevel = ((BlockParentHandler) getParent()).getChildrenExpectedIndent();
}
return indentLevel;
}
示例13: isSetterMethod
/**
* Returns whether an AST represents a setter method.
* @param ast the AST to check with
* @return whether the AST represents a setter method
*/
public static boolean isSetterMethod(final DetailAST ast) {
boolean setterMethod = false;
// Check have a method with exactly 7 children which are all that
// is allowed in a proper setter method which does not throw any
// exceptions.
if (ast.getType() == TokenTypes.METHOD_DEF
&& ast.getChildCount() == SETTER_GETTER_MAX_CHILDREN) {
final DetailAST type = ast.findFirstToken(TokenTypes.TYPE);
final String name = type.getNextSibling().getText();
final boolean matchesSetterFormat = SETTER_PATTERN.matcher(name).matches();
final boolean voidReturnType = type.findFirstToken(TokenTypes.LITERAL_VOID) != null;
final DetailAST params = ast.findFirstToken(TokenTypes.PARAMETERS);
final boolean singleParam = params.getChildCount(TokenTypes.PARAMETER_DEF) == 1;
if (matchesSetterFormat && voidReturnType && singleParam) {
// Now verify that the body consists of:
// SLIST -> EXPR -> ASSIGN
// SEMI
// RCURLY
final DetailAST slist = ast.findFirstToken(TokenTypes.SLIST);
if (slist != null && slist.getChildCount() == SETTER_BODY_SIZE) {
final DetailAST expr = slist.getFirstChild();
setterMethod = expr.getFirstChild().getType() == TokenTypes.ASSIGN;
}
}
}
return setterMethod;
}
示例14: leaveToken
@Override
public void leaveToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.FOR_ITERATOR:
leaveForIter(ast.getParent());
break;
case TokenTypes.FOR_EACH_CLAUSE:
if (!skipEnhancedForLoopVariable) {
final DetailAST paramDef = ast.findFirstToken(TokenTypes.VARIABLE_DEF);
leaveForEach(paramDef);
}
break;
case TokenTypes.LITERAL_FOR:
if (!getCurrentVariables().isEmpty()) {
leaveForDef(ast);
}
break;
case TokenTypes.OBJBLOCK:
exitBlock();
break;
case TokenTypes.ASSIGN:
case TokenTypes.PLUS_ASSIGN:
case TokenTypes.MINUS_ASSIGN:
case TokenTypes.STAR_ASSIGN:
case TokenTypes.DIV_ASSIGN:
case TokenTypes.MOD_ASSIGN:
case TokenTypes.SR_ASSIGN:
case TokenTypes.BSR_ASSIGN:
case TokenTypes.SL_ASSIGN:
case TokenTypes.BAND_ASSIGN:
case TokenTypes.BXOR_ASSIGN:
case TokenTypes.BOR_ASSIGN:
case TokenTypes.INC:
case TokenTypes.POST_INC:
case TokenTypes.DEC:
case TokenTypes.POST_DEC:
//we need that Tokens only at visitToken()
break;
default:
throw new IllegalStateException(ILLEGAL_TYPE_OF_TOKEN + ast);
}
}
示例15: 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, // "::"
};
}