static class CodePrinter.PrettyCodePrinter extends CodePrinter.MappedCodePrinter
| Modifier and Type | Field and Description |
|---|---|
private int |
indent |
(package private) static java.lang.String |
INDENT |
code, lineIndex, lineLength, lineLengthThresholdsawFunction, statementNeedsEnded, statementStarted| Modifier | Constructor and Description |
|---|---|
private |
PrettyCodePrinter(int lineLengthThreshold,
boolean createSourceMap,
SourceMap.DetailLevel sourceMapDetailLevel) |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
append(java.lang.String str)
Appends a string to the code, keeping track of the current line length.
|
(package private) void |
appendBlockEnd() |
(package private) void |
appendBlockStart() |
(package private) void |
appendOp(java.lang.String op,
boolean binOp) |
(package private) void |
beginCaseBody() |
(package private) boolean |
breakAfterBlockFor(Node n,
boolean isStatementContext) |
(package private) void |
endCaseBody() |
(package private) void |
endFile()
Called when we're at the end of a file.
|
(package private) void |
endFunction(boolean statementContext) |
(package private) void |
endLine() |
private static Node |
getTryForCatch(Node n) |
(package private) void |
listSeparator() |
(package private) void |
maybeCutLine()
This may start a new line if the current line is longer than the line
length threshold.
|
(package private) void |
maybeInsertSpace()
Allows a consumer to insert spaces in locations where it is unnecessary
but may improve the readability of the code.
|
(package private) void |
maybeLineBreak() |
(package private) boolean |
shouldPreserveExtraBlocks()
If the body of a for loop or the then clause of an if statement has
a single statement, should it be wrapped in a block?
If the body of a for loop or the then clause of an if statement has
a single statement, should it be wrapped in a block? Doing so can
help when pretty-printing the code, and permits putting a debugging
breakpoint on the statement inside the condition.
|
(package private) void |
startNewLine()
Adds a newline to the code, resetting the line length and handling
indenting for pretty printing.
|
endSourceMapping, generateSourceMap, getCode, getCurrentCharIndex, getCurrentLineIndex, getLastChar, reportLineCut, startSourceMappingadd, addConstant, addIdentifier, addNumber, addOp, beginBlock, continueProcessing, endBlock, endBlock, endClass, endStatement, endStatement, isNegativeZero, isWordChar, maybeEndStatement, notePreferredLineBreakstatic final java.lang.String INDENT
private int indent
private PrettyCodePrinter(int lineLengthThreshold,
boolean createSourceMap,
SourceMap.DetailLevel sourceMapDetailLevel)
lineLengthThreshold - The length of a line after which we force
a newline when possible.createSourceMap - Whether to generate source map data.sourceMapDetailLevel - A filter to control which nodes get mapped
into the source map.void append(java.lang.String str)
append in class CodeConsumervoid startNewLine()
startNewLine in class CodeConsumervoid maybeLineBreak()
maybeLineBreak in class CodeConsumervoid maybeCutLine()
maybeCutLine in class CodeConsumervoid endLine()
endLine in class CodeConsumervoid appendBlockStart()
appendBlockStart in class CodeConsumervoid appendBlockEnd()
appendBlockEnd in class CodeConsumervoid listSeparator()
listSeparator in class CodeConsumervoid endFunction(boolean statementContext)
endFunction in class CodeConsumervoid beginCaseBody()
beginCaseBody in class CodeConsumervoid endCaseBody()
endCaseBody in class CodeConsumervoid appendOp(java.lang.String op,
boolean binOp)
appendOp in class CodeConsumerboolean shouldPreserveExtraBlocks()
shouldPreserveExtraBlocks in class CodeConsumervoid maybeInsertSpace()
CodeConsumermaybeInsertSpace in class CodeConsumerprivate static Node getTryForCatch(Node n)
boolean breakAfterBlockFor(Node n, boolean isStatementContext)
breakAfterBlockFor in class CodeConsumervoid endFile()
CodeConsumerendFile in class CodeConsumer