public final class OpsBuilder
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
OpsBuilder.BlankLineWanted
A request to add or remove a blank line in the output.
|
static interface |
OpsBuilder.OpsOutput |
| Constructor and Description |
|---|
OpsBuilder(Input input)
The
OpsBuilder constructor. |
| Modifier and Type | Method and Description |
|---|---|
int |
actualSize(int position,
int length) |
java.lang.Integer |
actualStartColumn(int position) |
void |
addAll(java.util.List<Op> ops)
Add a list of
Ops. |
void |
blankLineWanted(OpsBuilder.BlankLineWanted wanted)
Force or suppress a blank line here in the output.
|
void |
breakOp()
Emit a
Break. |
void |
breakOp(Break breakOp)
Emit a self-built
Break. |
void |
breakOp(FillMode fillMode,
java.lang.String flat,
Indent plusIndent)
Emit a generic
Break. |
void |
breakOp(FillMode fillMode,
java.lang.String flat,
Indent plusIndent,
java.util.Optional<BreakTag> optionalTag)
Emit a generic
Break. |
void |
breakOp(Indent plusIndent)
Emit a
Break. |
void |
breakOp(java.lang.String flat)
|
void |
breakToFill()
Emit a filled
Break. |
void |
breakToFill(java.lang.String flat)
|
OpsBuilder.OpsOutput |
build()
Build a list of
Ops from the OpsBuilder. |
void |
checkClosed(int previous)
Checks that all open ops in the op stream have matching close ops.
|
void |
close()
Close the current level, by emitting a
CloseOp. |
int |
depth()
Returns the number of unclosed open ops in the input stream.
|
com.palantir.javaformat.java.FormatterDiagnostic |
diagnostic(java.lang.String message)
Create a
FormatterDiagnostic at the current position. |
void |
drain()
Output any remaining tokens from the input stream (e.g.
|
void |
forcedBreak()
Emit a forced
Break. |
void |
forcedBreak(Indent plusIndent)
Emit a forced
Break. |
Input |
getInput()
Get the
OpsBuilder's Input. |
void |
guessToken(java.lang.String token)
Emit an optional token iff it exists on the input.
|
void |
markForPartialFormat()
Make the boundary of a region that can be partially formatted.
|
boolean |
mostRecentTokenFollowedByNewline()
Return whether the last token emitted is followed by a newline.
|
void |
op(java.lang.String op)
Emit a single- or multi-character op by breaking it into single-character
Tokens. |
void |
open(Indent plusIndent)
Open a new level by emitting an
OpenOp. |
void |
open(Indent plusIndent,
BreakBehaviour breakBehaviour,
LastLevelBreakability breakabilityIfLastLevel)
Open a new level by emitting an
OpenOp. |
void |
open(OpenOp openOp) |
void |
open(java.lang.String debugName,
Indent plusIndent)
Open a new level by emitting an
OpenOp. |
java.util.Optional<java.lang.String> |
peekToken()
Return the text of the next
Input.Token, or absent if there is none. |
java.util.Optional<java.lang.String> |
peekToken(int skip)
Return the text of an upcoming
Input.Token, or absent if there is none. |
void |
space()
Emit a
NonBreakingSpace. |
void |
sync(int inputPosition)
Sync to position in the input.
|
void |
token(java.lang.String token,
Token.RealOrImaginary realOrImaginary,
Indent plusIndentCommentsBefore,
java.util.Optional<Indent> breakAndIndentTrailingComment) |
java.lang.String |
toString() |
public int actualSize(int position,
int length)
public java.lang.Integer actualStartColumn(int position)
position, including leading comments.public int depth()
public void checkClosed(int previous)
FormattingError - if any ops were unclosedpublic com.palantir.javaformat.java.FormatterDiagnostic diagnostic(java.lang.String message)
FormatterDiagnostic at the current position.public void sync(int inputPosition)
inputPosition - the 0-based input positionpublic void drain()
public void open(Indent plusIndent)
OpenOp.plusIndent - the extra indent for the new levelpublic void open(java.lang.String debugName,
Indent plusIndent)
OpenOp.debugName - a representative name for this lambdaplusIndent - the extra indent for the new levelpublic void open(Indent plusIndent, BreakBehaviour breakBehaviour, LastLevelBreakability breakabilityIfLastLevel)
OpenOp.plusIndent - the extra indent for the new levelbreakBehaviour - how to decide whether to break this level or notbreakabilityIfLastLevel - if last level, when to break this rather than parentpublic void open(OpenOp openOp)
public void close()
CloseOp.public java.util.Optional<java.lang.String> peekToken()
Input.Token, or absent if there is none.public boolean mostRecentTokenFollowedByNewline()
public java.util.Optional<java.lang.String> peekToken(int skip)
Input.Token, or absent if there is none.public void guessToken(java.lang.String token)
token - the optional tokenpublic void token(java.lang.String token,
Token.RealOrImaginary realOrImaginary,
Indent plusIndentCommentsBefore,
java.util.Optional<Indent> breakAndIndentTrailingComment)
public void op(java.lang.String op)
Tokens.op - the operator to emitpublic void space()
NonBreakingSpace.public void breakOp()
Break.public void breakOp(Indent plusIndent)
Break.plusIndent - extra indent if takenpublic void breakToFill()
Break.public void forcedBreak()
Break.public void forcedBreak(Indent plusIndent)
Break.plusIndent - extra indent if takenpublic void breakOp(java.lang.String flat)
flat - the Break when not brokenpublic void breakToFill(java.lang.String flat)
flat - the Break when not brokenpublic void breakOp(FillMode fillMode, java.lang.String flat, Indent plusIndent)
Break.public void breakOp(FillMode fillMode, java.lang.String flat, Indent plusIndent, java.util.Optional<BreakTag> optionalTag)
Break.public void markForPartialFormat()
public void blankLineWanted(OpsBuilder.BlankLineWanted wanted)
wanted - whether to force (true) or suppress false) the blank linepublic OpsBuilder.OpsOutput build()
Ops from the OpsBuilder.public java.lang.String toString()
toString in class java.lang.Object