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


Java DocTreePath.getLeaf方法代码示例

本文整理汇总了Java中com.sun.source.util.DocTreePath.getLeaf方法的典型用法代码示例。如果您正苦于以下问题:Java DocTreePath.getLeaf方法的具体用法?Java DocTreePath.getLeaf怎么用?Java DocTreePath.getLeaf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.source.util.DocTreePath的用法示例。


在下文中一共展示了DocTreePath.getLeaf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performRewrite

import com.sun.source.util.DocTreePath; //导入方法依赖的package包/类
@Override
protected void performRewrite(TransformationContext ctx) throws Exception {
    WorkingCopy javac = ctx.getWorkingCopy();
    DocTreePath path = dtph.resolve(javac);
    if(path == null) {
        LOG.log(Level.WARNING, "Cannot resolve DocTreePathHandle: {0}", dtph);
        return;
    }
    DocCommentTree docComment = path.getDocComment();
    TreeMaker make = javac.getTreeMaker();
    final List<DocTree> blockTags = new LinkedList<DocTree>();
    for (DocTree docTree : docComment.getBlockTags()) {
        if (docTree != path.getLeaf()) {
            blockTags.add(docTree);
        }
    }
    DocCommentTree newDoc = make.DocComment(docComment.getFirstSentence(), docComment.getBody(), blockTags);
    Tree tree = ctx.getPath().getLeaf();
    javac.rewrite(tree, docComment, newDoc);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:RemoveTagFix.java

示例2: qualifyDocReference

import com.sun.source.util.DocTreePath; //导入方法依赖的package包/类
/**
 * Fully qualifies a javadoc reference, e.g. for replacing {@code {@link List}} with {@code {@link
 * java.util.List}}
 *
 * @param fix the fix builder to add to
 * @param docPath the path to a {@link DCTree.DCReference} element
 */
public static void qualifyDocReference(
    SuggestedFix.Builder fix, DocTreePath docPath, VisitorState state) {

  DocTree leaf = docPath.getLeaf();
  checkArgument(
      leaf.getKind() == DocTree.Kind.REFERENCE,
      "expected a path to a reference, got %s instead",
      leaf.getKind());
  DCTree.DCReference reference = (DCTree.DCReference) leaf;

  Symbol sym = (Symbol) JavacTrees.instance(state.context).getElement(docPath);
  if (sym == null) {
    return;
  }
  String refString = reference.toString();
  String qualifiedName;
  int idx = refString.indexOf('#');
  if (idx >= 0) {
    qualifiedName = sym.owner.getQualifiedName() + refString.substring(idx, refString.length());
  } else {
    qualifiedName = sym.getQualifiedName().toString();
  }

  replaceDocTree(fix, docPath, qualifiedName);
}
 
开发者ID:google,项目名称:error-prone,代码行数:33,代码来源:SuggestedFixes.java

示例3: getReferenceClass

import com.sun.source.util.DocTreePath; //导入方法依赖的package包/类
/**Find the type (the part before {@code #}) that is being referenced by the given {@link ReferenceTree}.
     * 
     * @param path the leaf must be {@link ReferenceTree}
     * @return the referred type, or {@code null} if none.
     * @since 0.124
     */
    public @CheckForNull ExpressionTree getReferenceClass(@NonNull DocTreePath path) {
        TreePath tp = path.getTreePath();
        DCReference ref = (DCReference) path.getLeaf();
        
        ((DocTrees) this.info.getTrees()).getElement(path);
//        was:
//        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
        
        return (ExpressionTree) ref.qualifierExpression;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TreeUtilities.java

示例4: getReferenceParameters

import com.sun.source.util.DocTreePath; //导入方法依赖的package包/类
/**Find the parameters that are specified in the given {@link ReferenceTree}.
     * 
     * @param path the leaf must be {@link ReferenceTree}
     * @return the parameters for the referred method, or {@code null} if none.
     * @since 0.124
     */
    public @CheckForNull List<? extends Tree> getReferenceParameters(@NonNull DocTreePath path) {
        TreePath tp = path.getTreePath();
        DCReference ref = (DCReference) path.getLeaf();
        
        ((DocTrees) this.info.getTrees()).getElement(path);
//        was:
//        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
        
        return ref.paramTypes;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:TreeUtilities.java

示例5: getElement

import com.sun.source.util.DocTreePath; //导入方法依赖的package包/类
@Override
public Element getElement(DocTreePath path) {
    DocTree forTree = path.getLeaf();
    if (forTree instanceof DCReference)
        return attributeDocReference(path.getTreePath(), ((DCReference) forTree));
    if (forTree instanceof DCIdentifier) {
        if (path.getParentPath().getLeaf() instanceof DCParam) {
            return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf());
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:JavacTrees.java

示例6: getElement

import com.sun.source.util.DocTreePath; //导入方法依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public Element getElement(DocTreePath path) {
    DocTree forTree = path.getLeaf();
    if (forTree instanceof DCReference)
        return attributeDocReference(path.getTreePath(), ((DCReference) forTree));
    if (forTree instanceof DCIdentifier) {
        if (path.getParentPath().getLeaf() instanceof DCParam) {
            return attributeParamIdentifier(path.getTreePath(), (DCParam) path.getParentPath().getLeaf());
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:JavacTrees.java

示例7: replaceDocTree

import com.sun.source.util.DocTreePath; //导入方法依赖的package包/类
/** Replaces the leaf doctree in the given path with {@code replacement}. */
public static void replaceDocTree(
    SuggestedFix.Builder fix, DocTreePath docPath, String replacement) {
  DocTree leaf = docPath.getLeaf();
  checkArgument(
      leaf instanceof DCTree.DCEndPosTree, "no end position information for %s", leaf.getKind());
  DCTree.DCEndPosTree<?> node = (DCTree.DCEndPosTree<?>) leaf;
  DCTree.DCDocComment comment = (DCTree.DCDocComment) docPath.getDocComment();
  fix.replace((int) node.getSourcePosition(comment), node.getEndPos(comment), replacement);
}
 
开发者ID:google,项目名称:error-prone,代码行数:11,代码来源:SuggestedFixes.java

示例8: getReferenceName

import com.sun.source.util.DocTreePath; //导入方法依赖的package包/类
/**Find the name (the name after {@code #}) that is being referenced by the given {@link ReferenceTree}.
 * 
 * @param path the leaf must be {@link ReferenceTree}
 * @return the referred member name, or {@code null} if none.
 * @since 0.124
 */
public @CheckForNull Name getReferenceName(@NonNull DocTreePath path) {
    return ((DCReference) path.getLeaf()).memberName;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:TreeUtilities.java


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