本文整理汇总了Java中com.sun.tools.javac.tree.TreeTranslator类的典型用法代码示例。如果您正苦于以下问题:Java TreeTranslator类的具体用法?Java TreeTranslator怎么用?Java TreeTranslator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TreeTranslator类属于com.sun.tools.javac.tree包,在下文中一共展示了TreeTranslator类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import com.sun.tools.javac.tree.TreeTranslator; //导入依赖的package包/类
@Override
public void process( TypeElement typeElement, TypeProcessor typeProcessor, IssueReporter<JavaFileObject> issueReporter )
{
if( typeElement.getKind() == ElementKind.CLASS || typeElement.getKind() == ElementKind.INTERFACE )
{
TreeTranslator visitor = new ExtensionTransformer( this, typeProcessor );
typeProcessor.getTree().accept( visitor );
}
}
示例2: insertBootstrap
import com.sun.tools.javac.tree.TreeTranslator; //导入依赖的package包/类
private void insertBootstrap( JCTree.JCClassDecl tree )
{
TreeTranslator visitor = new BootstrapInserter( this );
tree.accept( visitor );
}
示例3: process
import com.sun.tools.javac.tree.TreeTranslator; //导入依赖的package包/类
@Override // from AbstractProcessor
public boolean process (Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
{
if (_trees == null) {
return false;
}
for (Element elem : roundEnv.getRootElements()) {
final JCCompilationUnit unit = toUnit(elem);
if (unit == null) {
continue;
}
// we only want to operate on files being compiled from source; if they're already
// classfiles then we've already run or we're looking at a library class
if (unit.sourcefile.getKind() != JavaFileObject.Kind.SOURCE) {
System.err.println("Skipping non-source-file " + unit.sourcefile);
continue;
}
// System.err.println("Processing " + unit.sourcefile);
unit.accept(new TreeTranslator() {
public void visitVarDef (JCVariableDecl tree) {
super.visitVarDef(tree);
// if this variable declaration's modifiers have already been processed
// (variables can share modifiers, ie. public @var int foo, bar), then don't
// repeat process this declaration
if (_seen.contains(tree.mods)) {
return;
}
_seen.add(tree.mods);
// note the number of annotations on this var
int ocount = tree.mods.annotations.size();
// remove the @var annotation if we see it
tree.mods.annotations = removeVar(tree.mods.annotations);
// if we didn't remove anything, then make the variable final
if (tree.mods.annotations.size() == ocount) {
tree.mods.flags |= Flags.FINAL;
// check for retardation
} else if ((tree.mods.flags & Flags.FINAL) != 0) {
_procenv.getMessager().printMessage(
Diagnostic.Kind.WARNING,
"@var annotated variable also marked final: " + tree,
// TODO: this should work but it doesn't, sigh
_trees.getElement(TreePath.getPath(unit, tree)));
}
}
protected Set<JCModifiers> _seen = new HashSet<JCModifiers>();
});
}
// TODO: it would be nice if we could say that we handled @var but there seems to be no way
// to say you accept "*" but then tell javac you handled some of the annotations you saw
return _handleStar;
}