APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.tools.javac.tree

public Class Pretty

extends Visitor
Class Inheritance
Imports
java.io.*, java.util.Optional, com.sun.source.tree.MemberReferenceTree.ReferenceMode, .ModuleTree.ModuleKind, com.sun.tools.javac.code.*, com.sun.tools.javac.tree.JCTree.*, com.sun.tools.javac.util.*

Prints out a tree as an indented Java source program.

This is NOT part of any supported API. 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.

Field Summary

Modifier and TypeField and Description
pack-priv DocCommentTable
docComments

A table mapping trees to their documentation comments (can be null)

pack-priv long
enclClassFlags

The enclosing class flags.

pack-priv Name
enclClassName

The enclosing class name.

pack-priv String
pack-priv int
lmargin

The current left margin.

pack-priv Writer
out

The output stream on which trees are printed.

pack-priv int
prec

Visitor argument: the current precedence level.

private static final int
PREFERRED_LENGTH

Max number of chars to be generated when output should fit into a single line

private final boolean
sourceOutput

Set when we are producing source output.

private static final String
trimSequence

A string sequence to be used when Pretty output should be constrained to fit into a given size

public int
width

Indentation width (can be reassigned from outside).

Constructor Summary

AccessConstructor and Description
public
Pretty(Writer out, boolean sourceOutput)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
align()

Align code to be indented to left margin.

pack-priv void
close(int
The precedence level we revert to.
contextPrec
,
int
The inner precedence level.
ownPrec
)

Leave precedence level.

pack-priv void
indent()

Increase left margin by indentation width.

pack-priv boolean
isCompactRecordConstructor(JCTree t)

Is the given tree a compact record constructor?

pack-priv boolean
isEnumerator(JCTree t)

Is the given tree an enumerator definition?

pack-priv boolean
isGeneratedDefaultConstructor(JCTree t)

Is the given tree a generated default constructor?

pack-priv boolean
isRecordComponent(JCTree t)

Is the given tree a record component?

pack-priv boolean
isUsed(final Symbol t, JCTree cdef)

pack-priv static int
lineEndPos(String s, int start)

pack-priv void
open(int
The precedence level in force so far.
contextPrec
,
int
The new precedence level.
ownPrec
)

Enter a new precedence level.

public String
public void
private void
public void
printBlock(List<? extends JCTree> stats)

Print a block.

private void
public void
printDocComment(JCTree
The tree for which a documentation comment should be printed.
tree
)

Print documentation comment, if it exists

public void
printEnumBody(List<JCTree> stats)

Print a block.

public void
printExpr(JCTree tree, int
The current precedence level.
prec
)

Visitor method: print expression tree.

public void
printExpr(JCTree tree)

Derived visitor method: print expression tree at minimum precedence level for expression.

public <T extends JCTree> void
printExprs(List<T> trees, String
the separator string
sep
)

Derived visitor method: print list of expression trees, separated by given string.

public <T extends JCTree> void
printExprs(List<T> trees)

Derived visitor method: print list of expression trees, separated by commas.

public void
printFlags(long flags)

Print a set of modifiers.

public void
println()

Print new line.

public void
printPattern(JCTree tree)

Derived visitor method: print pattern.

public void
printRecordBody(List<JCTree> stats)

Print a block.

public void
printRecordComponents(List<JCTree> stats)

Print record components.

public void
printStat(JCTree tree)

Derived visitor method: print statement tree.

public void
printStats(List<? extends JCTree> trees)

Derived visitor method: print list of statements, each on a separate line.

public void
public void
printTypeParameters(List<JCTree.JCTypeParameter> trees)

If type parameter list is non-empty, print it enclosed in "<...

public void
printUnit(JCTree.JCCompilationUnit
The toplevel tree
tree
,
JCTree.JCClassDecl
The class definition, which is assumed to be part of the toplevel tree.
cdef
)

Print unit consisting of package clause and import statements in toplevel, followed by class definition.

public static String
public static String
toSimpleString(JCTree tree, int maxLength)

pack-priv void
undent()

Decrease left margin by indentation width.

public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void
public void