protected void printTree(String label, JCTree tree) { if (tree == null) { printNull(label); } else { indent(); String ext; try { ext = tree.getKind().name(); } catch (Throwable t) { ext = "n/a"; } out.print(label + ": " + info(tree.getClass(), tree.getTag(), ext)); if (showPositions) { // We can always get start position, but to get end position // and/or line+offset, we would need a JCCompilationUnit out.print(" pos:" + tree.pos); } if (showTreeTypes && tree.type != null) out.print(" type:" + toString(tree.type)); Symbol sym; if (showTreeSymbols && (sym = TreeInfo.symbolFor(tree)) != null) out.print(" sym:" + toString(sym)); out.println(); indent(+1); if (showSrc) { indent(); out.println("src: " + Pretty.toSimpleString(tree, maxSrcLength)); } tree.accept(treeVisitor); indent(-1); } }
public void printScope(String label, Scope scope, Details details) { if (scope == null) { printNull(label); } else { switch (details) { case SUMMARY: { indent(); out.print(label); out.print(": ["); String sep = ""; for (Symbol sym : scope.getSymbols()) { out.print(sep); out.print(sym.name); sep = ","; } out.println("]"); break; } case FULL: { indent(); out.println(label); indent(+1); printFullScopeImpl(scope); indent(-1); break; } } } }
public void printName(String label, Name name) { if (name == null) { printNull(label); } else { printString(label, name.toString()); } }
public void printFileObject(String label, FileObject fo) { if (fo == null) { printNull(label); } else { printString(label, fo.getName()); } }
protected void printAnnotations(String label, SymbolMetadata annotations, Details details) { if (annotations == null) { printNull(label); } else { // no SUMMARY format currently available to use // use reflection to get at private fields Object DECL_NOT_STARTED = getField(null, SymbolMetadata.class, "DECL_NOT_STARTED"); Object DECL_IN_PROGRESS = getField(null, SymbolMetadata.class, "DECL_IN_PROGRESS"); Object attributes = getField(annotations, SymbolMetadata.class, "attributes"); Object type_attributes = getField(annotations, SymbolMetadata.class, "type_attributes"); if (!showEmptyItems) { if (attributes instanceof List && ((List) attributes).isEmpty() && attributes != DECL_NOT_STARTED && attributes != DECL_IN_PROGRESS && type_attributes instanceof List && ((List) type_attributes).isEmpty()) return; } printString(label, hashString(annotations)); indent(+1); if (attributes == DECL_NOT_STARTED) printString("attributes", "DECL_NOT_STARTED"); else if (attributes == DECL_IN_PROGRESS) printString("attributes", "DECL_IN_PROGRESS"); else if (attributes instanceof List) printList("attributes", (List) attributes); else printObject("attributes", attributes, Details.SUMMARY); if (attributes instanceof List) printList("type_attributes", (List) type_attributes); else printObject("type_attributes", type_attributes, Details.SUMMARY); indent(-1); } }
public void printAttribute(String label, Attribute attr) { if (attr == null) { printNull(label); } else { printString(label, attr.getClass().getSimpleName()); indent(+1); attr.accept(attrVisitor); indent(-1); } }
public void printDocTree(String label, DocTree tree) { if (tree == null) { printNull(label); } else { indent(); out.print(label); out.println(": " + tree.getClass().getSimpleName() + "," + tree.getKind()); indent(+1); tree.accept(docTreeVisitor, null); indent(-1); } }
public void printList(String label, List<?> list) { if (list == null) { printNull(label); } else if (!list.isEmpty() || showEmptyItems) { printString(label, "[" + list.size() + "]"); indent(+1); int i = 0; for (Object item : list) { printObject(String.valueOf(i++), item, Details.FULL); } indent(-1); } }
protected void printSymbol(String label, Symbol sym, Details details) { if (sym == null) { printNull(label); } else { switch (details) { case SUMMARY: printString(label, toString(sym)); break; case FULL: indent(); out.print(label); out.println( ": " + info( sym.getClass(), String.format("0x%x--%s", sym.kind.ordinal(), Kinds.kindName(sym)), sym.getKind()) + " " + sym.name + " " + hashString(sym)); indent(+1); if (showSrc) { JCTree tree = (JCTree) trees.getTree(sym); if (tree != null) printSource("src", tree); } printString( "flags", String.format("0x%x--%s", sym.flags_field, Flags.toString(sym.flags_field))); printObject("completer", sym.completer, Details.SUMMARY); // what if too long? printSymbol("owner", sym.owner, Details.SUMMARY); printType("type", sym.type, Details.SUMMARY); printType("erasure", sym.erasure_field, Details.SUMMARY); sym.accept(symVisitor, null); printAnnotations("annotations", sym.getMetadata(), Details.SUMMARY); indent(-1); } } }
protected void printType(String label, Type type, Details details) { if (type == null) printNull(label); else { switch (details) { case SUMMARY: printString(label, toString(type)); break; case FULL: indent(); out.print(label); out.println( ": " + info(type.getClass(), type.getTag(), type.getKind()) + " " + hashString(type)); indent(+1); printSymbol("tsym", type.tsym, Details.SUMMARY); printObject("constValue", type.constValue(), Details.SUMMARY); printObject("annotations", type.getAnnotationMirrors(), Details.SUMMARY); type.accept(typeVisitor, null); indent(-1); } } }
protected void printObject(String label, Object item, Details details) { if (item == null) { printNull(label); } else if (item instanceof Attribute) { printAttribute(label, (Attribute) item); } else if (item instanceof Symbol) { printSymbol(label, (Symbol) item, details); } else if (item instanceof Type) { printType(label, (Type) item, details); } else if (item instanceof JCTree) { printTree(label, (JCTree) item); } else if (item instanceof DocTree) { printDocTree(label, (DocTree) item); } else if (item instanceof List) { printList(label, (List) item); } else if (item instanceof Name) { printName(label, (Name) item); } else if (item instanceof Scope) { printScope(label, (Scope) item); } else { printString(label, String.valueOf(item)); } }