Package spoon.reflect.visitor
Class PrinterHelper
java.lang.Object
spoon.reflect.visitor.PrinterHelper
Supports configurable printing of text with indentations and line and column counting
-
Field Summary
Modifier and TypeFieldDescriptionprotected StringBuffer
The string buffer in which the code is generated.protected boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionwrites as many newlines as needed for the current line to match the end line of the passed elementwrites as many newlines as needed to align the line number again between the element position and the current line numberprotected void
decTab()
Decrements the current number of tabs.int
incTab()
Increments the current number of tabs.void
mapLine(CtElement e, CtCompilationUnit unitExpected)
void
putLineNumberMapping(int valueLine)
boolean
void
reset()
resets to the initial statevoid
setLineSeparator(String lineSeparator)
void
setShouldWriteTabs(boolean b)
setTabCount(int tabCount)
Sets the current number of tabs.toString()
void
write(char c)
Outputs a char.Outputs a string.writeln()
Generates a new line.void
writes a space ' '
-
Field Details
-
sbf
The string buffer in which the code is generated. -
shouldWriteTabs
protected boolean shouldWriteTabs
-
-
Constructor Details
-
PrinterHelper
public PrinterHelper() -
PrinterHelper
-
-
Method Details
-
reset
public void reset()resets to the initial state -
write
Outputs a string. -
write
Outputs a char. -
writeln
Generates a new line. -
autoWriteTabs
protected void autoWriteTabs() -
incTab
Increments the current number of tabs. -
decTab
Decrements the current number of tabs. -
getTabCount
public int getTabCount()- Returns:
- the current number of tabs.
-
setTabCount
Sets the current number of tabs. -
removeLine
public boolean removeLine() -
adjustStartPosition
writes as many newlines as needed to align the line number again between the element position and the current line number -
adjustEndPosition
writes as many newlines as needed for the current line to match the end line of the passed element- Parameters:
e
- element whose line number will be preserved by adding newlines- Returns:
- PrinterHelper
-
undefineLine
public void undefineLine() -
mapLine
-
putLineNumberMapping
public void putLineNumberMapping(int valueLine) -
getLineNumberMapping
-
toString
-
getLineSeparator
- Returns:
- current line separator. By default there is CR LF, LF or CR depending on the Operation system defined by System.getProperty("line.separator")
-
setLineSeparator
- Parameters:
lineSeparator
- characters which will be printed as End of line. By default there is System.getProperty("line.separator")
-
writeSpace
public void writeSpace()writes a space ' ' -
setShouldWriteTabs
public void setShouldWriteTabs(boolean b)
-