use of com.sun.source.doctree.DocTree in project error-prone by google.
the class SuggestedFixes method replaceDocTree.
/**
* Replaces the leaf doctree in the given path with {@code replacement}.
*/
public static void replaceDocTree(SuggestedFix.Builder fix, DocTreePath docPath, String replacement) {
DocTree leaf = docPath.getLeaf();
checkArgument(leaf instanceof DCTree.DCEndPosTree, "no end position information for %s", leaf.getKind());
DCTree.DCEndPosTree<?> node = (DCTree.DCEndPosTree<?>) leaf;
DCTree.DCDocComment comment = (DCTree.DCDocComment) docPath.getDocComment();
fix.replace((int) node.getSourcePosition(comment), node.getEndPos(comment), replacement);
}
use of com.sun.source.doctree.DocTree in project error-prone by google.
the class SuggestedFixes method qualifyDocReference.
/**
* Fully qualifies a javadoc reference, e.g. for replacing {@code {@link List}} with {@code {@link
* java.util.List}}
*
* @param fix the fix builder to add to
* @param docPath the path to a {@link DCTree.DCReference} element
*/
public static void qualifyDocReference(SuggestedFix.Builder fix, DocTreePath docPath, VisitorState state) {
DocTree leaf = docPath.getLeaf();
checkArgument(leaf.getKind() == DocTree.Kind.REFERENCE, "expected a path to a reference, got %s instead", leaf.getKind());
DCTree.DCReference reference = (DCTree.DCReference) leaf;
Symbol sym = (Symbol) JavacTrees.instance(state.context).getElement(docPath);
if (sym == null) {
return;
}
String refString = reference.toString();
String qualifiedName;
int idx = refString.indexOf('#');
if (idx >= 0) {
qualifiedName = sym.owner.getQualifiedName() + refString.substring(idx, refString.length());
} else {
qualifiedName = sym.getQualifiedName().toString();
}
replaceDocTree(fix, docPath, qualifiedName);
}
use of com.sun.source.doctree.DocTree in project mongo-java-driver by mongodb.
the class DocTaglet 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();
}
use of com.sun.source.doctree.DocTree in project morphia by mongodb.
the class DocTaglet 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();
}
use of com.sun.source.doctree.DocTree in project morphia by mongodb.
the class AggregationExpressionTaglet 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