Package com.google.googlejavaformat
Class Doc.Level
- java.lang.Object
-
- com.google.googlejavaformat.Doc
-
- com.google.googlejavaformat.Doc.Level
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.List<Doc.Break>breaksprivate java.util.List<Doc>docs(package private) booleanoneLineTrue if the entireDoc.Levelfits on one line.private IndentplusIndent(package private) java.util.List<java.util.List<Doc>>splits-
Fields inherited from class com.google.googlejavaformat.Doc
MAX_LINE_WIDTH
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidadd(Doc doc)Add aDocto theLevel.private static Doc.StatecomputeBreakAndSplit(CommentsHelper commentsHelper, int maxWidth, Doc.State state, java.util.Optional<Doc.Break> optBreakDoc, java.util.List<Doc> split)Lay out a Break-separated group of Docs in the current Level.Doc.StatecomputeBreaks(CommentsHelper commentsHelper, int maxWidth, Doc.State state)Make breaking decisions for aDoc.private Doc.StatecomputeBroken(CommentsHelper commentsHelper, int maxWidth, Doc.State state)Compute breaks for aDoc.Levelthat spans multiple lines.(package private) java.lang.StringcomputeFlat()Compute theDoc's flat value.(package private) com.google.common.collect.Range<java.lang.Integer>computeRange()private static Doc.StatecomputeSplit(CommentsHelper commentsHelper, int maxWidth, java.util.List<Doc> docs, Doc.State state)(package private) intcomputeWidth()Compute theDoc's width.(package private) static intgetWidth(java.util.List<Doc> docs)Get the width of a sequence ofDocs.(package private) static Doc.Levelmake(Indent plusIndent)Factory method forLevels.private static voidsplitByBreaks(java.util.List<Doc> docs, java.util.List<java.util.List<Doc>> splits, java.util.List<Doc.Break> breaks)java.lang.StringtoString()private static com.google.common.collect.Range<java.lang.Integer>union(com.google.common.collect.Range<java.lang.Integer> x, com.google.common.collect.Range<java.lang.Integer> y)voidwrite(Output output)Write aDocto anOutput, after breaking decisions have been made.private voidwriteFilled(Output output)
-
-
-
Constructor Detail
-
Level
private Level(Indent plusIndent)
-
-
Method Detail
-
make
static Doc.Level make(Indent plusIndent)
Factory method forLevels.- Parameters:
plusIndent- the extra indent inside theLevel- Returns:
- the new
Level
-
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
-
splitByBreaks
private static void splitByBreaks(java.util.List<Doc> docs, java.util.List<java.util.List<Doc>> splits, java.util.List<Doc.Break> breaks)
-
computeBroken
private Doc.State computeBroken(CommentsHelper commentsHelper, int maxWidth, Doc.State state)
Compute breaks for aDoc.Levelthat spans multiple lines.
-
computeBreakAndSplit
private static Doc.State computeBreakAndSplit(CommentsHelper commentsHelper, int maxWidth, Doc.State state, java.util.Optional<Doc.Break> optBreakDoc, java.util.List<Doc> split)
Lay out a Break-separated group of Docs in the current Level.
-
computeSplit
private static Doc.State computeSplit(CommentsHelper commentsHelper, int maxWidth, java.util.List<Doc> docs, Doc.State state)
-
write
public void write(Output output)
Description copied from class:DocWrite aDocto anOutput, after breaking decisions have been made.
-
writeFilled
private void writeFilled(Output output)
-
getWidth
static int getWidth(java.util.List<Doc> docs)
Get the width of a sequence ofDocs.- Parameters:
docs- theDocs- Returns:
- the width
-
union
private static com.google.common.collect.Range<java.lang.Integer> union(com.google.common.collect.Range<java.lang.Integer> x, com.google.common.collect.Range<java.lang.Integer> y)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-