本文整理匯總了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;
}