public enum PartialInlineability extends java.lang.Enum<PartialInlineability>
BreakBehaviours.breakOnlyIfInnerLevelsThenFitOnOneLine(boolean) where a level is too large to fit on the current line,
but a prefix thereof is partially inlined onto the current line.
Specifically, when inlining a level with the above behaviour, the partial inlineability of its first child level (and that level's first child, recursively) is queried in order to determine if we need to ensure there's enough room for some additional prefix of that level.
The reason for this is to prevent degenerate formattings like
Object foo = someSuperLongMethod(some |
.fully |
.qualified |
.ClassName |
.doSomething()); |
and instead prefer breaking earlier to keep the prefix on the same line, like:
Object foo = someSuperLongMethod( |
some.fully.qualified.ClassName|
.doSomething()); |
Note that this works as a mandatory access control. Namely, if it's allowed to partially inline a level, what are the additional conditions that have to be met in order for the inlining to go ahead.
| Enum Constant and Description |
|---|
ALWAYS_PARTIALLY_INLINEABLE
The level may always be partially inlined, regardless of how much space is left on the current line.
|
IF_FIRST_LEVEL_FITS
Partially inlineable if the first inner level of this level fits on the current line.
|
| Modifier and Type | Method and Description |
|---|---|
static PartialInlineability |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static PartialInlineability[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final PartialInlineability ALWAYS_PARTIALLY_INLINEABLE
This is usually only appropriate for levels that start with a direct Break, as opposed to a Break
that's nested inside some other levels.
public static final PartialInlineability IF_FIRST_LEVEL_FITS
This assumes that the next Doc after that starts with a Break (see StartsWithBreakVisitor) and
makes sense in contexts like JavaInputAstVisitor.visitDotWithPrefix(java.util.List<org.openjdk.source.tree.ExpressionTree>, boolean, java.util.Collection<java.lang.Integer>, com.palantir.javaformat.doc.FillMode) where we want to treat first doc (the
longest prefix) as a single entity to be fit onto the same line.
public static PartialInlineability[] values()
for (PartialInlineability c : PartialInlineability.values()) System.out.println(c);
public static PartialInlineability valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is null