Package com.palantir.javaformat.doc
Class Break
java.lang.Object
com.palantir.javaformat.doc.HasUniqueId
com.palantir.javaformat.doc.Doc
com.palantir.javaformat.doc.Break
- All Implemented Interfaces:
Op
A leaf node in a
Doc for an optional break.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(DocBuilder builder) Add anOpto aDocBuilder.static Break.Builderbuilder()computeBreaks(CommentsHelper commentsHelper, int maxWidth, State state, Obs.ExplorationNode observationNode) Make breaking decisions for aDoc.computeBreaks(State stateIn, boolean broken) protected StringCompute theDoc's flat value.protected com.google.common.collect.Range<Integer>protected floatCompute theDoc's width.intevalPlusIndent(State state) Return theBreak's extra indent.abstract FillModefillMode()abstract Stringflat()abstract booleanIf this break is restricted by its parentLevel'sLevel.getColumnLimitBeforeLastBreak().booleanisForced()Is theBreakforced?static BreakMake aBreak.static BreakMake aBreak.static BreakMake a forcedBreak.optTag()abstract IndentvoidWrite aDocto anOutput, after breaking decisions have been made.Methods inherited from class com.palantir.javaformat.doc.HasUniqueId
id
-
Constructor Details
-
Break
public Break()
-
-
Method Details
-
fillMode
-
flat
-
plusIndent
-
optTag
-
hasColumnLimit
public abstract boolean hasColumnLimit()If this break is restricted by its parentLevel'sLevel.getColumnLimitBeforeLastBreak(). -
make
Make aBreak.- Parameters:
fillMode- theFillModeflat- the text when not brokenplusIndent- extra indent if taken- Returns:
- the new
Break
-
make
public static Break make(FillMode fillMode, String flat, Indent plusIndent, Optional<BreakTag> optTag) Make aBreak.- Parameters:
fillMode- theFillModeflat- the text when not brokenplusIndent- extra indent if takenoptTag- an optional tag for remembering whether the break was taken- Returns:
- the new
Break
-
makeForced
Make a forcedBreak.- Returns:
- the new forced
Break
-
evalPlusIndent
Return theBreak's extra indent.- Returns:
- the extra indent
-
isForced
public boolean isForced()Is theBreakforced?- Returns:
- whether the
Breakis forced
-
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
-
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. -
builder
-