当前位置: 首页>>代码示例>>Java>>正文


Java SymTabAST类代码示例

本文整理汇总了Java中com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.SymTabAST的典型用法代码示例。如果您正苦于以下问题:Java SymTabAST类的具体用法?Java SymTabAST怎么用?Java SymTabAST使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SymTabAST类属于com.puppycrawl.tools.checkstyle.checks.usage.transmogrify包,在下文中一共展示了SymTabAST类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getReferences

import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.SymTabAST; //导入依赖的package包/类
/**
 * Returns the references to an AST.
 * @param aAST the AST for the references.
 * @return an iterator for the references to aAST.
 */
private Iterator getReferences(DetailAST aAST)
{
    final SymTabAST ident = getASTManager().get(aAST);
    final Definition definition =
        (Definition) ident.getDefinition();
    if (definition != null) {
        return definition.getReferences();
    }
    final Set dummy = new HashSet();
    return dummy.iterator();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:OneMethodPrivateFieldCheck.java

示例2: getReferenceCount

import com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.SymTabAST; //导入依赖的package包/类
/**
 * Determines the reference count for a DetailAST.
 * @param aAST the DetailAST to count.
 * @return the number of references to aAST.
 */
private int getReferenceCount(DetailAST aAST)
{
    final SymTabAST ident = getASTManager().get(aAST);
    if (ident == null) {
        return 0;
    }
    final Definition definition =
        (Definition) ident.getDefinition();
    if (definition != null) {
        return definition.getNumReferences();
    }

    return 0;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:AbstractUsageCheck.java

示例3: 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());
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:47,代码来源:OneMethodPrivateFieldCheck.java


注:本文中的com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.SymTabAST类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。