public class PrettyPrinter extends Object
| Modifier and Type | Field and Description |
|---|---|
private static char[] |
BLANKS |
protected Type |
classToPrint
Enforces the output of real Java syntax that can be compiled.
|
private int |
column
Column number.
|
protected boolean |
endAlreadyMarked |
private static char[] |
FEEDS |
protected Object |
firstStatement |
protected int |
firstStatementEnd |
protected int |
firstStatementStart |
private int |
indentation
Indentation (cached).
|
protected HashMap<SourceElement,Position> |
indentMap |
protected SVInstantiations |
instantiations |
private boolean |
isPrintingSingleLineComments
Flag to indicate if a single line comment is being put out.
|
private ArrayList<Range> |
keywordRanges
Contains the java keyword ranges.
|
private Stack<Integer> |
keywordStarts
Remembers the start of a keyword to create a range.
|
protected int |
level
Level.
|
private int |
line
Line number, not directly used.
|
protected boolean |
noLinefeed |
protected boolean |
noSemicolons |
protected Writer |
out |
protected StringBuffer |
outBuf |
private boolean |
overwriteIndentation
Overwrite indentation flag (cached).
|
private boolean |
overwriteParsePositions
Overwrite parse positions flag (cached).
|
protected boolean |
startAlreadyMarked |
protected int |
writtenCharacters
The number of charcters that have been send to the writer
|
| Constructor and Description |
|---|
PrettyPrinter(Writer o)
creates a new PrettyPrinter
|
PrettyPrinter(Writer o,
boolean noLinefeed) |
PrettyPrinter(Writer o,
boolean noLinefeed,
SVInstantiations svi) |
PrettyPrinter(Writer o,
SVInstantiations svi) |
private int line
private int column
protected int level
protected Writer out
protected StringBuffer outBuf
protected boolean noLinefeed
protected boolean noSemicolons
protected Type classToPrint
de.uka.ilkd.key.testgen.pp.unittest.ppAndJavaASTExtension.CompilableJavaCardPPprotected int firstStatementStart
protected int firstStatementEnd
protected boolean startAlreadyMarked
protected boolean endAlreadyMarked
protected Object firstStatement
protected SVInstantiations instantiations
private final Stack<Integer> keywordStarts
protected int writtenCharacters
private boolean isPrintingSingleLineComments
protected HashMap<SourceElement,Position> indentMap
private static final char[] BLANKS
private static final char[] FEEDS
private int indentation
private boolean overwriteIndentation
private boolean overwriteParsePositions
public PrettyPrinter(Writer o)
public PrettyPrinter(Writer o, SVInstantiations svi)
public PrettyPrinter(Writer o, boolean noLinefeed)
public PrettyPrinter(Writer o, boolean noLinefeed, SVInstantiations svi)
protected void output()
throws IOException
IOExceptionprotected int getCurrentPos()
protected void markStart(int n,
Object stmt)
n - offset from the current positionstmt - current statement;protected void markEnd(int n,
Object stmt)
n - offset from the current positionpublic Range getRangeOfFirstExecutableStatement()
protected final void markKeywordStart()
protected final void markKeywordEnd()
public final Range[] getKeywordRanges()
public void reset()
public void setWriter(Writer out)
public int getLine()
public int getColumn()
public int getIndentationLevel()
public void setIndentationLevel(int level)
level - an int value.public int getTotalIndentation()
public void changeLevel(int delta)
delta - an int value.protected void writeIndentation(int lf,
int blanks)
throws IOException
IOExceptionprotected void writeIndentation(Position relative) throws IOException
IOExceptionprotected void writeIndentation(SourceElement elem) throws IOException
elem - a source element.IOException - occasionally thrown.protected void writeInternalIndentation(SourceElement elem) throws IOException
elem - a source element.IOException - occasionally thrown.protected void writeSymbol(int lf,
int levelChange,
String symbol)
throws IOException
lf - an int value.levelChange - an int value.symbol - a string.IOException - occasionally thrown.protected static String encodeUnicodeChars(String str)
str - the input string.protected void scheduleComment(SingleLineComment slc)
slc - the comment to delay.protected void writeElement(int lf,
int levelChange,
int blanks,
SourceElement elem)
throws IOException
IOExceptionprotected Position getRelativePosition(SourceElement first)
protected void writeToken(int lf,
int blanks,
String image,
NonTerminalProgramElement parent)
throws IOException
IOExceptionSourceElement.prettyPrint(de.uka.ilkd.key.java.PrettyPrinter)protected final void writeToken(int blanks,
String image,
NonTerminalProgramElement parent)
throws IOException
IOExceptionprotected final void writeToken(String image, NonTerminalProgramElement parent) throws IOException
IOExceptionprotected void writeElement(int lf,
int blanks,
SourceElement elem)
throws IOException
lf - an int value.blanks - an int value.elem - a source element.IOException - occasionally thrown.protected void writeElement(int blanks,
SourceElement elem)
throws IOException
blanks - an int value.elem - a source element.IOException - occasionally thrown.protected void writeElement(SourceElement elem) throws IOException
elem - a source element.IOException - occasionally thrown.protected void writeImmutableArrayOfProgramElement(int firstLF,
int levelChange,
int firstBlanks,
String separationSymbol,
int separationLF,
int separationBlanks,
ImmutableArray<? extends ProgramElement> list)
throws IOException
IOExceptionprotected void writeKeywordList(int firstLF,
int levelChange,
int firstBlanks,
ImmutableArray<? extends ProgramElement> list)
throws IOException
IOExceptionprotected void writeKeywordList(ImmutableArray<? extends ProgramElement> list) throws IOException
list - a program element list.IOException - occasionally thrown.protected void writeCommaList(int firstLF,
int levelChange,
int firstBlanks,
ImmutableArray<? extends ProgramElement> list)
throws IOException
IOExceptionprotected void writeCommaList(int separationBlanks,
ImmutableArray<? extends ProgramElement> list)
throws IOException
list - a program element list.IOException - occasionally thrown.protected void writeCommaList(ImmutableArray<? extends ProgramElement> list) throws IOException
list - a program element list.IOException - occasionally thrown.protected void writeLineList(int firstLF,
int levelChange,
int firstBlanks,
ImmutableArray<? extends ProgramElement> list)
throws IOException
IOExceptionprotected void writeLineList(ImmutableArray<? extends ProgramElement> list) throws IOException
list - a program element list.IOException - occasionally thrown.protected void writeBlockList(int firstLF,
int levelChange,
int firstBlanks,
ImmutableArray<? extends ProgramElement> list)
throws IOException
IOExceptionprotected void writeBlockList(ImmutableArray<? extends ProgramElement> list) throws IOException
list - a program element list.IOException - occasionally thrown.private void dumpComments()
throws IOException
IOExceptionpublic void write(int c)
throws IOException
c - an int value.IOException - occasionally thrown.public void write(char[] cbuf)
throws IOException
cbuf - a char value.IOException - occasionally thrown.public void write(char[] cbuf,
int off,
int len)
throws IOException
cbuf - an array of char.off - an int value.len - an int value.IOException - occasionally thrown.public void write(String str) throws IOException
str - a string.IOException - occasionally thrown.public void write(String str, int off, int len) throws IOException
str - a string.off - an int value.len - an int value.IOException - occasionally thrown.protected int getIndentation()
protected boolean isOverwritingIndentation()
protected boolean isOverwritingParsePositions()
protected void printHeader(int lf,
int blanks,
ProgramElement elem)
throws IOException
lf - an int value.blanks - an int value.elem - a program element.IOException - occasionally thrown.protected void printHeader(int blanks,
ProgramElement elem)
throws IOException
blanks - an int value.elem - a program element.IOException - occasionally thrown.protected void printHeader(ProgramElement elem) throws IOException
elem - a program element.IOException - occasionally thrown.protected void printHeader(int lf,
int levelChange,
int blanks,
ProgramElement x)
throws IOException
lf - number of line feeds.levelChange - the level change.blanks - number of white spaces.x - the program element.IOException - occasionally thrown.protected void printFooter(ProgramElement x) throws IOException
x - the program element.IOException - occasionally thrown.protected void printOperator(Operator x, String symbol) throws IOException
IOExceptionpublic void printProgramElementName(ProgramElementName x) throws IOException
IOExceptionpublic void printProgramVariable(ProgramVariable x) throws IOException
IOExceptionpublic void printProgramMethod(IProgramMethod x) throws IOException
IOExceptionpublic void printProgramMetaConstruct(ProgramTransformer x) throws IOException
IOExceptionpublic void printContextStatementBlock(ContextStatementBlock x) throws IOException
IOExceptionpublic void printIntLiteral(IntLiteral x) throws IOException
IOExceptionpublic void printBigintLiteral(BigintLiteral x) throws IOException
IOExceptionpublic void printBooleanLiteral(BooleanLiteral x) throws IOException
IOExceptionpublic void printEmptySetLiteral(EmptySetLiteral x) throws IOException
IOExceptionpublic void printSingleton(Singleton x) throws IOException
IOExceptionpublic void printSetUnion(SetUnion x) throws IOException
IOExceptionpublic void printIntersect(Intersect x) throws IOException
IOExceptionpublic void printSetMinus(SetMinus x) throws IOException
IOExceptionpublic void printAllFields(AllFields x) throws IOException
IOExceptionpublic void printAllObjects(AllObjects x) throws IOException
IOExceptionpublic void printEmptySeqLiteral(EmptySeqLiteral x) throws IOException
IOExceptionpublic void printSeqLength(SeqLength x) throws IOException
IOExceptionpublic void printSeqGet(SeqGet x) throws IOException
IOExceptionpublic void printSeqSingleton(SeqSingleton x) throws IOException
IOExceptionpublic void printSeqConcat(SeqConcat x) throws IOException
IOExceptionpublic void printIndexOf(SeqIndexOf x) throws IOException
IOExceptionpublic void printSeqSub(SeqSub x) throws IOException
IOExceptionpublic void printSeqReverse(SeqReverse x) throws IOException
IOExceptionpublic void printDLEmbeddedExpression(DLEmbeddedExpression x) throws IOException
IOExceptionpublic void printStringLiteral(StringLiteral x) throws IOException
IOExceptionpublic void printNullLiteral(NullLiteral x) throws IOException
IOExceptionpublic void printCharLiteral(CharLiteral x) throws IOException
IOExceptionpublic void printDoubleLiteral(DoubleLiteral x) throws IOException
IOExceptionpublic void printLongLiteral(LongLiteral x) throws IOException
IOExceptionpublic void printFloatLiteral(FloatLiteral x) throws IOException
IOExceptionpublic void printPackageSpecification(PackageSpecification x) throws IOException
IOExceptionpublic void printAssert(Assert x) throws IOException
IOExceptionpublic void printArrayDeclaration(ArrayDeclaration type) throws IOException
IOExceptionpublic void printTypeReference(TypeReference x) throws IOException
IOExceptionpublic void printTypeReference(TypeReference x, boolean fullTypeNames) throws IOException
IOExceptionpublic void printSchemaTypeReference(SchemaTypeReference x) throws IOException
IOExceptionpublic void printFieldReference(FieldReference x) throws IOException
IOExceptionpublic void printPackageReference(PackageReference x) throws IOException
IOExceptionpublic void printThrows(Throws x) throws IOException
IOExceptionpublic void printArrayInitializer(ArrayInitializer x) throws IOException
IOExceptionpublic void printCompilationUnit(CompilationUnit x) throws IOException
IOExceptionpublic void printClassDeclaration(ClassDeclaration x) throws IOException
IOExceptionprotected boolean containsDefaultConstructor(ImmutableArray<MemberDeclaration> members)
public void printInterfaceDeclaration(InterfaceDeclaration x) throws IOException
IOExceptionprotected ImmutableArray<Modifier> removeFinal(ImmutableArray<Modifier> ma)
protected ImmutableArray<Modifier> replacePrivateByPublic(ImmutableArray<Modifier> ma)
public void printFieldDeclaration(FieldDeclaration x) throws IOException
IOExceptionpublic void printLocalVariableDeclaration(LocalVariableDeclaration x) throws IOException
IOExceptionpublic void printVariableDeclaration(VariableDeclaration x) throws IOException
IOExceptionpublic void printMethodDeclaration(MethodDeclaration x) throws IOException
IOExceptionpublic void printClassInitializer(ClassInitializer x) throws IOException
IOExceptionpublic void printStatementBlock(StatementBlock x) throws IOException
IOExceptionpublic void printBreak(Break x) throws IOException
IOExceptionpublic void printContinue(Continue x) throws IOException
IOExceptionpublic void printReturn(Return x) throws IOException
IOExceptionpublic void printThrow(Throw x) throws IOException
IOExceptionpublic void printDo(Do x) throws IOException
IOExceptionpublic void printDo(Do x, boolean includeBody) throws IOException
IOExceptionprivate static void removeChar(StringBuffer sb, char c)
public void printEnhancedFor(EnhancedFor x) throws IOException
IOExceptionpublic void printEnhancedFor(EnhancedFor x, boolean includeBody) throws IOException
IOExceptionpublic void printFor(For x) throws IOException
IOExceptionpublic void printFor(For x, boolean includeBody) throws IOException
IOExceptionpublic void printWhile(While x) throws IOException
IOExceptionpublic void printWhile(While x, boolean includeBody) throws IOException
IOExceptionpublic void printIf(If x) throws IOException
IOExceptionpublic void printIf(If x, boolean includeBranches) throws IOException
IOExceptionpublic void printSwitch(Switch x) throws IOException
IOExceptionpublic void printSwitch(Switch x, boolean includeBranches) throws IOException
IOExceptionpublic void printTry(Try x) throws IOException
IOExceptionpublic void printLabeledStatement(LabeledStatement x) throws IOException
IOExceptionpublic void printMethodFrame(MethodFrame x) throws IOException
IOExceptionpublic void printCatchAllStatement(CatchAllStatement x) throws IOException
IOExceptionpublic void printMethodBodyStatement(MethodBodyStatement x) throws IOException
IOExceptionpublic void printSynchronizedBlock(SynchronizedBlock x) throws IOException
IOExceptionpublic void printImport(Import x) throws IOException
IOExceptionpublic void printExtends(Extends x) throws IOException
IOExceptionpublic void printImplements(Implements x) throws IOException
IOExceptionpublic void printVariableSpecification(VariableSpecification x) throws IOException
IOExceptionpublic void printBinaryAnd(BinaryAnd x) throws IOException
IOExceptionpublic void printBinaryAndAssignment(BinaryAndAssignment x) throws IOException
IOExceptionpublic void printBinaryOrAssignment(BinaryOrAssignment x) throws IOException
IOExceptionpublic void printBinaryXOrAssignment(BinaryXOrAssignment x) throws IOException
IOExceptionpublic void printCopyAssignment(CopyAssignment x) throws IOException
IOExceptionpublic void printDivideAssignment(DivideAssignment x) throws IOException
IOExceptionpublic void printMinusAssignment(MinusAssignment x) throws IOException
IOExceptionpublic void printModuloAssignment(ModuloAssignment x) throws IOException
IOExceptionpublic void printPlusAssignment(PlusAssignment x) throws IOException
IOExceptionpublic void printPostDecrement(PostDecrement x) throws IOException
IOExceptionpublic void printPostIncrement(PostIncrement x) throws IOException
IOExceptionpublic void printPreDecrement(PreDecrement x) throws IOException
IOExceptionpublic void printPreIncrement(PreIncrement x) throws IOException
IOExceptionpublic void printShiftLeftAssignment(ShiftLeftAssignment x) throws IOException
IOExceptionpublic void printShiftRightAssignment(ShiftRightAssignment x) throws IOException
IOExceptionpublic void printTimesAssignment(TimesAssignment x) throws IOException
IOExceptionpublic void printUnsignedShiftRightAssignment(UnsignedShiftRightAssignment x) throws IOException
IOExceptionpublic void printBinaryNot(BinaryNot x) throws IOException
IOExceptionpublic void printBinaryOr(BinaryOr x) throws IOException
IOExceptionpublic void printBinaryXOr(BinaryXOr x) throws IOException
IOExceptionpublic void printConditional(Conditional x) throws IOException
IOExceptionpublic void printDivide(Divide x) throws IOException
IOExceptionpublic void printEquals(Equals x) throws IOException
IOExceptionpublic void printGreaterOrEquals(GreaterOrEquals x) throws IOException
IOExceptionpublic void printGreaterThan(GreaterThan x) throws IOException
IOExceptionpublic void printLessOrEquals(LessOrEquals x) throws IOException
IOExceptionpublic void printLessThan(LessThan x) throws IOException
IOExceptionpublic void printNotEquals(NotEquals x) throws IOException
IOExceptionpublic void printNewArray(NewArray x) throws IOException
IOExceptionpublic void printInstanceof(Instanceof x) throws IOException
IOExceptionpublic void printExactInstanceof(ExactInstanceof x) throws IOException
IOExceptionpublic void printNew(New x) throws IOException
IOExceptionpublic void printTypeCast(TypeCast x) throws IOException
IOExceptionpublic void printLogicalAnd(LogicalAnd x) throws IOException
IOExceptionpublic void printLogicalNot(LogicalNot x) throws IOException
IOExceptionpublic void printLogicalOr(LogicalOr x) throws IOException
IOExceptionpublic void printMinus(Minus x) throws IOException
IOExceptionpublic void printModulo(Modulo x) throws IOException
IOExceptionpublic void printNegative(Negative x) throws IOException
IOExceptionpublic void printPlus(Plus x) throws IOException
IOExceptionpublic void printPositive(Positive x) throws IOException
IOExceptionpublic void printShiftLeft(ShiftLeft x) throws IOException
IOExceptionpublic void printShiftRight(ShiftRight x) throws IOException
IOExceptionpublic void printTimes(Times x) throws IOException
IOExceptionpublic void printUnsignedShiftRight(UnsignedShiftRight x) throws IOException
IOExceptionpublic void printArrayReference(ArrayReference x) throws IOException
IOExceptionpublic void printMetaClassReference(MetaClassReference x) throws IOException
IOExceptionpublic void printMethodReference(MethodReference x) throws IOException
IOExceptionprotected void printMethodReference(MethodReference x, boolean withSemicolon) throws IOException
IOExceptionpublic void printMethod(IProgramMethod x) throws IOException
IOExceptionpublic void printFullMethodSignature(IProgramMethod x) throws IOException
IOExceptionprotected void writeFullMethodSignature(IProgramMethod x) throws IOException
IOExceptionpublic void printExecutionContext(ExecutionContext x) throws IOException
IOExceptionpublic void printSuperConstructorReference(SuperConstructorReference x) throws IOException
IOExceptionpublic void printThisConstructorReference(ThisConstructorReference x) throws IOException
IOExceptionpublic void printSuperReference(SuperReference x) throws IOException
IOExceptionpublic void printThisReference(ThisReference x) throws IOException
IOExceptionpublic void printArrayLengthReference(ArrayLengthReference x) throws IOException
IOExceptionpublic void printThen(Then x) throws IOException
IOExceptionpublic void printElse(Else x) throws IOException
IOExceptionpublic void printCase(Case x) throws IOException
IOExceptionpublic void printCatch(Catch x) throws IOException
IOExceptionpublic void printDefault(Default x) throws IOException
IOExceptionpublic void printFinally(Finally x) throws IOException
IOExceptionpublic void printModifier(Modifier x) throws IOException
IOExceptionpublic void printSchemaVariable(SchemaVariable x) throws IOException
IOExceptionpublic void printEmptyStatement(EmptyStatement x) throws IOException
IOExceptionpublic void printComment(Comment x) throws IOException
IOExceptionpublic void printParenthesizedExpression(ParenthesizedExpression x) throws IOException
IOExceptionpublic void printPassiveExpression(PassiveExpression x) throws IOException
IOExceptionpublic void printTransactionStatement(TransactionStatement x) throws IOException
IOExceptionpublic void printEmptyMapLiteral(EmptyMapLiteral x) throws IOException
IOException