當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。