Class JavadocWriter
- java.lang.Object
-
- com.google.googlejavaformat.java.javadoc.JavadocWriter
-
final class JavadocWriter extends java.lang.ObjectStateful object that accepts "requests" and "writes," producing formatted Javadoc.Our Javadoc formatter doesn't ever generate a parse tree, only a stream of tokens, so the writer must compute and store the answer to questions like "How many levels of nested HTML list are we inside?"
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classJavadocWriter.AutoIndent(package private) static classJavadocWriter.RequestedWhitespaceThe kind of whitespace that has been requested between the previous and next tokens.
-
Field Summary
Fields Modifier and Type Field Description private booleanatStartOfLineprivate intblockIndentprivate booleancontinuingFooterTagprivate NestingCountercontinuingListCountprivate NestingCountercontinuingListItemCountprivate booleancontinuingListItemOfInnermostListWhether we are inside an<li>element, excluding the case in which the<li>contains a<ul>or<ol>that we are also inside -- unless of course we're inside an<li>element in that inner list :)private intindentForMoeEndStripCommentprivate java.lang.StringBuilderoutputprivate NestingCounterpostWriteModifiedContinuingListCountprivate intremainingOnLineprivate TokenrequestedMoeBeginStripCommentprivate JavadocWriter.RequestedWhitespacerequestedWhitespaceprivate static com.google.common.collect.ImmutableSet<Token.Type>START_OF_LINE_TOKENSTokens that are always pinned to the following token.private booleanwroteAnythingSignificant
-
Constructor Summary
Constructors Constructor Description JavadocWriter(int blockIndent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidappendSpaces(int count)private intinnerIndent()private voidrequestBlankLine()(package private) voidrequestMoeBeginStripComment(Token token)private voidrequestNewline()(package private) voidrequestWhitespace()Requests whitespace between the previously written token and the next written token.private voidrequestWhitespace(JavadocWriter.RequestedWhitespace requestedWhitespace)java.lang.StringtoString()(package private) voidwriteBeginJavadoc()private voidwriteBlankLine()(package private) voidwriteBlockquoteOpenOrClose(Token token)(package private) voidwriteBr(Token token)(package private) voidwriteCodeClose(Token token)(package private) voidwriteCodeOpen(Token token)(package private) voidwriteEndJavadoc()(package private) voidwriteFooterJavadocTagStart(Token token)(package private) voidwriteHeaderClose(Token token)(package private) voidwriteHeaderOpen(Token token)(package private) voidwriteHtmlComment(Token token)(package private) voidwriteLineBreakNoAutoIndent()(package private) voidwriteListClose(Token token)(package private) voidwriteListItemOpen(Token token)(package private) voidwriteListOpen(Token token)(package private) voidwriteLiteral(Token token)(package private) voidwriteMoeEndStripComment(Token token)private voidwriteNewline()private voidwriteNewline(JavadocWriter.AutoIndent autoIndent)(package private) voidwriteParagraphOpen(Token token)(package private) voidwritePreClose(Token token)(package private) voidwritePreOpen(Token token)(package private) voidwriteTableClose(Token token)(package private) voidwriteTableOpen(Token token)private voidwriteToken(Token token)
-
-
-
Field Detail
-
blockIndent
private final int blockIndent
-
output
private final java.lang.StringBuilder output
-
continuingListItemOfInnermostList
private boolean continuingListItemOfInnermostList
Whether we are inside an<li>element, excluding the case in which the<li>contains a<ul>or<ol>that we are also inside -- unless of course we're inside an<li>element in that inner list :)
-
continuingFooterTag
private boolean continuingFooterTag
-
continuingListItemCount
private final NestingCounter continuingListItemCount
-
continuingListCount
private final NestingCounter continuingListCount
-
postWriteModifiedContinuingListCount
private final NestingCounter postWriteModifiedContinuingListCount
-
remainingOnLine
private int remainingOnLine
-
atStartOfLine
private boolean atStartOfLine
-
requestedWhitespace
private JavadocWriter.RequestedWhitespace requestedWhitespace
-
requestedMoeBeginStripComment
private Token requestedMoeBeginStripComment
-
indentForMoeEndStripComment
private int indentForMoeEndStripComment
-
wroteAnythingSignificant
private boolean wroteAnythingSignificant
-
START_OF_LINE_TOKENS
private static final com.google.common.collect.ImmutableSet<Token.Type> START_OF_LINE_TOKENS
Tokens that are always pinned to the following token. For example,<p>in<p>Foo bar(never<p> Foo baror<p>\nFoo bar).This is not the only kind of "pinning" that we do: See also the joining of LITERAL tokens done by the lexer. The special pinning here is necessary because these tokens are not of type LITERAL (because they require other special handling).
-
-
Method Detail
-
requestWhitespace
void requestWhitespace()
Requests whitespace between the previously written token and the next written token. The request may be honored, or it may be overridden by a request for "more significant" whitespace, like a newline.
-
requestMoeBeginStripComment
void requestMoeBeginStripComment(Token token)
-
writeBeginJavadoc
void writeBeginJavadoc()
-
writeEndJavadoc
void writeEndJavadoc()
-
writeFooterJavadocTagStart
void writeFooterJavadocTagStart(Token token)
-
writeListOpen
void writeListOpen(Token token)
-
writeListClose
void writeListClose(Token token)
-
writeListItemOpen
void writeListItemOpen(Token token)
-
writeHeaderOpen
void writeHeaderOpen(Token token)
-
writeHeaderClose
void writeHeaderClose(Token token)
-
writeParagraphOpen
void writeParagraphOpen(Token token)
-
writeBlockquoteOpenOrClose
void writeBlockquoteOpenOrClose(Token token)
-
writePreOpen
void writePreOpen(Token token)
-
writePreClose
void writePreClose(Token token)
-
writeCodeOpen
void writeCodeOpen(Token token)
-
writeCodeClose
void writeCodeClose(Token token)
-
writeTableOpen
void writeTableOpen(Token token)
-
writeTableClose
void writeTableClose(Token token)
-
writeMoeEndStripComment
void writeMoeEndStripComment(Token token)
-
writeHtmlComment
void writeHtmlComment(Token token)
-
writeBr
void writeBr(Token token)
-
writeLineBreakNoAutoIndent
void writeLineBreakNoAutoIndent()
-
writeLiteral
void writeLiteral(Token token)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
requestBlankLine
private void requestBlankLine()
-
requestNewline
private void requestNewline()
-
requestWhitespace
private void requestWhitespace(JavadocWriter.RequestedWhitespace requestedWhitespace)
-
writeToken
private void writeToken(Token token)
-
writeBlankLine
private void writeBlankLine()
-
writeNewline
private void writeNewline()
-
writeNewline
private void writeNewline(JavadocWriter.AutoIndent autoIndent)
-
innerIndent
private int innerIndent()
-
appendSpaces
private void appendSpaces(int count)
-
-