package internal
- Alphabetic
- Public
- Protected
Type Members
- case class ActualIndent(length: Int, expireEnd: Int, expiresAt: ExpiresOn, reset: Boolean) extends Product with Serializable
- 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, meta: Meta) 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.
- meta
Extra information about the token
- class FormatTokens extends IndexedSeq[FormatToken]
- class FormatWriter extends AnyRef
Produces formatted output from sequence of splits.
- abstract class Indent extends AnyRef
- sealed abstract class Length extends AnyRef
- case class ModExt(mod: Modification, indents: Seq[Indent] = Seq.empty) extends Product with Serializable
- mod
Is this a space, no space, newline or 2 newlines?
- indents
Does this add indentation?
- sealed abstract class Modification extends AnyRef
- case class NewlineT(isDouble: Boolean = false, noIndent: Boolean = false, alt: Option[ModExt] = None) extends Modification with Product with Serializable
A split representing a newline.
A split representing a newline.
- isDouble
Insert a blank line?
- noIndent
Should no indentation follow? For example in commented out code.
- alt
Is it ok to replace this newline with a NoSplit or Space (with an optional additional set of indents) if the newline will indent beyond the current column? For example, used by select chains in Router.
- case class OptimalToken(token: Token, killOnFail: Boolean = false) extends Product with Serializable
- abstract class Policy extends AnyRef
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.PriorityQueueto enable usage under GraalVM. The native-image compiler is unable to work withscala.collection.mutable.PriorityQueuecurrently.- T
the values inside the queue
- case class Provided(ft: FormatToken) 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(state: State, reachedEOF: Boolean) extends Product with Serializable
- sealed abstract class Side extends AnyRef
- case class Split(modExt: ModExt, cost: Int, neededTags: Set[SplitTag] = Set.empty, activeTags: Set[SplitTag] = Set.empty, policy: Policy = NoPolicy, optimalAt: Option[OptimalToken] = None)(implicit fileLine: FileLine) 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.
NB: there's a historical inconsistency in how splits are sorted; when they are initially considered, cost is the primary factor (and hence, because of stable sort, earlier split with the same cost will take precedence). However, when a search state is added into the priority queue, preference is given to states with lower cost, further token and, unlike above, a LATER line defining the split.
A possible reason for the latter is to give those "secondary" splits a chance to move through the BestFirstSearch algorithm, as otherwise a sequence of primary splits might end up as the winning solution even if it exceeds the maxColumn margins, because a secondary split was deemed unlikely to win and moved to a backup priority queue.
- modExt
whitespace and indents
- cost
How good is this output? Lower is better.
- policy
How does this split affect other later splits?
- sealed abstract class SplitTag extends AnyRef
- final case class State(cost: Int, policy: PolicySummary, split: Split, depth: Int, prev: State, indentation: Int, pushes: Seq[ActualIndent], column: Int, allAltAreNL: Boolean, delayedPenalty: Int) extends Product with Serializable
A partial formatting solution up to splits.length number of tokens.
- sealed trait SyntacticGroup extends AnyRef
- class TokenRange extends AnyRef
- final class TokenRanges extends AnyVal
Value Members
- object BestFirstSearch
- object Constants
- object Decision extends Serializable
- object ExpiresOn
- object FormatOps
- object FormatToken extends Serializable
- object FormatTokens
- object FormatWriter
- object Indent
- object Length
- object ModExt extends Serializable
- object Newline extends NewlineT
- object Newline2x extends NewlineT
- object Newline2xNoIndent extends NewlineT
- object NoIndentNewline extends NewlineT
- case object NoSplit extends Modification with Product with Serializable
- object Policy
- object PolicySummary
- object Side
- object Space extends Modification
- object Split extends Serializable
- object SplitTag
- object State extends Serializable
- object SyntacticGroup
- object SyntacticGroupOps
- object TokenRange
- object TokenRanges
- object TreeSyntacticGroup