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;
}
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;
}
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();
}
Aggregations