|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.sun.tools.javac.tree.JCTree.Visitor
com.sun.tools.javac.tree.Pretty
public class Pretty
Prints out a tree as an indented Java source program.
This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
| Nested Class Summary | |
|---|---|
protected static class |
Pretty.UncheckedIOException
Exception to propogate IOException through visitXXX methods |
| Field Summary | |
|---|---|
(package private) java.util.Map<JCTree,java.lang.String> |
docComments
A hashtable mapping trees to their documentation comments (can be null) |
(package private) Name |
enclClassName
The enclosing class name. |
protected java.lang.String |
lineSep
|
protected int |
lmargin
The current left margin. |
(package private) java.io.Writer |
out
The output stream on which trees are printed. |
(package private) int |
prec
Visitor argument: the current precedence level. |
private boolean |
sourceOutput
Set when we are producing source output. |
int |
width
Indentation width (can be reassigned from outside). |
| Constructor Summary | |
|---|---|
Pretty(java.io.Writer out,
boolean sourceOutput)
|
|
| Method Summary | ||
|---|---|---|
protected void |
align()
Align code to be indented to left margin. |
|
protected void |
close(int contextPrec,
int ownPrec)
Leave precedence level. |
|
protected void |
indent()
Increase left margin by indentation width. |
|
(package private) boolean |
isEnumerator(JCTree t)
Is the given tree an enumerator definition? |
|
(package private) boolean |
isUsed(Symbol t,
JCTree cdef)
|
|
(package private) static int |
lineEndPos(java.lang.String s,
int start)
|
|
protected void |
open(int contextPrec,
int ownPrec)
Enter a new precedence level. |
|
java.lang.String |
operatorName(int tag)
|
|
void |
print(java.lang.Object s)
Print string, replacing all non-ascii character with unicode escapes. |
|
void |
printAnnotations(List<JCTree.JCAnnotation> trees)
|
|
private void |
printBaseElementType(JCTree.JCArrayTypeTree tree)
|
|
void |
printBlock(List<? extends JCTree> stats)
Print a block. |
|
private void |
printBrackets(JCTree.JCArrayTypeTree tree)
|
|
void |
printDocComment(JCTree tree)
Print documentation comment, if it exists |
|
void |
printEnumBody(List<JCTree> stats)
Print a block. |
|
void |
printExpr(JCTree tree)
Derived visitor method: print expression tree at minimum precedence level for expression. |
|
void |
printExpr(JCTree tree,
int prec)
Visitor method: print expression tree. |
|
|
printExprs(List<T> trees)
Derived visitor method: print list of expression trees, separated by commas. |
|
|
printExprs(List<T> trees,
java.lang.String sep)
Derived visitor method: print list of expression trees, separated by given string. |
|
void |
printFlags(long flags)
Print a set of modifiers. |
|
void |
println()
Print new line. |
|
void |
printStat(JCTree tree)
Derived visitor method: print statement tree. |
|
void |
printStats(List<? extends JCTree> trees)
Derived visitor method: print list of statements, each on a separate line. |
|
void |
printTypeParameters(List<JCTree.JCTypeParameter> trees)
If type parameter list is non-empty, print it enclosed in "<...>" brackets. |
|
void |
printUnit(JCTree.JCCompilationUnit tree,
JCTree.JCClassDecl cdef)
Print unit consisting of package clause and import statements in toplevel, followed by class definition. |
|
void |
printVarDefName(JCTree.JCVariableDecl tree)
|
|
(package private) void |
undent()
Decrease left margin by indentation width. |
|
void |
visitAnnotation(JCTree.JCAnnotation tree)
|
|
void |
visitApply(JCTree.JCMethodInvocation tree)
|
|
void |
visitAssert(JCTree.JCAssert tree)
|
|
void |
visitAssign(JCTree.JCAssign tree)
|
|
void |
visitAssignop(JCTree.JCAssignOp tree)
|
|
void |
visitBinary(JCTree.JCBinary tree)
|
|
void |
visitBlock(JCTree.JCBlock tree)
|
|
void |
visitBracketExpr(JCTree.JCBracketExpr tree)
|
|
void |
visitBracketStat(JCTree.JCBracketStat tree)
|
|
void |
visitBreak(JCTree.JCBreak tree)
|
|
void |
visitCase(JCTree.JCCase tree)
|
|
void |
visitCatch(JCTree.JCCatch tree)
|
|
void |
visitClassDef(JCTree.JCClassDecl tree)
|
|
void |
visitConditional(JCTree.JCConditional tree)
|
|
void |
visitContinue(JCTree.JCContinue tree)
|
|
void |
visitDoLoop(JCTree.JCDoWhileLoop tree)
|
|
void |
visitErroneous(JCTree.JCErroneous tree)
|
|
void |
visitEscapeExpr(JCTree.JCEscapeExpr tree)
|
|
void |
visitEscapeStat(JCTree.JCEscapeStat tree)
|
|
void |
visitExec(JCTree.JCExpressionStatement tree)
|
|
void |
visitForeachLoop(JCTree.JCEnhancedForLoop tree)
|
|
void |
visitForLoop(JCTree.JCForLoop tree)
|
|
void |
visitIdent(JCTree.JCIdent tree)
|
|
void |
visitIf(JCTree.JCIf tree)
|
|
void |
visitImport(JCTree.JCImport tree)
|
|
void |
visitIndexed(JCTree.JCArrayAccess tree)
|
|
void |
visitLabelled(JCTree.JCLabeledStatement tree)
|
|
void |
visitLetExpr(JCTree.LetExpr tree)
|
|
void |
visitLiteral(JCTree.JCLiteral tree)
|
|
void |
visitMethodDef(JCTree.JCMethodDecl tree)
|
|
void |
visitModifiers(JCTree.JCModifiers mods)
|
|
void |
visitNewArray(JCTree.JCNewArray tree)
|
|
void |
visitNewClass(JCTree.JCNewClass tree)
|
|
void |
visitParens(JCTree.JCParens tree)
|
|
void |
visitReturn(JCTree.JCReturn tree)
|
|
void |
visitSelect(JCTree.JCFieldAccess tree)
|
|
void |
visitSkip(JCTree.JCSkip tree)
|
|
void |
visitSwitch(JCTree.JCSwitch tree)
|
|
void |
visitSynchronized(JCTree.JCSynchronized tree)
|
|
void |
visitThrow(JCTree.JCThrow tree)
|
|
void |
visitTopLevel(JCTree.JCCompilationUnit tree)
Visitor methods |
|
void |
visitTree(JCTree tree)
|
|
void |
visitTry(JCTree.JCTry tree)
|
|
void |
visitTypeApply(JCTree.JCTypeApply tree)
|
|
void |
visitTypeArray(JCTree.JCArrayTypeTree tree)
|
|
void |
visitTypeBoundKind(JCTree.TypeBoundKind tree)
|
|
void |
visitTypeCast(JCTree.JCTypeCast tree)
|
|
void |
visitTypeIdent(JCTree.JCPrimitiveTypeTree tree)
|
|
void |
visitTypeParameter(JCTree.JCTypeParameter tree)
|
|
void |
visitTypeTest(JCTree.JCInstanceOf tree)
|
|
void |
visitUnary(JCTree.JCUnary tree)
|
|
void |
visitVarDef(JCTree.JCVariableDecl tree)
|
|
void |
visitWhileLoop(JCTree.JCWhileLoop tree)
|
|
void |
visitWildcard(JCTree.JCWildcard tree)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final boolean sourceOutput
java.io.Writer out
public int width
protected int lmargin
Name enclClassName
java.util.Map<JCTree,java.lang.String> docComments
protected java.lang.String lineSep
int prec
| Constructor Detail |
|---|
public Pretty(java.io.Writer out,
boolean sourceOutput)
| Method Detail |
|---|
protected void align()
throws java.io.IOException
java.io.IOExceptionprotected void indent()
void undent()
protected void open(int contextPrec,
int ownPrec)
throws java.io.IOException
contextPrec - The precedence level in force so far.ownPrec - The new precedence level.
java.io.IOException
protected void close(int contextPrec,
int ownPrec)
throws java.io.IOException
contextPrec - The precedence level we revert to.ownPrec - The inner precedence level.
java.io.IOException
public void print(java.lang.Object s)
throws java.io.IOException
java.io.IOException
public void println()
throws java.io.IOException
java.io.IOException
public void printExpr(JCTree tree,
int prec)
throws java.io.IOException
prec - The current precedence level.
java.io.IOException
public void printExpr(JCTree tree)
throws java.io.IOException
java.io.IOException
public void printStat(JCTree tree)
throws java.io.IOException
java.io.IOException
public <T extends JCTree> void printExprs(List<T> trees,
java.lang.String sep)
throws java.io.IOException
sep - the separator string
java.io.IOException
public <T extends JCTree> void printExprs(List<T> trees)
throws java.io.IOException
java.io.IOException
public void printStats(List<? extends JCTree> trees)
throws java.io.IOException
java.io.IOException
public void printFlags(long flags)
throws java.io.IOException
java.io.IOException
public void printAnnotations(List<JCTree.JCAnnotation> trees)
throws java.io.IOException
java.io.IOException
public void printDocComment(JCTree tree)
throws java.io.IOException
tree - The tree for which a documentation comment should be printed.
java.io.IOException
static int lineEndPos(java.lang.String s,
int start)
public void printTypeParameters(List<JCTree.JCTypeParameter> trees)
throws java.io.IOException
java.io.IOException
public void printBlock(List<? extends JCTree> stats)
throws java.io.IOException
java.io.IOException
public void printEnumBody(List<JCTree> stats)
throws java.io.IOException
java.io.IOExceptionboolean isEnumerator(JCTree t)
public void printUnit(JCTree.JCCompilationUnit tree,
JCTree.JCClassDecl cdef)
throws java.io.IOException
tree - The toplevel treecdef - The class definition, which is assumed to be part of the
toplevel tree.
java.io.IOException
boolean isUsed(Symbol t,
JCTree cdef)
public void visitTopLevel(JCTree.JCCompilationUnit tree)
visitTopLevel in class JCTree.Visitorpublic void visitImport(JCTree.JCImport tree)
visitImport in class JCTree.Visitorpublic void visitClassDef(JCTree.JCClassDecl tree)
visitClassDef in class JCTree.Visitorpublic void visitMethodDef(JCTree.JCMethodDecl tree)
visitMethodDef in class JCTree.Visitorpublic void visitVarDef(JCTree.JCVariableDecl tree)
visitVarDef in class JCTree.Visitor
public void printVarDefName(JCTree.JCVariableDecl tree)
throws java.io.IOException
java.io.IOExceptionpublic void visitSkip(JCTree.JCSkip tree)
visitSkip in class JCTree.Visitorpublic void visitBlock(JCTree.JCBlock tree)
visitBlock in class JCTree.Visitorpublic void visitBracketExpr(JCTree.JCBracketExpr tree)
visitBracketExpr in class JCTree.Visitorpublic void visitBracketStat(JCTree.JCBracketStat tree)
visitBracketStat in class JCTree.Visitorpublic void visitEscapeExpr(JCTree.JCEscapeExpr tree)
visitEscapeExpr in class JCTree.Visitorpublic void visitEscapeStat(JCTree.JCEscapeStat tree)
visitEscapeStat in class JCTree.Visitorpublic void visitDoLoop(JCTree.JCDoWhileLoop tree)
visitDoLoop in class JCTree.Visitorpublic void visitWhileLoop(JCTree.JCWhileLoop tree)
visitWhileLoop in class JCTree.Visitorpublic void visitForLoop(JCTree.JCForLoop tree)
visitForLoop in class JCTree.Visitorpublic void visitForeachLoop(JCTree.JCEnhancedForLoop tree)
visitForeachLoop in class JCTree.Visitorpublic void visitLabelled(JCTree.JCLabeledStatement tree)
visitLabelled in class JCTree.Visitorpublic void visitSwitch(JCTree.JCSwitch tree)
visitSwitch in class JCTree.Visitorpublic void visitCase(JCTree.JCCase tree)
visitCase in class JCTree.Visitorpublic void visitSynchronized(JCTree.JCSynchronized tree)
visitSynchronized in class JCTree.Visitorpublic void visitTry(JCTree.JCTry tree)
visitTry in class JCTree.Visitorpublic void visitCatch(JCTree.JCCatch tree)
visitCatch in class JCTree.Visitorpublic void visitConditional(JCTree.JCConditional tree)
visitConditional in class JCTree.Visitorpublic void visitIf(JCTree.JCIf tree)
visitIf in class JCTree.Visitorpublic void visitExec(JCTree.JCExpressionStatement tree)
visitExec in class JCTree.Visitorpublic void visitBreak(JCTree.JCBreak tree)
visitBreak in class JCTree.Visitorpublic void visitContinue(JCTree.JCContinue tree)
visitContinue in class JCTree.Visitorpublic void visitReturn(JCTree.JCReturn tree)
visitReturn in class JCTree.Visitorpublic void visitThrow(JCTree.JCThrow tree)
visitThrow in class JCTree.Visitorpublic void visitAssert(JCTree.JCAssert tree)
visitAssert in class JCTree.Visitorpublic void visitApply(JCTree.JCMethodInvocation tree)
visitApply in class JCTree.Visitorpublic void visitNewClass(JCTree.JCNewClass tree)
visitNewClass in class JCTree.Visitorpublic void visitNewArray(JCTree.JCNewArray tree)
visitNewArray in class JCTree.Visitorpublic void visitParens(JCTree.JCParens tree)
visitParens in class JCTree.Visitorpublic void visitAssign(JCTree.JCAssign tree)
visitAssign in class JCTree.Visitorpublic java.lang.String operatorName(int tag)
public void visitAssignop(JCTree.JCAssignOp tree)
visitAssignop in class JCTree.Visitorpublic void visitUnary(JCTree.JCUnary tree)
visitUnary in class JCTree.Visitorpublic void visitBinary(JCTree.JCBinary tree)
visitBinary in class JCTree.Visitorpublic void visitTypeCast(JCTree.JCTypeCast tree)
visitTypeCast in class JCTree.Visitorpublic void visitTypeTest(JCTree.JCInstanceOf tree)
visitTypeTest in class JCTree.Visitorpublic void visitIndexed(JCTree.JCArrayAccess tree)
visitIndexed in class JCTree.Visitorpublic void visitSelect(JCTree.JCFieldAccess tree)
visitSelect in class JCTree.Visitorpublic void visitIdent(JCTree.JCIdent tree)
visitIdent in class JCTree.Visitorpublic void visitLiteral(JCTree.JCLiteral tree)
visitLiteral in class JCTree.Visitorpublic void visitTypeIdent(JCTree.JCPrimitiveTypeTree tree)
visitTypeIdent in class JCTree.Visitorpublic void visitTypeArray(JCTree.JCArrayTypeTree tree)
visitTypeArray in class JCTree.Visitor
private void printBaseElementType(JCTree.JCArrayTypeTree tree)
throws java.io.IOException
java.io.IOException
private void printBrackets(JCTree.JCArrayTypeTree tree)
throws java.io.IOException
java.io.IOExceptionpublic void visitTypeApply(JCTree.JCTypeApply tree)
visitTypeApply in class JCTree.Visitorpublic void visitTypeParameter(JCTree.JCTypeParameter tree)
visitTypeParameter in class JCTree.Visitorpublic void visitWildcard(JCTree.JCWildcard tree)
visitWildcard in class JCTree.Visitorpublic void visitTypeBoundKind(JCTree.TypeBoundKind tree)
visitTypeBoundKind in class JCTree.Visitorpublic void visitErroneous(JCTree.JCErroneous tree)
visitErroneous in class JCTree.Visitorpublic void visitLetExpr(JCTree.LetExpr tree)
visitLetExpr in class JCTree.Visitorpublic void visitModifiers(JCTree.JCModifiers mods)
visitModifiers in class JCTree.Visitorpublic void visitAnnotation(JCTree.JCAnnotation tree)
visitAnnotation in class JCTree.Visitorpublic void visitTree(JCTree tree)
visitTree in class JCTree.Visitor
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||