本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.EXPR属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.EXPR属性的具体用法?Java TokenTypes.EXPR怎么用?Java TokenTypes.EXPR使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.EXPR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleAssert
/**
* @param block
*/
private void handleAssert(BlockDef block) {
SymTabAST node = block.getTreeNode();
SymTabAST conditional =
(node.findFirstToken(TokenTypes.EXPR));
resolveExpression(conditional, block, null, true);
SymTabAST message = (SymTabAST) conditional.getNextSibling();
while ((message != null) && (message.getType() != TokenTypes.EXPR)) {
message = (SymTabAST) message.getNextSibling();
}
if (message != null) {
resolveExpression(message, block, null, true);
}
}
示例2: processAssert
/**
* @param tree
*/
public void processAssert(SymTabAST tree) {
BlockDef block = makeBlock(tree);
SymTabAST expr = tree.findFirstToken(TokenTypes.EXPR);
SymTabAST message = (SymTabAST)expr.getNextSibling();
while ((message != null) && (message.getType() != TokenTypes.EXPR)) {
message = (SymTabAST) message.getNextSibling();
}
symbolTable.pushScope( block );
walkTree(expr, false);
if (message != null) {
walkTree(message, false);
}
symbolTable.popScope();
}
示例3: getAnnotationValues
/**
* Returns the annotation values represented by an AST.
* @param ast an AST node for an EXPR or ANNOTATION_ARRAY_INIT
* @return the list of Java string represented by the given AST for an
* expression or annotation array initializer
* @throws IllegalArgumentException if the AST is invalid
*/
private static List<String> getAnnotationValues(DetailAST ast) {
final List<String> annotationValues;
switch (ast.getType()) {
case TokenTypes.EXPR:
annotationValues = Collections.singletonList(getStringExpr(ast));
break;
case TokenTypes.ANNOTATION_ARRAY_INIT:
annotationValues = findAllExpressionsInChildren(ast);
break;
default:
throw new IllegalArgumentException(
"Expression or annotation array initializer AST expected: " + ast);
}
return annotationValues;
}
示例4: isCountable
/**
* Checks if a token is countable for the ncss metric.
*
* @param ast
* the AST
* @return true if the token is countable
*/
private static boolean isCountable(DetailAST ast) {
boolean countable = true;
final int tokenType = ast.getType();
//check if an expression is countable
if (tokenType == TokenTypes.EXPR) {
countable = isExpressionCountable(ast);
}
//check if an variable definition is countable
else if (tokenType == TokenTypes.VARIABLE_DEF) {
countable = isVariableDefCountable(ast);
}
return countable;
}
示例5: findAllExpressionsInChildren
/**
* Method looks at children and returns list of expressions in strings.
* @param parent ast, that contains children
* @return list of expressions in strings
*/
private static List<String> findAllExpressionsInChildren(DetailAST parent) {
final List<String> valueList = new LinkedList<String>();
DetailAST childAST = parent.getFirstChild();
while (childAST != null) {
if (childAST.getType() == TokenTypes.EXPR) {
valueList.add(getStringExpr(childAST));
}
childAST = childAST.getNextSibling();
}
return valueList;
}
示例6: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.EXPR,
TokenTypes.LAND,
TokenTypes.BAND,
TokenTypes.LOR,
TokenTypes.BOR,
TokenTypes.BXOR,
};
}
示例7: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.EXPR,
TokenTypes.LAND,
TokenTypes.BAND,
TokenTypes.LOR,
TokenTypes.BOR,
TokenTypes.BXOR,
};
}
示例8: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.CTOR_DEF:
case TokenTypes.METHOD_DEF:
visitMethodDef(ast);
break;
case TokenTypes.EXPR:
visitExpr();
break;
case TokenTypes.BOR:
if (!isPipeOperator(ast) && !isPassedInParameter(ast)) {
context.visitBooleanOperator();
}
break;
case TokenTypes.BAND:
case TokenTypes.BXOR:
if (!isPassedInParameter(ast)) {
context.visitBooleanOperator();
}
break;
case TokenTypes.LAND:
case TokenTypes.LOR:
context.visitBooleanOperator();
break;
default:
throw new IllegalArgumentException("Unknown type: " + ast);
}
}
示例9: leaveToken
@Override
public void leaveToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.CTOR_DEF:
case TokenTypes.METHOD_DEF:
leaveMethodDef();
break;
case TokenTypes.EXPR:
leaveExpr(ast);
break;
default:
// Do nothing
}
}
示例10: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.INSTANCE_INIT,
TokenTypes.STATIC_INIT,
TokenTypes.PACKAGE_DEF,
TokenTypes.IMPORT,
TokenTypes.VARIABLE_DEF,
TokenTypes.CTOR_CALL,
TokenTypes.SUPER_CTOR_CALL,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_FOR,
TokenTypes.LITERAL_SWITCH,
TokenTypes.LITERAL_BREAK,
TokenTypes.LITERAL_CONTINUE,
TokenTypes.LITERAL_RETURN,
TokenTypes.LITERAL_THROW,
TokenTypes.LITERAL_SYNCHRONIZED,
TokenTypes.LITERAL_CATCH,
TokenTypes.LITERAL_FINALLY,
TokenTypes.EXPR,
TokenTypes.LABELED_STAT,
TokenTypes.LITERAL_CASE,
TokenTypes.LITERAL_DEFAULT,
};
}
示例11: findChildrenOfExpressionType
/**
* Find all child of given AST of type TokenType.EXPR
* @param ast parent of expressions to find
* @return all child of given ast
*/
private static List<DetailAST> findChildrenOfExpressionType(DetailAST ast) {
final List<DetailAST> foundExpressions = new LinkedList<DetailAST>();
if (ast != null) {
for (DetailAST iteratingExpressionAST = ast.findFirstToken(TokenTypes.EXPR);
iteratingExpressionAST != null;
iteratingExpressionAST = iteratingExpressionAST.getNextSibling()) {
if (iteratingExpressionAST.getType() == TokenTypes.EXPR) {
foundExpressions.add(iteratingExpressionAST.getFirstChild());
}
}
}
return foundExpressions;
}
示例12: getValueAsStringList
public static List<String> getValueAsStringList(DetailAST annotationKeyValueAst) {
DetailAST annotationValueNode = getAnnotationValueNode(annotationKeyValueAst);
List<DetailAST> exprNodes = annotationValueNode.getType() == TokenTypes.EXPR ?
Collections.singletonList(annotationValueNode) :
CommonUtil.getChildsByType(annotationValueNode, TokenTypes.EXPR);
return exprNodes.stream()
.map(exprNode -> exprNode.findFirstToken(TokenTypes.STRING_LITERAL)
.getText()
.replaceAll("\"", ""))
.collect(Collectors.toList());
}
示例13: getFirstNodeInsideForWhileDoWhileBlocks
/**
* Gets first Ast node inside FOR, WHILE or DO-WHILE blocks if variable
* usage is met only inside the block (not in its declaration!).
* @param block
* Ast node represents FOR, WHILE or DO-WHILE block.
* @param variable
* Variable which is checked for content in block.
* @return If variable usage is met only inside the block
* (not in its declaration!) than return the first Ast node
* of this block, otherwise - null.
*/
private static DetailAST getFirstNodeInsideForWhileDoWhileBlocks(
DetailAST block, DetailAST variable) {
DetailAST firstNodeInsideBlock = null;
if (!isVariableInOperatorExpr(block, variable)) {
final DetailAST currentNode;
// Find currentNode for DO-WHILE block.
if (block.getType() == TokenTypes.LITERAL_DO) {
currentNode = block.getFirstChild();
}
// Find currentNode for FOR or WHILE block.
else {
// Looking for RPAREN ( ')' ) token to mark the end of operator
// expression.
currentNode = block.findFirstToken(TokenTypes.RPAREN).getNextSibling();
}
final int currentNodeType = currentNode.getType();
if (currentNodeType == TokenTypes.SLIST) {
firstNodeInsideBlock = currentNode.getFirstChild();
}
else if (currentNodeType != TokenTypes.EXPR) {
firstNodeInsideBlock = currentNode;
}
}
return firstNodeInsideBlock;
}
示例14: 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,
};
}
示例15: 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,
};
}