本文整理汇总了Java中com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.SymTabAST.getDetailNode方法的典型用法代码示例。如果您正苦于以下问题:Java SymTabAST.getDetailNode方法的具体用法?Java SymTabAST.getDetailNode怎么用?Java SymTabAST.getDetailNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.SymTabAST
的用法示例。
在下文中一共展示了SymTabAST.getDetailNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyTo
import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.SymTabAST; //导入方法依赖的package包/类
/** @see com.puppycrawl.tools.checkstyle.checks.usage.AbstractUsageCheck */
public void applyTo(Set aNodes)
{
// apply the check to each private field
final Set methods = new HashSet();
final Iterator it = aNodes.iterator();
while (it.hasNext()) {
methods.clear();
final DetailAST nameAST = (DetailAST) it.next();
// find methods using the field
final Iterator refIt = getReferences(nameAST);
while (refIt.hasNext()) {
final Reference ref = (Reference) refIt.next();
final SymTabAST refNode = ref.getTreeNode();
final DetailAST refDetail = refNode.getDetailNode();
// don't need to check a self-reference
if (refDetail == nameAST) {
continue;
}
DetailAST parent = refDetail.getParent();
while (parent != null) {
final int type = parent.getType();
if ((type == TokenTypes.METHOD_DEF)
|| (type == TokenTypes.CTOR_DEF)
|| (type == TokenTypes.INSTANCE_INIT)
|| (type == TokenTypes.STATIC_INIT))
{
methods.add(parent);
break;
}
// initializer for inner class?
else if (type == TokenTypes.CLASS_DEF) {
break;
}
parent = parent.getParent();
}
}
if (methods.size() == 1) {
log(
nameAST.getLineNo(),
nameAST.getColumnNo(),
getErrorKey(),
nameAST.getText());
}
}
}