本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.COMMA属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.COMMA属性的具体用法?Java TokenTypes.COMMA怎么用?Java TokenTypes.COMMA使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.COMMA属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveParameters
/**
* Resolves the types found in a method call. Any references found
* in the process are created. Returns a <code>MethodSignature</code> for
* the types of the parameters.
*
* @param elist The <code>SymTabAST</code> for the list of parameters
* @return the signature of the parameters
*/
private MethodSignature resolveParameters(
SymTabAST elist,
Scope location,
IClass context,
boolean referencePhase) {
Vector parameters = new Vector();
SymTabAST expr = (SymTabAST) (elist.getFirstChild());
while (expr != null) {
if (expr.getType() != TokenTypes.COMMA) {
IClass parameter =
resolveExpression((SymTabAST) (expr
.getFirstChild()),
location,
context,
referencePhase);
parameters.add(parameter);
}
expr = (SymTabAST) (expr.getNextSibling());
}
return new MethodSignature(parameters);
}
示例2: logCommaViolation
/**
* Logs a trailing array comma violation if one exists.
*
* @param ast the array init
* {@link TokenTypes#ANNOTATION_ARRAY_INIT ANNOTATION_ARRAY_INIT}.
*/
private void logCommaViolation(final DetailAST ast) {
final DetailAST rCurly = ast.findFirstToken(TokenTypes.RCURLY);
//comma can be null if array is empty
final DetailAST comma = rCurly.getPreviousSibling();
if (trailingArrayComma == TrailingArrayComma.ALWAYS
&& (comma == null || comma.getType() != TokenTypes.COMMA)) {
log(rCurly.getLineNo(),
rCurly.getColumnNo(), MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING);
}
else if (trailingArrayComma == TrailingArrayComma.NEVER
&& comma != null && comma.getType() == TokenTypes.COMMA) {
log(comma.getLineNo(),
comma.getColumnNo(), MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT);
}
}
示例3: isVariableDefCountable
/**
* Checks if a variable definition is countable.
*
* @param ast the AST
* @return true if the variable definition is countable, false otherwise
*/
private static boolean isVariableDefCountable(DetailAST ast) {
boolean countable = false;
//count variable definitions only if they are direct child to a slist or
// object block
final int parentType = ast.getParent().getType();
if (parentType == TokenTypes.SLIST
|| parentType == TokenTypes.OBJBLOCK) {
final DetailAST prevSibling = ast.getPreviousSibling();
//is countable if no previous sibling is found or
//the sibling is no COMMA.
//This is done because multiple assignment on one line are counted
// as 1
countable = prevSibling == null
|| prevSibling.getType() != TokenTypes.COMMA;
}
return countable;
}
示例4: visitToken
@Override
public void visitToken(DetailAST detailAST) {
final DetailAST methodDef = detailAST.getParent();
// Check if the method with the given name should be ignored.
if (!isIgnorableMethod(methodDef)) {
DetailAST token = detailAST.getFirstChild();
while (token != null) {
if (token.getType() != TokenTypes.COMMA) {
final FullIdent ident = FullIdent.createFullIdent(token);
if (illegalClassNames.contains(ident.getText())) {
log(token, MSG_KEY, ident.getText());
}
}
token = token.getNextSibling();
}
}
}
示例5: getDetailsForLambda
/**
* Collects validation details for Lambdas.
* @param ast a {@code DetailAST} value
* @return an object containing all details to make a validation
*/
private static Details getDetailsForLambda(DetailAST ast) {
final DetailAST lcurly = ast.findFirstToken(TokenTypes.SLIST);
boolean shouldCheckLastRcurly = false;
DetailAST nextToken = getNextToken(ast);
if (nextToken.getType() != TokenTypes.RPAREN
&& nextToken.getType() != TokenTypes.COMMA) {
shouldCheckLastRcurly = true;
nextToken = getNextToken(nextToken);
}
DetailAST rcurly = null;
if (lcurly != null) {
rcurly = lcurly.getLastChild();
}
return new Details(lcurly, rcurly, nextToken, shouldCheckLastRcurly);
}
示例6: getTypeArgsClassNames
/**
* Returns a list of type parameters class names.
* @param typeArgs type arguments token.
* @return a list of type parameters class names.
*/
private static List<String> getTypeArgsClassNames(DetailAST typeArgs) {
final List<String> typeClassNames = new ArrayList<String>();
DetailAST type = typeArgs.findFirstToken(TokenTypes.TYPE_ARGUMENT);
boolean isCanonicalName = isCanonicalName(type);
String typeName = getTypeName(type, isCanonicalName);
typeClassNames.add(typeName);
DetailAST sibling = type.getNextSibling();
while (sibling.getType() == TokenTypes.COMMA) {
type = sibling.getNextSibling();
isCanonicalName = isCanonicalName(type);
typeName = getTypeName(type, isCanonicalName);
typeClassNames.add(typeName);
sibling = type.getNextSibling();
}
return typeClassNames;
}
示例7: handleMethod
/**
* processes a <code>MethodDef</code> and resolves references in it
*
* @param method the <code>MethodDef</code> to process
*/
protected void handleMethod(MethodDef method) {
SymTabAST node = method.getTreeNode();
SymTabAST nameNode = node.findFirstToken(TokenTypes.IDENT);
nameNode.setDefinition(method, method, true);
// references to classes in return type
SymTabAST returnTypeNode = node.findFirstToken(TokenTypes.TYPE);
if (returnTypeNode != null) {
// this is not a constructor
resolveExpression(returnTypeNode, method, null, true);
}
SymTabAST throwsNode =
node.findFirstToken(TokenTypes.LITERAL_THROWS);
if (throwsNode != null) {
SymTabAST exception = (SymTabAST) throwsNode.getFirstChild();
while (exception != null) {
// handle Checkstyle grammar
if (exception.getType() != TokenTypes.COMMA) {
resolveClass(exception, method, null, true);
}
exception = (SymTabAST) exception.getNextSibling();
}
}
// references to classes in parameters
// the body -- this would be better its own function
SymTabAST slist = node.findFirstToken(TokenTypes.SLIST);
if (slist != null) {
handleSList(slist, method);
}
}
示例8: resolveArrayInitializer
/**
* Resolves a constructor call.
*
* @param tree the root node of the constructor call
* @return the <code>ClassDef</code> for the class instantiated by the
* constructor
*/
private void resolveArrayInitializer(
SymTabAST initializerNode,
Scope location,
IClass context,
boolean referencePhase) {
SymTabAST child = (SymTabAST) (initializerNode.getFirstChild());
while (child != null) {
if (child.getType() != TokenTypes.COMMA) {
resolveExpression(child, location, context, referencePhase);
}
child = (SymTabAST) (child.getNextSibling());
}
}
示例9: visitLiteralThrows
/**
* Visits throws clause and collects all exceptions we throw.
* @param literalThrows throws to process.
*/
public void visitLiteralThrows(DetailAST literalThrows) {
for (DetailAST childAST = literalThrows.getFirstChild();
childAST != null;
childAST = childAST.getNextSibling()) {
if (childAST.getType() != TokenTypes.COMMA) {
addReferencedClassName(childAST);
}
}
}
示例10: 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);
}
}
}
}
}
示例11: visitToken
@Override
public void visitToken(DetailAST arrayInit) {
final DetailAST rcurly = arrayInit.findFirstToken(TokenTypes.RCURLY);
final DetailAST previousSibling = rcurly.getPreviousSibling();
if (arrayInit.getLineNo() != rcurly.getLineNo()
&& arrayInit.getChildCount() != 1
&& rcurly.getLineNo() != previousSibling.getLineNo()
&& arrayInit.getLineNo() != previousSibling.getLineNo()
&& previousSibling.getType() != TokenTypes.COMMA) {
log(rcurly.getLineNo(), MSG_KEY);
}
}
示例12: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.COMMA,
TokenTypes.SEMI,
TokenTypes.POST_INC,
TokenTypes.POST_DEC,
TokenTypes.ELLIPSIS,
};
}
示例13: 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,
};
}
示例14: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.COMMA,
TokenTypes.SEMI,
TokenTypes.TYPECAST,
TokenTypes.LITERAL_IF,
TokenTypes.LITERAL_ELSE,
TokenTypes.LITERAL_WHILE,
TokenTypes.LITERAL_DO,
TokenTypes.LITERAL_FOR,
TokenTypes.DO_WHILE,
};
}
示例15: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.DOT,
TokenTypes.COMMA,
};
}