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


Java TreePathScanner.scan方法代码示例

本文整理汇总了Java中com.sun.source.util.TreePathScanner.scan方法的典型用法代码示例。如果您正苦于以下问题:Java TreePathScanner.scan方法的具体用法?Java TreePathScanner.scan怎么用?Java TreePathScanner.scan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.source.util.TreePathScanner的用法示例。


在下文中一共展示了TreePathScanner.scan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: typeProcess

import com.sun.source.util.TreePathScanner; //导入方法依赖的package包/类
/**
 * Visit the tree path for the type element.
 */
@Override
public void typeProcess(TypeElement e, TreePath p) {
    currentRoot = p.getCompilationUnit();

    TreePathScanner<?, ?> scanner = null;
    try {
        scanner = createTreePathScanner(currentRoot);
        scanner.scan(p, null);
    } catch (Throwable t) {
        System.err.println("BasicTypeProcessor.typeProcess: unexpected Throwable (" +
                t.getClass().getSimpleName() + ")  when processing "
                + currentRoot.getSourceFile().getName() +
                (t.getMessage()!=null ? "; message: " + t.getMessage() : ""));
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:19,代码来源:BasicTypeProcessor.java

示例2: typeProcess

import com.sun.source.util.TreePathScanner; //导入方法依赖的package包/类
/** Visit the tree path for the type element. */
@Override
public void typeProcess(TypeElement e, TreePath p) {
    currentRoot = p.getCompilationUnit();

    TreePathScanner<?, ?> scanner = null;
    try {
        scanner = createTreePathScanner(currentRoot);
        scanner.scan(p, null);
    } catch (Throwable t) {
        System.err.println(
                "BasicTypeProcessor.typeProcess: unexpected Throwable ("
                        + t.getClass().getSimpleName()
                        + ")  when processing "
                        + currentRoot.getSourceFile().getName()
                        + (t.getMessage() != null ? "; message: " + t.getMessage() : ""));
    }
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:19,代码来源:BasicTypeProcessor.java

示例3: process

import com.sun.source.util.TreePathScanner; //导入方法依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {

    if (annotations.isEmpty()) {
        // called with no annotations
        return true;
    }

    for (TypeElement annotation : annotations) {

        TreePathScanner<Void, Trees> scanner = scanners.get(annotation.getQualifiedName().toString());
        if (scanner == null) {
            // annotation is not intended to be used for code checking
            continue;
        }

        // check whether the annotation is used in correct place and perform the verification
        // of target element using appropriate scanner
        Target target = annotation.getAnnotation(Target.class);
        Set<? extends Element> annotatedElements = roundEnv.getElementsAnnotatedWith(annotation);
        for (Element element : annotatedElements) {

            if (target == null) {
                // annotation can be used everywhere
            } else {

                boolean usedInCorrectPlace = false;

                for (ElementType type : target.value()) {
                    if (UtilsCTree.convertToElementType(element.getKind()).equals(type)) {
                        usedInCorrectPlace = true;
                    }
                }

                if (!usedInCorrectPlace) {
                    messager.printMessage(Diagnostic.Kind.ERROR, "The @" + annotation.getSimpleName() +
                        " annotation is declared to be used with " + target.toString());
                    continue;
                }
            }

            scanner.scan(trees.getPath(element), trees);
        }
    }

    return true;
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:48,代码来源:ProActiveProcessorCTree.java


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