Package com.palantir.javaformat.doc
Class Doc
java.lang.Object
com.palantir.javaformat.doc.HasUniqueId
com.palantir.javaformat.doc.Doc
- Direct Known Subclasses:
Break,Comment,Level,NonBreakingSpace,Token
JavaInputAstVisitor outputs a sequence of Ops using
OpsBuilder. This linear sequence is then transformed by DocBuilder into a tree-structured
Doc. The top-level Doc is a Level, which contains a sequence of Docs, including other
Levels. Leaf Docs are Tokens, representing language-level tokens; Comments, which may
also represent non-token Input.Toks, including comments and other white-space; NonBreakingSpaces,
representing single spaces; and Breaks, which represent optional line-breaks.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract StatecomputeBreaks(CommentsHelper commentsHelper, int maxWidth, State state, Obs.ExplorationNode explorationNode) Make breaking decisions for aDoc.protected abstract StringCompute theDoc's flat value.protected abstract com.google.common.collect.Range<Integer>protected abstract floatCompute theDoc's width.final StringgetFlat()Return aDoc's flat-string value; not defined (and never called) if the (@code Doc} contains forced breaks.abstract voidWrite aDocto anOutput, after breaking decisions have been made.Methods inherited from class com.palantir.javaformat.doc.HasUniqueId
id
-
Constructor Details
-
Doc
public Doc()
-
-
Method Details
-
getFlat
Return aDoc's flat-string value; not defined (and never called) if the (@code Doc} contains forced breaks.- Returns:
- the flat-string value
-
computeWidth
protected abstract float computeWidth()Compute theDoc's width.- Returns:
- the width, or
Float.POSITIVE_INFINITYif it must be broken
-
computeFlat
Compute theDoc's flat value. Not defined (and never called) if contains forced breaks.- Returns:
- the flat value
-
computeRange
- Returns:
- the
Range
-
computeBreaks
public abstract State computeBreaks(CommentsHelper commentsHelper, int maxWidth, State state, Obs.ExplorationNode explorationNode) Make breaking decisions for aDoc.- Parameters:
maxWidth- the maximum line widthstate- the current output state- Returns:
- the new output state
-
write
Write aDocto anOutput, after breaking decisions have been made.
-