本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.SEMI属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.SEMI属性的具体用法?Java TokenTypes.SEMI怎么用?Java TokenTypes.SEMI使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.SEMI属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveGoto
/**
* resolves references in a a break statement
*
* @param expression the <code>SymTabAST</code> for the expression
* @param location the <code>Scope</code> where the expression occurs
* @param context the <code>Scope</code> in which the expression occurs
* (where the search for a defintion begins)
*
* @return the <code>Scope</code> for the int primitive type
*/
private IClass resolveGoto(
SymTabAST expression,
Scope location,
IClass context,
boolean referencePhase) {
SymTabAST label = (SymTabAST) (expression.getFirstChild());
// handle Checkstyle grammar
if (label != null && (label.getType() != TokenTypes.SEMI)) {
LabelDef def = location.getLabelDefinition(label.getText());
if (def != null) {
label.setDefinition(def, location, referencePhase);
}
}
return null;
}
示例2: processIf
/**
* process the given SymTabAST as an if block
*
* @param tree the SymTabAST to process
* @return <code>void</code>
* @see #makeBlock(SymTabAST)
* @see #walkTree(SymTabAST, boolean)
* @see #processElse(SymTabAST)
*/
public void processIf(SymTabAST tree) {
BlockDef block = makeBlock(tree);
SymTabAST expr = tree.findFirstToken(TokenTypes.EXPR);
SymTabAST ifBranch = (SymTabAST)expr.getNextSibling();
// handle Checkstyle grammar
if (ifBranch.getType() == TokenTypes.RPAREN) {
ifBranch = (SymTabAST) ifBranch.getNextSibling();
}
SymTabAST elseBranch = (SymTabAST)ifBranch.getNextSibling();
// handle Checkstyle grammar
if ((elseBranch != null) && (elseBranch.getType() == TokenTypes.SEMI)) {
elseBranch = (SymTabAST) elseBranch.getNextSibling();
}
if ((elseBranch != null) && (elseBranch.getType() == TokenTypes.LITERAL_ELSE)) {
elseBranch = (SymTabAST) elseBranch.getFirstChild();
}
symbolTable.pushScope( block );
walkTree(expr, false);
walkTree(ifBranch, false);
symbolTable.popScope();
processElse(elseBranch);
}
示例3: getImportedTypeCanonicalName
/**
* Gets imported type's
* <a href="https://docs.oracle.com/javase/specs/jls/se8/html/jls-6.html#jls-6.7">
* canonical name</a>.
* @param importAst {@link TokenTypes#IMPORT Import}
* @return Imported canonical type's name.
*/
private static String getImportedTypeCanonicalName(DetailAST importAst) {
final StringBuilder canonicalNameBuilder = new StringBuilder(256);
DetailAST toVisit = importAst;
while (toVisit != null) {
toVisit = getNextSubTreeNode(toVisit, importAst);
if (toVisit != null && toVisit.getType() == TokenTypes.IDENT) {
canonicalNameBuilder.append(toVisit.getText());
final DetailAST nextSubTreeNode = getNextSubTreeNode(toVisit, importAst);
if (nextSubTreeNode.getType() != TokenTypes.SEMI) {
canonicalNameBuilder.append('.');
}
}
}
return canonicalNameBuilder.toString();
}
示例4: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.SEMI:
checkIfSemicolonIsInDifferentLineThanPrevious(ast);
break;
case TokenTypes.FOR_ITERATOR:
forStatementEnd = ast.getLineNo();
break;
case TokenTypes.LAMBDA:
isInLambda = true;
countOfSemiInLambda.push(0);
break;
default:
inForHeader = true;
break;
}
}
示例5: leaveToken
@Override
public void leaveToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.SEMI:
lastStatementEnd = ast.getLineNo();
forStatementEnd = -1;
lambdaStatementEnd = -1;
break;
case TokenTypes.FOR_ITERATOR:
inForHeader = false;
break;
case TokenTypes.LAMBDA:
countOfSemiInLambda.pop();
if (countOfSemiInLambda.isEmpty()) {
isInLambda = false;
}
lambdaStatementEnd = ast.getLineNo();
break;
default:
break;
}
}
示例6: getDistributedPreviousStatement
/**
* Returns the first token of the distributed previous statement of comment.
* @param comment comment to check.
* @return the first token of the distributed previous statement of comment.
*/
private static DetailAST getDistributedPreviousStatement(DetailAST comment) {
DetailAST currentToken = comment.getPreviousSibling();
while (isComment(currentToken)) {
currentToken = currentToken.getPreviousSibling();
}
final DetailAST previousStatement;
if (currentToken.getType() == TokenTypes.SEMI) {
currentToken = currentToken.getPreviousSibling();
while (currentToken.getFirstChild() != null) {
currentToken = currentToken.getFirstChild();
}
previousStatement = currentToken;
}
else {
previousStatement = currentToken;
}
return previousStatement;
}
示例7: visitToken
@Override
public void visitToken(DetailAST ast) {
DetailAST nextNode = ast.getNextSibling();
if (nextNode != null) {
final boolean isCommaSeparated = nextNode.getType() == TokenTypes.COMMA;
if (isCommaSeparated
|| nextNode.getType() == TokenTypes.SEMI) {
nextNode = nextNode.getNextSibling();
}
if (nextNode != null
&& nextNode.getType() == TokenTypes.VARIABLE_DEF) {
final DetailAST firstNode = CheckUtils.getFirstNode(ast);
if (isCommaSeparated) {
// Check if the multiple variable declarations are in a
// for loop initializer. If they are, then no warning
// should be displayed. Declaring multiple variables in
// a for loop initializer is a good way to minimize
// variable scope. Refer Feature Request Id - 2895985
// for more details
if (ast.getParent().getType() != TokenTypes.FOR_INIT) {
log(firstNode, MSG_MULTIPLE_COMMA);
}
}
else {
final DetailAST lastNode = getLastNode(ast);
final DetailAST firstNextNode = CheckUtils.getFirstNode(nextNode);
if (firstNextNode.getLineNo() == lastNode.getLineNo()) {
log(firstNode, MSG_MULTIPLE);
}
}
}
}
}
示例8: visitReturn
/**
* Examines the return statement and tells context about it.
* @param ast return statement to check.
*/
private void visitReturn(DetailAST ast) {
// we can't identify which max to use for lambdas, so we can only assign
// after the first return statement is seen
if (ast.getFirstChild().getType() == TokenTypes.SEMI) {
context.visitLiteralReturn(maxForVoid, true);
}
else {
context.visitLiteralReturn(max, false);
}
}
示例9: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.SEMI,
TokenTypes.FOR_INIT,
TokenTypes.FOR_ITERATOR,
TokenTypes.LAMBDA,
};
}
示例10: isBooleanLiteralReturnStatement
/**
* Returns if an AST is a return statement with a boolean literal.
*
* <p>Returns {@code true} iff ast represents
* <br/>
* <pre>
* return true/false;
* </pre>
*
* @param ast the syntax tree to check
* @return if ast is a return statement with a boolean literal.
*/
private static boolean isBooleanLiteralReturnStatement(AST ast) {
boolean booleanReturnStatement = false;
if (ast != null && ast.getType() == TokenTypes.LITERAL_RETURN) {
final AST expr = ast.getFirstChild();
if (expr.getType() != TokenTypes.SEMI) {
final AST value = expr.getFirstChild();
booleanReturnStatement = isBooleanLiteralType(value.getType());
}
}
return booleanReturnStatement;
}
示例11: isDistributedExpression
/**
* Checks whether the previous statement of a comment is a method call chain or
* string concatenation statement distributed over two ore more lines.
* @param comment comment to check.
* @return true if the previous statement is a distributed expression.
*/
private boolean isDistributedExpression(DetailAST comment) {
DetailAST previousSibling = comment.getPreviousSibling();
while (previousSibling != null && isComment(previousSibling)) {
previousSibling = previousSibling.getPreviousSibling();
}
boolean isDistributed = false;
if (previousSibling != null) {
if (previousSibling.getType() == TokenTypes.SEMI
&& isOnPreviousLineIgnoringComments(comment, previousSibling)) {
DetailAST currentToken = previousSibling.getPreviousSibling();
while (currentToken.getFirstChild() != null) {
currentToken = currentToken.getFirstChild();
}
if (currentToken.getType() == TokenTypes.COMMENT_CONTENT) {
currentToken = currentToken.getParent();
while (isComment(currentToken)) {
currentToken = currentToken.getNextSibling();
}
}
if (previousSibling.getLineNo() != currentToken.getLineNo()) {
isDistributed = true;
}
}
else {
isDistributed = isStatementWithPossibleCurlies(previousSibling);
}
}
return isDistributed;
}
示例12: getPrevStatementWhenCommentIsUnderCase
/**
* Gets previous statement for comment which is placed immediately under case.
* @param parentStatement comment's parent statement.
* @return comment's previous statement or null if previous statement is absent.
*/
private static DetailAST getPrevStatementWhenCommentIsUnderCase(DetailAST parentStatement) {
DetailAST prevStmt = null;
final DetailAST prevBlock = parentStatement.getPreviousSibling();
if (prevBlock.getLastChild() != null) {
DetailAST blockBody = prevBlock.getLastChild().getLastChild();
if (blockBody.getType() == TokenTypes.SEMI) {
blockBody = blockBody.getPreviousSibling();
}
if (blockBody.getType() == TokenTypes.EXPR) {
if (isUsingOfObjectReferenceToInvokeMethod(blockBody)) {
prevStmt = findStartTokenOfMethodCallChain(blockBody);
}
else {
prevStmt = blockBody.getFirstChild().getFirstChild();
}
}
else {
if (blockBody.getType() == TokenTypes.SLIST) {
prevStmt = blockBody.getParent().getParent();
}
else {
prevStmt = blockBody;
}
}
if (isComment(prevStmt)) {
prevStmt = prevStmt.getNextSibling();
}
}
return prevStmt;
}
示例13: getVarDefStatementSemicolon
/**
* Returns semicolon for variable definition statement.
* @param variableDef
* ast node of type TokenTypes.VARIABLE_DEF
* @return ast node of type TokenTypes.SEMI
*/
private static DetailAST getVarDefStatementSemicolon(DetailAST variableDef) {
DetailAST lastNode = variableDef.getLastChild();
if (lastNode.getType() != TokenTypes.SEMI) {
lastNode = variableDef.getNextSibling();
}
return lastNode;
}
示例14: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.COMMA,
TokenTypes.SEMI,
TokenTypes.POST_INC,
TokenTypes.POST_DEC,
TokenTypes.ELLIPSIS,
};
}
示例15: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.COMMA,
TokenTypes.SEMI,
TokenTypes.POST_INC,
TokenTypes.POST_DEC,
TokenTypes.DOT,
TokenTypes.GENERIC_START,
TokenTypes.GENERIC_END,
TokenTypes.ELLIPSIS,
TokenTypes.METHOD_REF,
};
}