public abstract class AbstractTreePrinter extends AbstractTreeScanner
| Modifier and Type | Field and Description |
|---|---|
StringBuilder |
footer
A footer to be printed at the end of the output.
|
protected boolean |
inArgListTail |
protected static String |
INDENT
The constant string for indentation.
|
SourceMap |
sourceMap
The object storing source map information while printing.
|
TypeChecker |
typeChecker
A type checker instance.
|
compilationUnit, context, diagnosticSource, stack, staticImports| Constructor and Description |
|---|
AbstractTreePrinter(TranspilationHandler logHandler,
JSweetContext context,
com.sun.tools.javac.tree.JCTree.JCCompilationUnit compilationUnit,
PrinterAdapter adapter,
boolean fillSourceMap)
Creates a new printer.
|
| Modifier and Type | Method and Description |
|---|---|
AbstractTreePrinter |
endIndent()
Decrements the current indentation value.
|
protected void |
enter(com.sun.tools.javac.tree.JCTree tree)
Enters the given tree (se
AbstractTreeScanner.scan(JCTree). |
protected void |
exit()
Exits the currently scanned tree.
|
PrinterAdapter |
getAdapter()
Gets the adapter attached to this printer.
|
com.sun.tools.javac.tree.JCTree.JCCompilationUnit |
getCompilationUnit()
Gets the current compilation unit.
|
int |
getCurrentColumn()
Gets the current column of the printed output.
|
int |
getCurrentLine()
Gets the current line of the printed output.
|
int |
getCurrentPosition()
Gets the current character count of the output.
|
String |
getIdentifier(com.sun.tools.javac.code.Symbol symbol) |
int |
getIndent() |
String |
getIndentString()
Returns the current indentation as a string.
|
char |
getLastPrintedChar()
Gets the lastly printed character.
|
String |
getLastPrintedString(int length)
Gets the last printed string for the given length.
|
String |
getOutput()
Gets this output of this printer.
|
Stack<Position> |
getPositionStack()
The position stack of the scanner.
|
String |
getQualifiedTypeName(com.sun.tools.javac.code.Symbol.TypeSymbol type,
boolean globals,
boolean ignoreLangTypes) |
String |
getResult()
Gets the printed result as a string.
|
String |
getRootRelativeName(com.sun.tools.javac.code.Symbol symbol) |
String |
getRootRelativeName(com.sun.tools.javac.code.Symbol symbol,
boolean useJavaNames) |
boolean |
isFillSourceMap()
Tells if this printer tries to preserve the original line numbers of the
Java input.
|
protected void |
onRollbacked(com.sun.tools.javac.tree.JCTree target)
A global handler to be called when a rollback operation terminates.
|
AbstractTreePrinter |
print(com.sun.tools.javac.tree.JCTree tree)
Print a given AST.
|
AbstractTreePrinter |
print(String string)
Outputs a string (new lines are not allowed).
|
AbstractTreePrinter |
printArgList(com.sun.tools.javac.tree.JCTree.JCMethodInvocation inv)
Prints an invocation argument list, with type assignment.
|
AbstractTreePrinter |
printArgList(List<com.sun.tools.javac.code.Type> assignedTypes,
List<? extends com.sun.tools.javac.tree.JCTree> args) |
AbstractTreePrinter |
printArgList(List<com.sun.tools.javac.code.Type> assignedTypes,
List<? extends com.sun.tools.javac.tree.JCTree> args,
Consumer<com.sun.tools.javac.tree.JCTree> printer)
Prints a comma-separated list of subtrees.
|
abstract AbstractTreePrinter |
printConstructorArgList(com.sun.tools.javac.tree.JCTree.JCNewClass newClass,
boolean localClass) |
AbstractTreePrinter |
printIdentifier(com.sun.tools.javac.code.Symbol symbol)
Outputs an identifier.
|
AbstractTreePrinter |
printIndent()
Prints an indentation for the current indentation value.
|
AbstractTreePrinter |
println()
Outputs a new line.
|
AbstractTreePrinter |
println(String string)
Outputs a string and new line
|
AbstractTreePrinter |
printTypeArgList(List<? extends com.sun.tools.javac.tree.JCTree> args)
Prints a comma-separated list of type subtrees.
|
AbstractTreePrinter |
printVarNameList(List<com.sun.tools.javac.tree.JCTree.JCVariableDecl> args)
Prints a comma-separated list of variable names (no types).
|
AbstractTreePrinter |
removeLastChar()
Removes the last output character.
|
boolean |
removeLastChar(char expectedChar)
removes last character if expectedChar
|
AbstractTreePrinter |
removeLastChars(int count)
Removes the last output characters.
|
AbstractTreePrinter |
removeLastIndent()
Removes the last printed indentation.
|
void |
setAdapter(PrinterAdapter adapter)
Sets the adapter attached to this printer.
|
AbstractTreePrinter |
space()
Adds a space to the output.
|
AbstractTreePrinter |
startIndent()
Increments the current indentation value.
|
AbstractTreePrinter |
substituteAndPrintAssignedExpression(com.sun.tools.javac.code.Type assignedType,
com.sun.tools.javac.tree.JCTree.JCExpression expression)
Print an expression being assigned to a type (should handled necessary
wraping/unwraping).
|
abstract AbstractTreePrinter |
substituteAndPrintType(com.sun.tools.javac.tree.JCTree typeTree) |
protected abstract boolean |
substituteAssignedExpression(com.sun.tools.javac.code.Type assignedType,
com.sun.tools.javac.tree.JCTree.JCExpression expression)
Conditionally substitutes an expression when it is assigned to a given
type.
|
dumpStackTrace, getContext, getCurrent, getFirstParent, getGetSource, getParent, getParent, getParent, getParentElement, getParentElement, getParentOfParent, getStack, getStaticImports, report, report, rollback, scan, scan, setCompilationUnitscan, visitAnnotatedType, visitAnnotation, visitApply, visitAssert, visitAssign, visitAssignop, visitBinary, visitBlock, visitBreak, visitCase, visitCatch, visitClassDef, visitConditional, visitContinue, visitDoLoop, visitErroneous, visitExec, visitForeachLoop, visitForLoop, visitIdent, visitIf, visitImport, visitIndexed, visitLabelled, visitLambda, visitLetExpr, visitLiteral, visitMethodDef, visitModifiers, visitNewArray, visitNewClass, visitParens, visitReference, visitReturn, visitSelect, visitSkip, visitSwitch, visitSynchronized, visitThrow, visitTopLevel, visitTree, visitTry, visitTypeApply, visitTypeArray, visitTypeBoundKind, visitTypeCast, visitTypeIdent, visitTypeIntersection, visitTypeParameter, visitTypeTest, visitTypeUnion, visitUnary, visitVarDef, visitWhileLoop, visitWildcardpublic StringBuilder footer
protected static final String INDENT
public TypeChecker typeChecker
public SourceMap sourceMap
protected boolean inArgListTail
public AbstractTreePrinter(TranspilationHandler logHandler, JSweetContext context, com.sun.tools.javac.tree.JCTree.JCCompilationUnit compilationUnit, PrinterAdapter adapter, boolean fillSourceMap)
logHandler - the handler that reports logs and problemscontext - the scanning contextcompilationUnit - the source file to be printedadapter - the printer adapterfillSourceMap - tells if printer fills the source mappublic String getOutput()
public AbstractTreePrinter print(com.sun.tools.javac.tree.JCTree tree)
protected void enter(com.sun.tools.javac.tree.JCTree tree)
AbstractTreeScanner.scan(JCTree).enter in class AbstractTreeScannerAbstractTreeScanner.exit()protected void onRollbacked(com.sun.tools.javac.tree.JCTree target)
AbstractTreeScanneronRollbacked in class AbstractTreeScannertarget - the rollback's targetAbstractTreeScanner.rollback(JCTree, Consumer)protected void exit()
exit in class AbstractTreeScannerAbstractTreeScanner.enter(JCTree)public int getCurrentPosition()
public char getLastPrintedChar()
public String getLastPrintedString(int length)
public AbstractTreePrinter printIndent()
public String getIndentString()
public AbstractTreePrinter startIndent()
public AbstractTreePrinter endIndent()
public AbstractTreePrinter print(String string)
public AbstractTreePrinter println(String string)
public AbstractTreePrinter printIdentifier(com.sun.tools.javac.code.Symbol symbol)
public String getQualifiedTypeName(com.sun.tools.javac.code.Symbol.TypeSymbol type, boolean globals, boolean ignoreLangTypes)
public String getIdentifier(com.sun.tools.javac.code.Symbol symbol)
public AbstractTreePrinter space()
public boolean removeLastChar(char expectedChar)
public AbstractTreePrinter removeLastChar()
public AbstractTreePrinter removeLastChars(int count)
public AbstractTreePrinter removeLastIndent()
public AbstractTreePrinter println()
public String getResult()
public PrinterAdapter getAdapter()
public void setAdapter(PrinterAdapter adapter)
public AbstractTreePrinter printArgList(List<com.sun.tools.javac.code.Type> assignedTypes, List<? extends com.sun.tools.javac.tree.JCTree> args, Consumer<com.sun.tools.javac.tree.JCTree> printer)
public AbstractTreePrinter substituteAndPrintAssignedExpression(com.sun.tools.javac.code.Type assignedType, com.sun.tools.javac.tree.JCTree.JCExpression expression)
assignedType - the type the expression is being assigned toexpression - the assigned expressionprotected abstract boolean substituteAssignedExpression(com.sun.tools.javac.code.Type assignedType,
com.sun.tools.javac.tree.JCTree.JCExpression expression)
assignedType - the type the expression is being assigned toexpression - the assigned expressionpublic AbstractTreePrinter printArgList(com.sun.tools.javac.tree.JCTree.JCMethodInvocation inv)
public AbstractTreePrinter printArgList(List<com.sun.tools.javac.code.Type> assignedTypes, List<? extends com.sun.tools.javac.tree.JCTree> args)
public abstract AbstractTreePrinter printConstructorArgList(com.sun.tools.javac.tree.JCTree.JCNewClass newClass, boolean localClass)
public abstract AbstractTreePrinter substituteAndPrintType(com.sun.tools.javac.tree.JCTree typeTree)
public AbstractTreePrinter printVarNameList(List<com.sun.tools.javac.tree.JCTree.JCVariableDecl> args)
public AbstractTreePrinter printTypeArgList(List<? extends com.sun.tools.javac.tree.JCTree> args)
public int getCurrentLine()
public int getCurrentColumn()
public com.sun.tools.javac.tree.JCTree.JCCompilationUnit getCompilationUnit()
getCompilationUnit in class AbstractTreeScannerpublic boolean isFillSourceMap()
public String getRootRelativeName(com.sun.tools.javac.code.Symbol symbol)
public String getRootRelativeName(com.sun.tools.javac.code.Symbol symbol, boolean useJavaNames)
public int getIndent()