本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.LPAREN属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.LPAREN属性的具体用法?Java TokenTypes.LPAREN怎么用?Java TokenTypes.LPAREN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.LPAREN属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processClass
/**
* process the given <code>SymTabAST</code> as a class definition
*
* @param tree the <code>SymTabAST</code> to process
* @return <code>void</code>
* @see #makeClass(String, SymTabAST)
* @see #walkSiblings(SymTabAST, boolean)
* @see net.sourceforge.transmogrify.symtab.antlr.SymTabAST
*/
public void processClass(SymTabAST tree) {
String name = tree.findFirstToken(TokenTypes.IDENT).getText();
makeClass(name, tree);
final SymTabAST objblock =
tree.findFirstToken(TokenTypes.OBJBLOCK);
SymTabAST start = (SymTabAST)objblock.getFirstChild();
if (start != null) {
//skip LPAREN
if (start.getType() == TokenTypes.LPAREN) {
start = (SymTabAST)start.getNextSibling();
}
walkSiblings(start, false);
}
symbolTable.popScope();
}
示例2: getPositionAfter
/**
* Gets position after token (place of possible redundant whitespace).
* @param ast Node representing token.
* @return position after token.
*/
private static int getPositionAfter(DetailAST ast) {
final int after;
//If target of possible redundant whitespace is in method definition.
if (ast.getType() == TokenTypes.IDENT
&& ast.getNextSibling() != null
&& ast.getNextSibling().getType() == TokenTypes.LPAREN) {
final DetailAST methodDef = ast.getParent();
final DetailAST endOfParams = methodDef.findFirstToken(TokenTypes.RPAREN);
after = endOfParams.getColumnNo() + 1;
}
else {
after = ast.getColumnNo() + ast.getText().length();
}
return after;
}
示例3: processExpression
/**
* Checks parens inside {@link TokenTypes#EXPR}, {@link TokenTypes#QUESTION}
* and {@link TokenTypes#METHOD_CALL}.
* @param ast the token to check.
*/
private void processExpression(DetailAST ast) {
if (ast.branchContains(TokenTypes.LPAREN)) {
DetailAST childAst = ast.getFirstChild();
while (childAst != null) {
if (childAst.getType() == TokenTypes.LPAREN) {
processLeft(childAst);
}
else if (childAst.getType() == TokenTypes.RPAREN && !isInTypecast(childAst)) {
processRight(childAst);
}
else if (!isAcceptableToken(childAst)) {
//Traverse all subtree tokens which will never be configured
//to be launched in visitToken()
processExpression(childAst);
}
childAst = childAst.getNextSibling();
}
}
}
示例4: newIsConstructor
private boolean newIsConstructor(SymTabAST newNode) {
boolean result = false;
SymTabAST typeNode =
(SymTabAST) (newNode.getFirstChild().getNextSibling());
//handle Checkstyle grammar
if (typeNode.getType() == TokenTypes.LPAREN) {
typeNode = (SymTabAST) typeNode.getNextSibling();
}
if (typeNode.getType() == TokenTypes.ELIST) {
result = true;
}
return result;
}
示例5: resolveQuestion
private IClass resolveQuestion(
SymTabAST question,
Scope location,
IClass context,
boolean referencePhase) {
SymTabAST test = (SymTabAST) question.getFirstChild();
while (test.getType() == TokenTypes.LPAREN) {
test = (SymTabAST) test.getNextSibling();
}
SymTabAST leftBranch = (SymTabAST) test.getNextSibling();
while (leftBranch.getType() == TokenTypes.RPAREN) {
leftBranch = (SymTabAST) leftBranch.getNextSibling();
}
SymTabAST rightBranch = (SymTabAST) leftBranch.getNextSibling();
while (rightBranch.getType() != TokenTypes.COLON) {
rightBranch = (SymTabAST) rightBranch.getNextSibling();
}
rightBranch = (SymTabAST) rightBranch.getNextSibling();
resolveExpression(test, location, context, referencePhase);
IClass leftClass =
resolveExpression(leftBranch, location, context, referencePhase);
IClass rightClass =
resolveExpression(rightBranch, location, context, referencePhase);
return moreGeneral(leftClass, rightClass);
}
示例6: findLeftChild
/**
* Finds the left child of a binary operator, skipping parentheses.
* @param aExpression the node for the binary operator.
* @return the node for the left child.
*/
private SymTabAST findLeftChild(SymTabAST aExpression) {
SymTabAST leftChild = (SymTabAST) (aExpression.getFirstChild());
// handle Checkstyle grammar
while (leftChild.getType() == TokenTypes.LPAREN) {
leftChild = (SymTabAST) leftChild.getNextSibling();
}
return leftChild;
}
示例7: finishCreatingDefinition
/**
* begins at the base of the Table and starts finishing definition creation.
*
* @param def <code>Definition</code> needs to be completed
* @return <code>void</code>
* @throws <code>SymbolTableException</code>
* @see ClassFinisher
* @see VariableFinisher
* @see MethodFinisher
* @see CatchFinisher
*/
private void finishCreatingDefinition(Definition def) throws SymbolTableException {
if (def instanceof AnonymousInnerClass) {
AnonymousInnerClass innerClass = (AnonymousInnerClass)def;
innerClass.finishMakingDefinition();
}
else if (def instanceof ClassDef) {
new ClassFinisher(def).finish();
}
else if ( def instanceof VariableDef ) {
new VariableFinisher( def ).finish();
}
else if (def instanceof DefaultConstructor) {}
else if ( def instanceof MethodDef ) {
new MethodFinisher( def ).finish();
}
else if (def instanceof BlockDef) {
SymTabAST firstChild = (SymTabAST)def.getTreeNode().getFirstChild();
//handle Checkstyle grammar
if (firstChild.getType() == TokenTypes.LPAREN) {
firstChild = (SymTabAST) firstChild.getNextSibling();
}
if (firstChild.getType() == TokenTypes.PARAMETER_DEF) {
// this is a catch block
new CatchFinisher((BlockDef)def).finish();
}
}
if ( def instanceof Scope ) {
finishCreatingChildren((Scope)def);
}
}
示例8: processBlock
/**
* processes the current tree node as BlockDef
* @param tree current tree node
* @param makeAnonymousScopes
* @return <code>void</code>
*/
public void processBlock(SymTabAST tree, boolean makeAnonymousScopes) {
BlockDef block = makeBlock(tree);
symbolTable.pushScope(block);
//handle Checkstyle grammar
SymTabAST child = (SymTabAST)tree.getFirstChild();
if ((child != null) && (child.getType() == TokenTypes.LPAREN)) {
child = (SymTabAST) child.getNextSibling();
}
walkSiblings(child, makeAnonymousScopes);
symbolTable.popScope();
}
示例9: isExpressionCountable
/**
* Checks if an expression is countable for the ncss metric.
*
* @param ast the AST
* @return true if the expression is countable, false otherwise
*/
private static boolean isExpressionCountable(DetailAST ast) {
final boolean countable;
//count expressions only if they are direct child to a slist (method
// body, for loop...)
//or direct child of label,if,else,do,while,for
final int parentType = ast.getParent().getType();
switch (parentType) {
case TokenTypes.SLIST :
case TokenTypes.LABELED_STAT :
case TokenTypes.LITERAL_FOR :
case TokenTypes.LITERAL_DO :
case TokenTypes.LITERAL_WHILE :
case TokenTypes.LITERAL_IF :
case TokenTypes.LITERAL_ELSE :
//don't count if or loop conditions
final DetailAST prevSibling = ast.getPreviousSibling();
countable = prevSibling == null
|| prevSibling.getType() != TokenTypes.LPAREN;
break;
default :
countable = false;
break;
}
return countable;
}
示例10: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.DOT,
TokenTypes.COMMA,
TokenTypes.SEMI,
TokenTypes.ELLIPSIS,
TokenTypes.AT,
TokenTypes.LPAREN,
TokenTypes.RPAREN,
TokenTypes.ARRAY_DECLARATOR,
TokenTypes.RBRACK,
TokenTypes.METHOD_REF,
};
}
示例11: isSurrounded
/**
* Tests if the given {@code DetailAST} is surrounded by parentheses.
* In short, does {@code ast} have a previous sibling whose type is
* {@code TokenTypes.LPAREN} and a next sibling whose type is {@code
* TokenTypes.RPAREN}.
* @param ast the {@code DetailAST} to check if it is surrounded by
* parentheses.
* @return {@code true} if {@code ast} is surrounded by
* parentheses.
*/
private static boolean isSurrounded(DetailAST ast) {
// if previous sibling is left parenthesis,
// next sibling can't be other than right parenthesis
final DetailAST prev = ast.getPreviousSibling();
return prev != null && prev.getType() == TokenTypes.LPAREN;
}
示例12: isLambdaSingleParameterSurrounded
/**
* Tests if the given lambda node has a single parameter, no defined type, and is surrounded
* by parentheses.
* @param ast a {@code DetailAST} whose type is
* {@code TokenTypes.LAMBDA}.
* @return {@code true} if the lambda has a single parameter, no defined type, and is
* surrounded by parentheses.
*/
private static boolean isLambdaSingleParameterSurrounded(DetailAST ast) {
final DetailAST firstChild = ast.getFirstChild();
return firstChild.getType() == TokenTypes.LPAREN
&& firstChild.getNextSibling().getChildCount(TokenTypes.PARAMETER_DEF) == 1
&& firstChild.getNextSibling().getFirstChild().findFirstToken(TokenTypes.TYPE)
.getChildCount() == 0;
}
示例13: isExprSurrounded
/**
* Tests if the given expression node is surrounded by parentheses.
* @param ast a {@code DetailAST} whose type is
* {@code TokenTypes.EXPR}.
* @return {@code true} if the expression is surrounded by
* parentheses.
*/
private static boolean isExprSurrounded(DetailAST ast) {
return ast.getFirstChild().getType() == TokenTypes.LPAREN;
}