Search in sources :

Example 1 with DocTree

use of com.sun.source.doctree.DocTree in project error-prone by google.

the class SuggestedFixes method replaceDocTree.

/**
 * 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);
}
Also used : DocTree(com.sun.source.doctree.DocTree) DCTree(com.sun.tools.javac.tree.DCTree)

Example 2 with DocTree

use of com.sun.source.doctree.DocTree in project error-prone by google.

the class SuggestedFixes method qualifyDocReference.

/**
 * 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);
}
Also used : ASTHelpers.getSymbol(com.google.errorprone.util.ASTHelpers.getSymbol) Symbol(com.sun.tools.javac.code.Symbol) DocTree(com.sun.source.doctree.DocTree) DCTree(com.sun.tools.javac.tree.DCTree)

Example 3 with DocTree

use of com.sun.source.doctree.DocTree in project mongo-java-driver by mongodb.

the class DocTaglet method toString.

@Override
public String toString(List<? extends DocTree> tags, Element element) {
    if (tags.size() == 0) {
        return null;
    }
    StringBuilder buf = new StringBuilder(String.format("<dl><dt><span class=\"strong\">%s</span></dt>", getHeader()));
    for (DocTree tag : tags) {
        String text = ((UnknownBlockTagTree) tag).getContent().get(0).toString();
        buf.append("<dd>").append(genLink(text)).append("</dd>");
    }
    return buf.toString();
}
Also used : UnknownBlockTagTree(com.sun.source.doctree.UnknownBlockTagTree) DocTree(com.sun.source.doctree.DocTree)

Example 4 with DocTree

use of com.sun.source.doctree.DocTree in project morphia by mongodb.

the class DocTaglet method toString.

@Override
public String toString(List<? extends DocTree> tags, Element element) {
    if (tags.size() == 0) {
        return null;
    }
    StringBuilder buf = new StringBuilder(String.format("<dl><dt><span class=\"strong\">%s</span></dt>", getHeader()));
    for (DocTree tag : tags) {
        String text = ((UnknownBlockTagTree) tag).getContent().get(0).toString();
        buf.append("<dd>").append(genLink(text)).append("</dd>");
    }
    return buf.toString();
}
Also used : UnknownBlockTagTree(com.sun.source.doctree.UnknownBlockTagTree) DocTree(com.sun.source.doctree.DocTree)

Example 5 with DocTree

use of com.sun.source.doctree.DocTree in project morphia by mongodb.

the class AggregationExpressionTaglet method toString.

@Override
public String toString(List<? extends DocTree> tags, Element element) {
    if (tags.size() == 0) {
        return null;
    }
    StringBuilder buf = new StringBuilder(String.format("<dl><dt><span class=\"strong\">%s</span></dt>", getHeader()));
    for (DocTree tag : tags) {
        String text = ((UnknownBlockTagTree) tag).getContent().get(0).toString();
        buf.append("<dd>").append(genLink(text)).append("</dd>");
    }
    return buf.toString();
}
Also used : UnknownBlockTagTree(com.sun.source.doctree.UnknownBlockTagTree) DocTree(com.sun.source.doctree.DocTree)

Aggregations

DocTree (com.sun.source.doctree.DocTree)13 UnknownBlockTagTree (com.sun.source.doctree.UnknownBlockTagTree)5 DocTrees (com.sun.source.util.DocTrees)3 DCTree (com.sun.tools.javac.tree.DCTree)3 Javadoc (com.google.devtools.j2objc.ast.Javadoc)2 TagElement (com.google.devtools.j2objc.ast.TagElement)2 TreeNode (com.google.devtools.j2objc.ast.TreeNode)2 DocCommentTree (com.sun.source.doctree.DocCommentTree)2 TextElement (com.google.devtools.j2objc.ast.TextElement)1 ASTHelpers.getSymbol (com.google.errorprone.util.ASTHelpers.getSymbol)1 ParamTree (com.sun.source.doctree.ParamTree)1 ReturnTree (com.sun.source.doctree.ReturnTree)1 UnknownInlineTagTree (com.sun.source.doctree.UnknownInlineTagTree)1 TreePath (com.sun.source.util.TreePath)1 Symbol (com.sun.tools.javac.code.Symbol)1 File (java.io.File)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Properties (java.util.Properties)1 StringJoiner (java.util.StringJoiner)1