@Value.Immutable public abstract class OpenOp extends HasUniqueId implements Op
OpenOp opens a level. It is an Op in the sequence of Ops generated by OpsBuilder.
When the sequence is turned into a Doc by DocBuilder, Input.Toks delimited by
OpenOp-CloseOp pairs turn into nested Levels.| Modifier and Type | Class and Description |
|---|---|
static class |
OpenOp.Builder |
static class |
OpenOp.Complexity |
| Constructor and Description |
|---|
OpenOp() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(DocBuilder builder)
Add an
Op to a DocBuilder. |
LastLevelBreakability |
breakabilityIfLastLevel()
If it's the last level of its parent, when to inline this level rather than break the parent.
|
BreakBehaviour |
breakBehaviour()
When this level doesn't fit on one line, controls whether this level is to be broken (its breaks taken) or
partially inlined onto the current line.
|
static OpenOp.Builder |
builder() |
abstract java.util.OptionalInt |
columnLimitBeforeLastBreak()
Custom max column limit that contents of this level before the last break may not exceed.
|
OpenOp.Complexity |
complexity()
A level is "simple" if it doesn't have multiple parameters (in the case of a method call), or multiple chained
method calls.
|
abstract java.util.Optional<java.lang.String> |
debugName() |
static Op |
make(Indent plusIndent)
Make an ordinary
OpenOp. |
PartialInlineability |
partialInlineability() |
abstract Indent |
plusIndent()
The extra indent inside this level.
|
idpublic abstract Indent plusIndent()
@Value.Default public BreakBehaviour breakBehaviour()
@Value.Default public LastLevelBreakability breakabilityIfLastLevel()
@Value.Default public PartialInlineability partialInlineability()
@Value.Default public OpenOp.Complexity complexity()
This is used to poison the ability to partially inline method arguments down the line if a parent level was too complicated, so that you can't end up with this:
method(arg1, arg2, arg3.foo().stream()
.filter(...)
.map(...));
or
log.info("Message", exception, SafeArg.of(
"foo", foo);
But you can still get this (see test B20128760):
Streamor this:itemIdsStream = stream(members).flatMap(m -> m.getFieldValues().entrySet().stream() .filter(...) .map(...));
method(anotherMethod(arg3.foo().stream()
.filter(...)
.map(...)));
or this:
method(anotherMethod(
...)); // long arguments
public abstract java.util.Optional<java.lang.String> debugName()
public abstract java.util.OptionalInt columnLimitBeforeLastBreak()
public void add(DocBuilder builder)
OpOp to a DocBuilder.add in interface Opbuilder - the DocBuilderpublic static OpenOp.Builder builder()
ImmutableOpenOp.Builder#Builder()