Package com.google.googlejavaformat
Class Doc.Token
java.lang.Object
com.google.googlejavaformat.Doc
com.google.googlejavaformat.Doc.Token
- All Implemented Interfaces:
Op
- Enclosing class:
Doc
A leaf
Doc for a token.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIs a Token a real token, or imaginary (e.g., a token generated incorrectly, or an EOF)? -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Indentprivate final Doc.Token.RealOrImaginaryprivate final Input.TokenFields inherited from class com.google.googlejavaformat.Doc
MAX_LINE_WIDTH -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateToken(Input.Token token, Doc.Token.RealOrImaginary realOrImaginary, Indent plusIndentCommentsBefore, Optional<Indent> breakAndIndentTrailingComment) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(DocBuilder builder) Add anOpto aDocBuilder.Force a line break and indent trailing javadoc or block comments.computeBreaks(CommentsHelper commentsHelper, int maxWidth, Doc.State state) Make breaking decisions for aDoc.(package private) StringCompute theDoc's flat value.(package private) com.google.common.collect.Range<Integer> (package private) intCompute theDoc's width.(package private) IndentHow much extra to indent comments before theToken.(package private) Input.TokengetToken()Return the wrappedInput.Token.(package private) static Opmake(Input.Token token, Doc.Token.RealOrImaginary realOrImaginary, Indent plusIndentCommentsBefore, Optional<Indent> breakAndIndentTrailingComment) Make aToken.(package private) Doc.Token.RealOrImaginaryIs the token good? That is, does it match anInput.Token?private Input.Toktok()toString()voidWrite aDocto anOutput, after breaking decisions have been made.
-
Field Details
-
token
-
realOrImaginary
-
plusIndentCommentsBefore
-
breakAndIndentTrailingComment
-
-
Constructor Details
-
Token
private Token(Input.Token token, Doc.Token.RealOrImaginary realOrImaginary, Indent plusIndentCommentsBefore, Optional<Indent> breakAndIndentTrailingComment)
-
-
Method Details
-
tok
-
getPlusIndentCommentsBefore
Indent getPlusIndentCommentsBefore()How much extra to indent comments before theToken.- Returns:
- the extra indent
-
breakAndIndentTrailingComment
Force a line break and indent trailing javadoc or block comments. -
make
static Op make(Input.Token token, Doc.Token.RealOrImaginary realOrImaginary, Indent plusIndentCommentsBefore, Optional<Indent> breakAndIndentTrailingComment) Make aToken.- Parameters:
token- theInput.Tokento wraprealOrImaginary- did thisInput.Tokenappear in the input, or was it generated incorrectly?plusIndentCommentsBefore- extraplusIndentfor comments just before this token- Returns:
- the new
Token
-
getToken
Input.Token getToken()Return the wrappedInput.Token.- Returns:
- the
Input.Token
-
realOrImaginary
Doc.Token.RealOrImaginary realOrImaginary()Is the token good? That is, does it match anInput.Token?- Returns:
- whether the @code Token} is good
-
add
Description copied from interface:OpAdd anOpto aDocBuilder.- Specified by:
addin interfaceOp- Parameters:
builder- theDocBuilder
-
computeWidth
int computeWidth()Description copied from class:DocCompute theDoc's width.- Specified by:
computeWidthin classDoc- Returns:
- the width
-
computeFlat
String computeFlat()Description copied from class:DocCompute theDoc's flat value. Not defined (and never called) if contains forced breaks.- Specified by:
computeFlatin classDoc- Returns:
- the flat value
-
computeRange
com.google.common.collect.Range<Integer> computeRange()Description copied from class:Doc- Specified by:
computeRangein classDoc- Returns:
- the
Range
-
computeBreaks
Description copied from class:DocMake breaking decisions for aDoc.- Specified by:
computeBreaksin classDoc- Parameters:
maxWidth- the maximum line widthstate- the current output state- Returns:
- the new output state
-
write
Description copied from class:DocWrite aDocto anOutput, after breaking decisions have been made. -
toString
-