枚举类 PartialInlineability

java.lang.Object
java.lang.Enum<PartialInlineability>
com.palantir.javaformat.PartialInlineability
所有已实现的接口:
Serializable, Comparable<PartialInlineability>, Constable

public enum PartialInlineability extends Enum<PartialInlineability>
What are the conditions for a level to be partially inlineable. Partial inlining refers to the behaviour of 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.

  • 枚举常量详细资料

    • ALWAYS_PARTIALLY_INLINEABLE

      public static final PartialInlineability ALWAYS_PARTIALLY_INLINEABLE
      The level may always be partially inlined, regardless of how much space is left on the current line.

      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.

    • IF_FIRST_LEVEL_FITS

      public static final PartialInlineability IF_FIRST_LEVEL_FITS
      Partially inlineable if the first inner level of this level fits on the current line.

      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<com.sun.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.
  • 方法详细资料

    • values

      public static PartialInlineability[] values()
      返回包含该枚举类的常量的数组, 顺序与声明这些常量的顺序相同
      返回:
      包含该枚举类的常量的数组,顺序与声明这些常量的顺序相同
    • valueOf

      public static PartialInlineability valueOf(String name)
      返回带有指定名称的该类的枚举常量。 字符串必须与用于声明该类的枚举常量的 标识符完全匹配。(不允许有多余 的空格字符。)
      参数:
      name - 要返回的枚举常量的名称。
      返回:
      返回带有指定名称的枚举常量
      抛出:
      IllegalArgumentException - 如果该枚举类没有带有指定名称的常量
      NullPointerException - 如果参数为空值