Package

org.scalafmt

internal

Permalink

package internal

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. internal
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
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 TreeOps

    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. 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 or unknown integer StateColumn.

    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.

  7. sealed trait Length extends AnyRef

    Permalink
  8. sealed abstract class Modification extends AnyRef

    Permalink
  9. trait NewlineT extends Modification

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

    Permalink
  11. case class Policy(f: PartialFunction[Decision, Decision], expire: Int, noDequeue: 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.

  12. class PolicySummary extends AnyRef

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

    Permalink
  14. class Router extends AnyRef

    Permalink

    Assigns splits to format tokens.

  15. case class Split(modification: Modification, cost: Int, ignoreIf: Boolean = false, indents: Vector[Indent[Length]] = Vector.empty[Indent[Length]], policy: Policy = NoPolicy, penalty: Boolean = false, optimalAt: Option[Token] = None)(implicit line: Line) extends TokenOps with 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.

  16. 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 TokenOps with Product with Serializable

    Permalink

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

  17. type TokenHash = Long

    Permalink

    For convenience when experimenting with different hashing strategies.

  18. trait TokenOps extends AnyRef

    Permalink

    Stateless helper functions on scala.meta.Token.

  19. trait TreeOps extends TokenOps

    Permalink

    Stateless helper functions on scala.meta.Tree.

Value Members

  1. object BestFirstSearch

    Permalink
  2. object Constants

    Permalink
  3. object Debug

    Permalink

    (ugly) Utility to collect data about formatter.

    (ugly) Utility to collect data about formatter.

    Only used during development.

  4. object FormatToken extends Serializable

    Permalink
  5. object Left extends ExpiresOn with Product with Serializable

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

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

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

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

    Permalink
  10. val NoPolicy: Policy

    Permalink
  11. object NoSplit extends Modification with Product with Serializable

    Permalink
  12. object Policy extends Serializable

    Permalink
  13. object PolicySummary

    Permalink
  14. object Right extends ExpiresOn with Product with Serializable

    Permalink
  15. object ScalaFmtLogger

    Permalink

    Debugging utility.

  16. object Space extends Modification with Product with Serializable

    Permalink
  17. object State extends Serializable

    Permalink
  18. 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)

  19. object TokenOps extends TokenOps

    Permalink
  20. def childOf(tok: Token, tree: Tree, owners: Map[TokenHash, Tree]): Boolean

    Permalink
  21. final def childOf(child: Tree, tree: Tree): Boolean

    Permalink
    Annotations
    @tailrec()
  22. def hash(token: Token): TokenHash

    Permalink

    Custom hash code for token.

    Custom hash code for token.

    The default hashCode is slow because it prevents conflicts between tokens from different source files. We only care about getting a unique identifier for the token inside this source file.

    The hash code works like this this: Top 8 bits go to privateTag, a unique identifier for the tokens class. Next 28 bits go to the tokens **start** offset byte. Final 28 bits go to the tokens **end** offset byte.

    The only chance for collision is if two empty length tokens with the same type lie next to each other. @xeno-by said this should not happen.

    Annotations
    @inline()
  23. final def parents(tree: Tree, accum: Seq[Tree] = Seq.empty[Tree]): Seq[Tree]

    Permalink
    Annotations
    @tailrec()

Inherited from AnyRef

Inherited from Any

Ungrouped