package internal
- Alphabetic
- Public
- Protected
Type Members
- class BestFirstSearch extends AnyRef
Implements best first search to find optimal formatting.
- case class Decision(formatToken: FormatToken, splits: Seq[Split]) extends Product with Serializable
The decision made by Router.
- sealed abstract class ExpiresOn extends AnyRef
- class FormatOps extends AnyRef
Helper functions for generating splits/policies for a given tree.
- case class FormatToken(left: Token, right: Token, between: Vector[Token]) extends Product with Serializable
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 right non-whitespace token.
- between
The whitespace tokens between left and right.
- class FormatWriter extends AnyRef
Produces formatted output from sequence of splits.
- case class Indent[T <: Length](length: T, expire: Token, expiresAt: ExpiresOn) extends Product with Serializable
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.
- sealed abstract class Length extends AnyRef
- sealed abstract class Modification extends AnyRef
- case class NewlineT(isDouble: Boolean = false, noIndent: Boolean = false, acceptSpace: Boolean = false, acceptNoSplit: Boolean = false) extends Modification with Product with Serializable
A split representing a newline.
- case class OptimalToken(token: Token, killOnFail: Boolean = false) extends Product with Serializable
- case class Policy(f: PartialFunction[Decision, Decision], expire: Int, noDequeue: Boolean = false, isSingleLine: Boolean = false)(implicit line: Line) extends Product with Serializable
The decision made by Router.
- class PolicySummary extends AnyRef
- class PriorityQueue[T] extends AnyRef
Minimal implementation of the PriorityQueue's functions needed.
Minimal implementation of the PriorityQueue's functions needed.
We use java.util.PriorityQueue to enable usage under GraalVM. The native-image compiler is unable to work with scala.collection.mutable.PriorityQueue currently.
- T
the values inside the queue
- case class Provided(code: String) extends Modification with Product with Serializable
- class Router extends AnyRef
Assigns splits to format tokens.
Assigns splits to format tokens.
NOTE(olafurpg). The pattern match in this file has gotten out of hand. It's difficult even for myself to keep track of what's going on in some cases, especially around applications and lambdas. I'm hoping to sunset this file along with BestFirstSearch in favor of https://github.com/scalameta/scalafmt/issues/917
- case class SearchResult(splits: Vector[Split], reachedEOF: Boolean) extends Product with Serializable
- sealed abstract class Side extends AnyRef
- 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[OptimalToken] = None)(implicit line: Line) extends Product with Serializable
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.
- 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
A partial formatting solution up to splits.length number of tokens.
- sealed trait SyntacticGroup extends AnyRef
Value Members
- object Constants
- object ExpiresOn
- object FormatToken extends Serializable
- object FormatWriter
- object Length
- object Newline extends NewlineT
- object Newline2x extends NewlineT
- object Newline2xNoIndent extends NewlineT
- object NoIndentNewline extends NewlineT
- object NoSplit extends Modification with Product with Serializable
- object Policy extends Serializable
- object PolicySummary
- object Side
- object Space extends Modification
- object State extends Serializable
- object SyntacticGroup
- object SyntacticGroupOps
- object TreeSyntacticGroup