本文整理汇总了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() : ""));
}
}
示例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() : ""));
}
}
示例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;
}