public String href(Element e) {
return visit(e).toString();
}
public StringBuilder visitType(TypeElement t, Void _) {
ClassTree ct = trees.getTree(t);
if(ct ==null)
return new StringBuilder(); // not a part of compiled source files. return a bogus value
switch(t.getNestingKind()) {
case ANONYMOUS:
String binaryName = elements.getBinaryName(t).toString();
int idx = binaryName.lastIndexOf('$');
String name = "~"+binaryName.substring(idx); // #$1 is ambiguous between field and anonyous type, so use '~' as the prefix for type
return combine(getEnclosingTypeOrPackage(t).accept(this,null)).append(name);
case TOP_LEVEL:
// check if this class is the 'primary type' of the compilation unit
CompilationUnitTree owner = pss.getTreePathByClass().get(ct).getCompilationUnit();
String primaryTypeName = TreeUtil.getPrimaryTypeName(owner);
String simpleName = ct.getSimpleName().toString();
StringBuilder buf = new StringBuilder();
if(!primaryTypeName.equals(simpleName)) {
buf.append("~").append(simpleName);
}