当前位置: 首页>>代码示例>>Java>>正文


Java Trees.getTree方法代码示例

本文整理汇总了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));
  }
}
 
开发者ID:uber,项目名称:NullAway,代码行数:14,代码来源:NullAway.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ChangeParamsTransformer.java

示例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)};
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ElementVisitor.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:TestGetTree.java

示例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);
}
 
开发者ID:FermioCloud,项目名称:java-code-templates,代码行数:13,代码来源:Util.java


注:本文中的com.sun.source.util.Trees.getTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。