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