Search in sources :

Example 6 with TextElement

use of com.google.devtools.j2objc.ast.TextElement 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 7 with TextElement

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

the class JavadocConverter method visitReference.

@Override
public Void visitReference(ReferenceTree node, TagElement tag) {
    TreeNode newNode = new TextElement().setText(node.getSignature());
    tag.addFragment(setPos(node, newNode));
    return null;
}
Also used : TextElement(com.google.devtools.j2objc.ast.TextElement) TreeNode(com.google.devtools.j2objc.ast.TreeNode)

Example 8 with TextElement

use of com.google.devtools.j2objc.ast.TextElement 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

TextElement (com.google.devtools.j2objc.ast.TextElement)8 TreeNode (com.google.devtools.j2objc.ast.TreeNode)5 SimpleName (com.google.devtools.j2objc.ast.SimpleName)2 VariableElement (javax.lang.model.element.VariableElement)2 Name (com.google.devtools.j2objc.ast.Name)1 TagElement (com.google.devtools.j2objc.ast.TagElement)1 DocTree (com.sun.source.doctree.DocTree)1 IdentifierTree (com.sun.source.doctree.IdentifierTree)1 DCTree (com.sun.tools.javac.tree.DCTree)1 Element (javax.lang.model.element.Element)1 ExecutableElement (javax.lang.model.element.ExecutableElement)1