Package com.palantir.javaformat.doc
Class Token
java.lang.Object
com.palantir.javaformat.doc.HasUniqueId
com.palantir.javaformat.doc.Doc
com.palantir.javaformat.doc.Token
- All Implemented Interfaces:
Op
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)? -
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, State state, Obs.ExplorationNode observationNode) Make breaking decisions for aDoc.protected StringCompute theDoc's flat value.protected com.google.common.collect.Range<Integer>protected floatCompute theDoc's width.How much extra to indent comments before theToken.getToken()Return the wrappedInput.Token.static Opmake(Input.Token token, Token.RealOrImaginary realOrImaginary, Indent plusIndentCommentsBefore, Optional<Indent> breakAndIndentTrailingComment) Make aToken.Is the token good? That is, does it match anInput.Token?toString()voidWrite aDocto anOutput, after breaking decisions have been made.Methods inherited from class com.palantir.javaformat.doc.HasUniqueId
id
-
Method Details
-
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
public static Op make(Input.Token token, 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
Return the wrappedInput.Token.- Returns:
- the
Input.Token
-
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
protected float computeWidth()Description copied from class:DocCompute theDoc's width.- Specified by:
computeWidthin classDoc- Returns:
- the width, or
Float.POSITIVE_INFINITYif it must be broken
-
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
Description copied from class:Doc- Specified by:
computeRangein classDoc- Returns:
- the
Range
-
computeBreaks
public State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State state, Obs.ExplorationNode observationNode) 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
Description copied from class:DocWrite aDocto anOutput, after breaking decisions have been made. -
toString
-