Package com.google.googlejavaformat
Class Doc.Token
- java.lang.Object
-
- com.google.googlejavaformat.Doc
-
- com.google.googlejavaformat.Doc.Token
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDoc.Token.RealOrImaginaryIs a Token a real token, or imaginary (e.g., a token generated incorrectly, or an EOF)?
-
Field Summary
Fields Modifier and Type Field Description private java.util.Optional<Indent>breakAndIndentTrailingCommentprivate IndentplusIndentCommentsBeforeprivate Doc.Token.RealOrImaginaryrealOrImaginaryprivate Input.Tokentoken-
Fields inherited from class com.google.googlejavaformat.Doc
MAX_LINE_WIDTH
-
-
Constructor Summary
Constructors Modifier Constructor Description privateToken(Input.Token token, Doc.Token.RealOrImaginary realOrImaginary, Indent plusIndentCommentsBefore, java.util.Optional<Indent> breakAndIndentTrailingComment)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(DocBuilder builder)Add anOpto aDocBuilder.(package private) java.util.Optional<Indent>breakAndIndentTrailingComment()Force a line break and indent trailing javadoc or block comments.Doc.StatecomputeBreaks(CommentsHelper commentsHelper, int maxWidth, Doc.State state)Make breaking decisions for aDoc.(package private) java.lang.StringcomputeFlat()Compute theDoc's flat value.(package private) com.google.common.collect.Range<java.lang.Integer>computeRange()(package private) intcomputeWidth()Compute theDoc's width.(package private) IndentgetPlusIndentCommentsBefore()How 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, java.util.Optional<Indent> breakAndIndentTrailingComment)Make aToken.(package private) Doc.Token.RealOrImaginaryrealOrImaginary()Is the token good? That is, does it match anInput.Token?private Input.Toktok()java.lang.StringtoString()voidwrite(Output output)Write aDocto anOutput, after breaking decisions have been made.
-
-
-
Field Detail
-
token
private final Input.Token token
-
realOrImaginary
private final Doc.Token.RealOrImaginary realOrImaginary
-
plusIndentCommentsBefore
private final Indent plusIndentCommentsBefore
-
breakAndIndentTrailingComment
private final java.util.Optional<Indent> breakAndIndentTrailingComment
-
-
Constructor Detail
-
Token
private Token(Input.Token token, Doc.Token.RealOrImaginary realOrImaginary, Indent plusIndentCommentsBefore, java.util.Optional<Indent> breakAndIndentTrailingComment)
-
-
Method Detail
-
tok
private Input.Tok tok()
-
getPlusIndentCommentsBefore
Indent getPlusIndentCommentsBefore()
How much extra to indent comments before theToken.- Returns:
- the extra indent
-
breakAndIndentTrailingComment
java.util.Optional<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, java.util.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
public void add(DocBuilder builder)
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
java.lang.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<java.lang.Integer> computeRange()
Description copied from class:Doc- Specified by:
computeRangein classDoc- Returns:
- the
Range
-
computeBreaks
public Doc.State computeBreaks(CommentsHelper commentsHelper, int maxWidth, Doc.State state)
Description copied from class:DocMake breaking decisions for aDoc.- Specified by:
computeBreaksin classDocmaxWidth- the maximum line widthstate- the current output state- Returns:
- the new output state
-
write
public void write(Output output)
Description copied from class:DocWrite aDocto anOutput, after breaking decisions have been made.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-