Search in sources :

Example 11 with DocTree

use of com.sun.source.doctree.DocTree in project j2objc by google.

the class JavadocConverter method visitStartElement.

@Override
public Void visitStartElement(StartElementTree node, TagElement tag) {
    StringBuilder sb = new StringBuilder("<");
    sb.append(node.getName());
    for (DocTree attr : node.getAttributes()) {
        sb.append(' ');
        sb.append(attr);
    }
    sb.append('>');
    tag.addFragment(setPos(node, new TextElement().setText(sb.toString())));
    return null;
}
Also used : TextElement(com.google.devtools.j2objc.ast.TextElement) DocTree(com.sun.source.doctree.DocTree)

Example 12 with DocTree

use of com.sun.source.doctree.DocTree in project j2objc by google.

the class JavadocConverter method convertJavadoc.

/**
 * Returns an AST node for the javadoc comment of a specified class, method, or field element.
 */
static Javadoc convertJavadoc(TreePath path, String source, JavacEnvironment env, boolean reportWarnings) {
    DocTrees docTrees = DocTrees.instance(env.task());
    DocCommentTree docComment = docTrees.getDocCommentTree(path);
    if (docComment == null) {
        // Declaration does not have a javadoc comment.
        return null;
    }
    JavadocConverter converter = new JavadocConverter(env.treeUtilities().getElement(path), docComment, source, docTrees, path.getCompilationUnit(), reportWarnings);
    Javadoc result = new Javadoc();
    // First tag is the description.
    TagElement newTag = new TagElement().setTagKind(TagElement.TagKind.DESCRIPTION);
    converter.scan(docComment.getFirstSentence(), newTag);
    converter.scan(docComment.getBody(), newTag);
    if (!newTag.getFragments().isEmpty()) {
        List<TreeNode> fragments = newTag.getFragments();
        int start = fragments.get(0).getStartPosition();
        TreeNode lastFragment = fragments.get(fragments.size() - 1);
        int end = start + lastFragment.getLength();
        converter.setPos(newTag, start, end);
        result.addTag(newTag);
    }
    for (DocTree tag : docComment.getBlockTags()) {
        if (tag.getKind() != DocTree.Kind.ERRONEOUS) {
            newTag = new TagElement();
            converter.scan(tag, newTag);
            result.addTag(newTag);
        }
    }
    return result;
}
Also used : DocCommentTree(com.sun.source.doctree.DocCommentTree) DocTrees(com.sun.source.util.DocTrees) TreeNode(com.google.devtools.j2objc.ast.TreeNode) Javadoc(com.google.devtools.j2objc.ast.Javadoc) TagElement(com.google.devtools.j2objc.ast.TagElement) DocTree(com.sun.source.doctree.DocTree)

Example 13 with DocTree

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

the class UpdateOperatorTaglet 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