本文整理汇总了Java中com.sun.source.util.Trees.getTree方法的典型用法代码示例。如果您正苦于以下问题:Java Trees.getTree方法的具体用法?Java Trees.getTree怎么用?Java Trees.getTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.source.util.Trees
的用法示例。
在下文中一共展示了Trees.getTree方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGuaranteedNonNullFromInvokes
import com.sun.source.util.Trees; //导入方法依赖的package包/类
private void addGuaranteedNonNullFromInvokes(
VisitorState state,
Trees trees,
Set<Element> safeInitMethods,
AccessPathNullnessAnalysis nullnessAnalysis,
Set<Element> guaranteedNonNull) {
for (Element invoked : safeInitMethods) {
Tree invokedTree = trees.getTree(invoked);
guaranteedNonNull.addAll(
nullnessAnalysis.getNonnullFieldsOfReceiverAtExit(
new TreePath(state.getPath(), invokedTree), state.context));
}
}
示例2: resolveAnonymousClassConstructor
import com.sun.source.util.Trees; //导入方法依赖的package包/类
/**
* special treatment for anonymous classes to resolve the proper constructor
* of extended class instead of the synthetic one.
* @see <a href="https://netbeans.org/bugzilla/show_bug.cgi?id=168775">#168775</a>
*/
private Element resolveAnonymousClassConstructor(Element el, NewClassTree tree, final Trees trees) {
if (el != null && tree.getClassBody() != null) {
Tree t = trees.getTree(el);
if (t != null && t.getKind() == Tree.Kind.METHOD) {
MethodTree constructorTree = (MethodTree) t;
Tree superCall = constructorTree.getBody().getStatements().get(0);
TreePath superCallPath = trees.getPath(
getCurrentPath().getCompilationUnit(),
((ExpressionStatementTree) superCall).getExpression());
el = trees.getElement(superCallPath);
}
}
return el;
}
示例3: getPosition
import com.sun.source.util.Trees; //导入方法依赖的package包/类
private long[] getPosition( Element e ) {
Trees trees = cc.getTrees();
CompilationUnitTree cut = cc.getCompilationUnit();
Tree t = trees.getTree(e);
if ( t == null ) {
return new long[]{-1,-1};
}
SourcePositions sourcePositions = trees.getSourcePositions();
return new long[] {sourcePositions.getStartPosition(cut, t),sourcePositions.getEndPosition(cut, t)};
}
示例4: process
import com.sun.source.util.Trees; //导入方法依赖的package包/类
public boolean process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnvironment)
{
final Trees trees = Trees.instance(processingEnv);
for (TypeElement e : typesIn(roundEnvironment.getRootElements())) {
ClassTree node = trees.getTree(e);
System.out.println(node.toString());
}
return true;
}
示例5: hasInitializer
import com.sun.source.util.Trees; //导入方法依赖的package包/类
/**
* Static helper method to determine if a given variable declaration
* includes an initializer.
*
* @param element
* @param trees
* @return
*/
static boolean hasInitializer(final VariableElement element, final Trees trees) {
JCVariableDecl tree = (JCVariableDecl)trees.getTree(element);
return (tree.init != null);
}