Package

org.scalafmt

internal

Permalink

package internal

Visibility
  1. Public
  2. All

Type Members

  1. class BestFirstSearch extends AnyRef

    Permalink

    Implements best first search to find optimal formatting.

  2. case class Decision(formatToken: FormatToken, splits: Seq[Split]) extends Product with Serializable

    Permalink

    The decision made by Router.

    The decision made by Router.

    Used by Policy to enforce non-local formatting.

  3. sealed trait ExpiresOn extends AnyRef

    Permalink
  4. class FormatOps extends AnyRef

    Permalink

    Helper functions for generating splits/policies for a given tree.

  5. case class FormatToken(left: Token, right: Token, between: Vector[Whitespace]) extends Product with Serializable

    Permalink

    Two adjacent non-whitespace tokens.

    Two adjacent non-whitespace tokens.

    Consider a FormatToken as a node in a search graph and Split are the edges. The format tokens remain unchanged after formatting, while the splits are changed.

    left

    The left non-whitespace token.

    right

    The left non-whitespace token.

    between

    The whitespace tokens between left and right.

  6. class FormatWriter extends AnyRef

    Permalink

    Produces formatted output from sequence of splits.

  7. case class Indent[T <: Length](length: T, expire: Token, expiresAt: ExpiresOn) extends Product with Serializable

    Permalink

    One layer of indentation, created by an opening (, {, etc.

    One layer of indentation, created by an opening (, {, etc.

    Indent is parameterized by some Length to allow splits from Router to be memoized. If the length field was int, we would have to eagerly evaluate the indentation for state columns, which may be different depending on the formatting we choose.

    T

    Can be a known number Num (used in State) or unknown integer StateColumn (used in Split).

    length

    lengt of indentation, can be negative (in rare cases, with deeply nested terms with no newlines).

    expire

    Until which token does this indentation stay?

    expiresAt

    If Right, then expires when expire is curr.right, otherwise curr.left in BestFirstSearch.

  8. sealed trait Length extends AnyRef

    Permalink
  9. sealed abstract class Modification extends AnyRef

    Permalink
  10. trait NewlineT extends Modification

    Permalink
  11. case class Num(n: Int) extends Length with Product with Serializable

    Permalink
  12. case class OptimalToken(token: Token, killOnFail: Boolean = false) extends Product with Serializable

    Permalink
  13. case class Policy(f: PartialFunction[Decision, Decision], expire: Int, noDequeue: Boolean = false, isSingleLine: Boolean = false)(implicit line: Line) extends Product with Serializable

    Permalink

    The decision made by Router.

    The decision made by Router.

    Used by Policy to enforce non-local formatting.

    f

    is applied to every decision until expire

    expire

    The latest token offset.

  14. class PolicySummary extends AnyRef

    Permalink
  15. case class Provided(code: String) extends Modification with Product with Serializable

    Permalink
  16. class Router extends AnyRef

    Permalink

    Assigns splits to format tokens.

  17. case class Split(modification: Modification, cost: Int, ignoreIf: Boolean = false, indents: Vector[Indent[Length]] = ..., policy: Policy = NoPolicy, penalty: Boolean = false, optimalAt: Option[OptimalToken] = None)(implicit line: Line) extends Product with Serializable

    Permalink

    A Split is the whitespace between two non-whitespace tokens.

    A Split is the whitespace between two non-whitespace tokens.

    Consider a split to be an edge in a search graph and FormatToken are the nodes.

    modification

    Is this a space, no space, newline or 2 newlines?

    cost

    How good is this output? Lower is better.

    indents

    Does this add indentation?

    policy

    How does this split affect other later splits?

    penalty

    Does this split overflow the column limit?

    line

    For debugging, to retrace from which case in Router this split originates.

  18. final case class State(cost: Int, policy: PolicySummary, splits: Vector[Split], indentation: Int, pushes: Vector[Indent[Num]], column: Int, formatOff: Boolean) extends Ordered[State] with Product with Serializable

    Permalink

    A partial formatting solution up to splits.length number of tokens.

Value Members

  1. object Constants

    Permalink
  2. object Debug

    Permalink

    (ugly) Utility to collect data about formatter.

    (ugly) Utility to collect data about formatter.

    Only used during development.

  3. object FormatToken extends Serializable

    Permalink
  4. object Left extends ExpiresOn with Product with Serializable

    Permalink
  5. object Newline extends Modification with NewlineT with Product with Serializable

    Permalink
  6. object Newline2x extends Modification with NewlineT with Product with Serializable

    Permalink
  7. object Newline2xNoIndent extends Modification with NewlineT with Product with Serializable

    Permalink
  8. object NoIndentNewline extends Modification with NewlineT with Product with Serializable

    Permalink
  9. object NoSplit extends Modification with Product with Serializable

    Permalink
  10. object Policy extends Serializable

    Permalink
  11. object PolicySummary

    Permalink
  12. object Right extends ExpiresOn with Product with Serializable

    Permalink
  13. object Space extends Modification with Product with Serializable

    Permalink
  14. object State extends Serializable

    Permalink
  15. object StateColumn extends Length with Product with Serializable

    Permalink

    Indent up to the column of the left token.

    Indent up to the column of the left token.

    Example: the opening parenthesis below indents by StateColumn.

    foobar(arg1, arg2)

Ungrouped