Search in sources :

Example 6 with TagElement

use of com.google.devtools.j2objc.ast.TagElement in project j2objc by google.

the class JavadocGenerator method printTagFragments.

private String printTagFragments(List<TreeNode> fragments) {
    if (fragments.isEmpty()) {
        return "";
    }
    StringBuilder sb = new StringBuilder();
    int lineNo = fragments.get(0).getLineNumber();
    for (TreeNode fragment : fragments) {
        if (fragment.getLineNumber() > lineNo) {
            sb.append("\n ");
            lineNo = fragment.getLineNumber();
        }
        if (fragment instanceof TextElement) {
            if (spanningPreTag) {
                sb.append(getSourceIndent(fragment));
            }
            String text = escapeDocText(((TextElement) fragment).getText());
            sb.append(text);
        } else if (fragment instanceof TagElement) {
            sb.append(printTag((TagElement) fragment));
        } else if (fragment instanceof SimpleName) {
            Element element = ((Name) fragment).getElement();
            if (element != null && ElementUtil.isVariable(element)) {
                sb.append(NameTable.getDocCommentVariableName(((VariableElement) element)));
            } else {
                sb.append(fragment.toString());
            }
        } else {
            sb.append(fragment.toString().trim());
        }
    }
    return sb.toString();
}
Also used : TextElement(com.google.devtools.j2objc.ast.TextElement) TreeNode(com.google.devtools.j2objc.ast.TreeNode) SimpleName(com.google.devtools.j2objc.ast.SimpleName) TagElement(com.google.devtools.j2objc.ast.TagElement) VariableElement(javax.lang.model.element.VariableElement) Element(javax.lang.model.element.Element) TextElement(com.google.devtools.j2objc.ast.TextElement) TagElement(com.google.devtools.j2objc.ast.TagElement) Name(com.google.devtools.j2objc.ast.Name) SimpleName(com.google.devtools.j2objc.ast.SimpleName)

Aggregations

TagElement (com.google.devtools.j2objc.ast.TagElement)6 TreeNode (com.google.devtools.j2objc.ast.TreeNode)3 Javadoc (com.google.devtools.j2objc.ast.Javadoc)2 DocTree (com.sun.source.doctree.DocTree)2 DocTrees (com.sun.source.util.DocTrees)2 Name (com.google.devtools.j2objc.ast.Name)1 SimpleName (com.google.devtools.j2objc.ast.SimpleName)1 TagKind (com.google.devtools.j2objc.ast.TagElement.TagKind)1 TextElement (com.google.devtools.j2objc.ast.TextElement)1 DocCommentTree (com.sun.source.doctree.DocCommentTree)1 TreePath (com.sun.source.util.TreePath)1 DCTree (com.sun.tools.javac.tree.DCTree)1 BreakIterator (java.text.BreakIterator)1 Element (javax.lang.model.element.Element)1 VariableElement (javax.lang.model.element.VariableElement)1