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.
|
Constructor and Description |
---|
OpsBuilder(Input input,
Output output)
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
Op s. |
void |
blankLineWanted(OpsBuilder.BlankLineWanted wanted)
Force or suppress a blank line here in the output.
|
void |
breakOp()
Emit a
Doc.Break . |
void |
breakOp(Doc.FillMode fillMode,
java.lang.String flat,
Indent plusIndent)
Emit a generic
Doc.Break . |
void |
breakOp(Doc.FillMode fillMode,
java.lang.String flat,
Indent plusIndent,
com.google.common.base.Optional<Output.BreakTag> optionalTag)
Emit a generic
Doc.Break . |
void |
breakOp(Indent plusIndent)
Emit a
Doc.Break . |
void |
breakOp(java.lang.String flat)
|
void |
breakToFill()
Emit a filled
Doc.Break . |
void |
breakToFill(java.lang.String flat)
|
com.google.common.collect.ImmutableList<Op> |
build()
Build a list of
Op s 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.
|
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
Doc.Break . |
void |
forcedBreak(Indent plusIndent)
Emit a forced
Doc.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.
|
void |
op(java.lang.String op)
Emit a single- or multi-character op by breaking it into single-character
Doc.Token s. |
void |
open(Indent plusIndent)
Open a new level by emitting an
OpenOp . |
com.google.common.base.Optional<java.lang.String> |
peekToken()
Return the text of the next
Input.Token , or absent if there is none. |
com.google.common.base.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
Doc.Space . |
void |
sync(int inputPosition)
Sync to position in the input.
|
void |
token(java.lang.String token,
Doc.Token.RealOrImaginary realOrImaginary,
Indent plusIndentCommentsBefore,
com.google.common.base.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 FormatterDiagnostic diagnostic(java.lang.String message)
FormatterDiagnostic
at the current position.public final void sync(int inputPosition)
inputPosition
- the 0
-based input positionpublic final void drain()
public final void open(Indent plusIndent)
OpenOp
.plusIndent
- the extra indent for the new levelpublic final void close()
CloseOp
.public final com.google.common.base.Optional<java.lang.String> peekToken()
Input.Token
, or absent if there is none.public final com.google.common.base.Optional<java.lang.String> peekToken(int skip)
Input.Token
, or absent if there is none.public final void guessToken(java.lang.String token)
token
- the optional tokenpublic final void token(java.lang.String token, Doc.Token.RealOrImaginary realOrImaginary, Indent plusIndentCommentsBefore, com.google.common.base.Optional<Indent> breakAndIndentTrailingComment)
public final void op(java.lang.String op)
Doc.Token
s.op
- the operator to emitpublic final void space()
Doc.Space
.public final void breakOp()
Doc.Break
.public final void breakOp(Indent plusIndent)
Doc.Break
.plusIndent
- extra indent if takenpublic final void breakToFill()
Doc.Break
.public final void forcedBreak()
Doc.Break
.public final void forcedBreak(Indent plusIndent)
Doc.Break
.plusIndent
- extra indent if takenpublic final void breakOp(java.lang.String flat)
flat
- the Doc.Break
when not brokenpublic final void breakToFill(java.lang.String flat)
flat
- the Doc.Break
when not brokenpublic final void breakOp(Doc.FillMode fillMode, java.lang.String flat, Indent plusIndent)
Doc.Break
.fillMode
- the Doc.FillMode
flat
- the Doc.Break
when not brokenplusIndent
- extra indent if takenpublic final void breakOp(Doc.FillMode fillMode, java.lang.String flat, Indent plusIndent, com.google.common.base.Optional<Output.BreakTag> optionalTag)
Doc.Break
.fillMode
- the Doc.FillMode
flat
- the Doc.Break
when not brokenplusIndent
- extra indent if takenoptionalTag
- an optional tag for remembering whether the break was takenpublic void markForPartialFormat()
public final void blankLineWanted(OpsBuilder.BlankLineWanted wanted)
wanted
- whether to force (true
) or suppress false
) the blank linepublic final com.google.common.collect.ImmutableList<Op> build()
Op
s from the OpsBuilder
.Op
spublic final java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2015-2018 Google Inc.. All Rights Reserved.