本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.IDENT属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.IDENT属性的具体用法?Java TokenTypes.IDENT怎么用?Java TokenTypes.IDENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.IDENT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCanonicalName
/**
* Gets canonical type's name from given {@link TokenTypes#TYPE TYPE} node.
* @param type DetailAST {@link TokenTypes#TYPE TYPE} node.
* @return canonical type's name
*/
private static String getCanonicalName(DetailAST type) {
final StringBuilder canonicalNameBuilder = new StringBuilder(256);
DetailAST toVisit = type.getFirstChild();
while (toVisit != null) {
toVisit = getNextSubTreeNode(toVisit, type);
if (toVisit != null && toVisit.getType() == TokenTypes.IDENT) {
canonicalNameBuilder.append(toVisit.getText());
final DetailAST nextSubTreeNode = getNextSubTreeNode(toVisit, type);
if (nextSubTreeNode != null) {
if (nextSubTreeNode.getType() == TokenTypes.TYPE_ARGUMENTS) {
break;
}
canonicalNameBuilder.append('.');
}
}
}
return canonicalNameBuilder.toString();
}
示例2: containsAllSafeTokens
/**
* Looks for all "safe" Token combinations in the argument
* expression branch.
* @param expr the argument expression
* @return - true if any child matches the set of tokens, false if not
*/
private static boolean containsAllSafeTokens(final DetailAST expr) {
DetailAST arg = expr.getFirstChild();
arg = skipVariableAssign(arg);
boolean argIsNotNull = false;
if (arg.getType() == TokenTypes.PLUS) {
DetailAST child = arg.getFirstChild();
while (child != null
&& !argIsNotNull) {
argIsNotNull = child.getType() == TokenTypes.STRING_LITERAL
|| child.getType() == TokenTypes.IDENT;
child = child.getNextSibling();
}
}
return argIsNotNull
|| !arg.branchContains(TokenTypes.IDENT)
&& !arg.branchContains(TokenTypes.LITERAL_NULL);
}
示例3: visitToken
@Override
public void visitToken(DetailAST ast) {
switch (ast.getType()) {
case TokenTypes.IDENT :
processIdent(ast);
break;
case TokenTypes.CLASS_DEF :
case TokenTypes.INTERFACE_DEF :
case TokenTypes.ENUM_DEF :
case TokenTypes.ANNOTATION_DEF :
case TokenTypes.SLIST :
case TokenTypes.METHOD_DEF :
case TokenTypes.CTOR_DEF :
case TokenTypes.LITERAL_FOR :
current.push(frames.get(ast));
break;
default :
// do nothing
}
}
示例4: testGetRequiredTokens
@Test
public void testGetRequiredTokens() {
final UnusedImportsCheck testCheckObject =
new UnusedImportsCheck();
final int[] actual = testCheckObject.getRequiredTokens();
final int[] expected = {
TokenTypes.IDENT,
TokenTypes.IMPORT,
TokenTypes.STATIC_IMPORT,
// Definitions that may contain Javadoc...
TokenTypes.PACKAGE_DEF,
TokenTypes.ANNOTATION_DEF,
TokenTypes.ANNOTATION_FIELD_DEF,
TokenTypes.ENUM_DEF,
TokenTypes.ENUM_CONSTANT_DEF,
TokenTypes.CLASS_DEF,
TokenTypes.INTERFACE_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF,
TokenTypes.VARIABLE_DEF,
};
assertArrayEquals("Default required tokens are invalid", expected, actual);
}
示例5: getForIteratorVariables
/**
* Get all variables which for loop iterating part change in every loop.
* @param ast for loop literal(TokenTypes.LITERAL_FOR)
* @return names of variables change in iterating part of for
*/
private static Set<String> getForIteratorVariables(DetailAST ast) {
final Set<String> iteratorVariables = new HashSet<String>();
final DetailAST forIteratorAST = ast.findFirstToken(TokenTypes.FOR_ITERATOR);
final DetailAST forUpdateListAST = forIteratorAST.findFirstToken(TokenTypes.ELIST);
for (DetailAST iteratingExpressionAST : findChildrenOfExpressionType(forUpdateListAST)) {
if (MUTATION_OPERATIONS.contains(iteratingExpressionAST.getType())) {
final DetailAST oneVariableOperatorChild = iteratingExpressionAST.getFirstChild();
if (oneVariableOperatorChild.getType() == TokenTypes.IDENT) {
iteratorVariables.add(oneVariableOperatorChild.getText());
}
}
}
return iteratorVariables;
}
示例6: 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;
}
示例7: getWordNodeAtOccurrence
private SymTabAST getWordNodeAtOccurrence(Occurrence location) {
SymTabAST result = null;
SymTabAST fileNode = getFileNode(location.getFile());
if ( fileNode != null ) {
SymTabAST node = fileNode.getEnclosingNode(location.getLine(),
location.getColumn());
if ( (node != null) && (node.getType() == TokenTypes.IDENT) ) {
result = node;
}
}
return result;
}
示例8: ignoreChildren
/**
* sets meaningfulness for this node and its children
* @return <code>void</code>
* @see #setMeaningfulness(boolean)
*/
public void ignoreChildren() {
if (getType() == TokenTypes.IDENT) {
setMeaningfulness(false);
}
SymTabAST child = (SymTabAST) getFirstChild();
while (child != null) {
child.ignoreChildren();
child = (SymTabAST) child.getNextSibling();
}
}
示例9: handleNode
protected void handleNode( SymTabAST node ) {
if (node.getType() == TokenTypes.IDENT && node.isMeaningful()) {
_references.add( node );
if (node.getDefinition() != null && !(node.getDefinition() instanceof UnknownClass)) {
_resolvedReferences.add( node );
}
else {
_unresolvedReferences.add( node );
}
}
walkChildren( node );
}
示例10: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.NUM_DOUBLE,
TokenTypes.NUM_FLOAT,
TokenTypes.NUM_INT,
TokenTypes.NUM_LONG,
TokenTypes.IDENT,
TokenTypes.COMMENT_CONTENT,
TokenTypes.STRING_LITERAL,
TokenTypes.CHAR_LITERAL,
};
}
示例11: createChildren
/**
* Iterates children of the current node and
* recursively creates new Xpath-nodes.
*/
private void createChildren() {
DetailAST currentChild = detailAst.getFirstChild();
while (currentChild != null) {
if (currentChild.getType() != TokenTypes.IDENT) {
final ElementNode child = new ElementNode(root, this, currentChild);
addChild(child);
}
currentChild = currentChild.getNextSibling();
}
}
示例12: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.IDENT,
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.SLIST,
TokenTypes.OBJBLOCK,
TokenTypes.LITERAL_BREAK,
};
}
示例13: getDefaultTokens
@Override
public int[] getDefaultTokens() {
return new int[] {
TokenTypes.IDENT,
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.SLIST,
TokenTypes.OBJBLOCK,
TokenTypes.LITERAL_BREAK,
TokenTypes.VARIABLE_DEF,
};
}
示例14: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.IDENT,
TokenTypes.CTOR_DEF,
TokenTypes.METHOD_DEF,
TokenTypes.SLIST,
TokenTypes.OBJBLOCK,
TokenTypes.LITERAL_BREAK,
TokenTypes.VARIABLE_DEF,
TokenTypes.PARAMETER_DEF,
};
}
示例15: 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;
}