use of com.sun.source.doctree.UnknownInlineTagTree in project ignite by apache.
the class IgniteLinkTaglet method toString.
/**
* Given the <code>DocTree</code> representation of this custom tag, return its string representation.
* <p>
* Input: org.apache.ignite.grid.spi.indexing.h2.GridH2IndexingSpi#setIndexCustomFunctionClasses(Class[])
* <p>
* Output: <a href="../../../../../org/apache/ignite/grid/spi/indexing/h2/GridH2IndexingSpi.html#
* setIndexCustomFunctionClasses(java.lang.Class...)">
* <code>GridH2IndexingSpi.setIndexCustomFunctionClasses(java.lang.Class[])</code></a>
*
* @param tags <code>DocTree</code> representation of this custom tag.
* @param element The element to which the enclosing comment belongs.
*/
@Override
public String toString(List<? extends DocTree> tags, Element element) {
for (DocTree tag : tags) {
String text = new SimpleDocTreeVisitor<String, Void>() {
@Override
public String visitUnknownInlineTag(UnknownInlineTagTree node, Void param) {
return node.getContent().toString();
}
}.visit(tag, null);
if (text == null || text.isEmpty())
return "";
File f = new File(env.getDocTrees().getPath(element).getCompilationUnit().getSourceFile().toUri());
String curCls = f == null ? "" : f.getAbsolutePath().replace(File.separator, ".");
String packPref = "src.main.java.";
int idx = curCls.indexOf(packPref);
StringBuilder path = new StringBuilder();
if (idx != -1) {
curCls = curCls.substring(idx + packPref.length());
for (int i = 0, n = curCls.split("\\.").length - 2; i < n; i++) path.append("../");
}
String[] tokens = text.split("#");
int lastIdx = tokens[0].lastIndexOf('.');
String simpleClsName = lastIdx != -1 && lastIdx + 1 < tokens[0].length() ? tokens[0].substring(lastIdx + 1) : tokens[0];
String fullyQClsName = tokens[0].replace(".", "/");
return "<a href=\"" + path + fullyQClsName + ".html" + (tokens.length > 1 ? ("#" + tokens[1].replace("[]", "...")) : "") + "\"><code>" + simpleClsName + (tokens.length > 1 ? ("." + tokens[1]) : "") + "</code></a>";
}
return "";
}
Aggregations