Implements best first search to find optimal formatting.
The decision made by Router.
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.
The left non-whitespace token.
The left non-whitespace token.
The whitespace tokens between left and right.
The decision made by Router.
Assigns splits to format tokens.
Debugging utility.
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.
Is this a space, no space, newline or 2 newlines?
How good is this output? Lower is better.
Does this add indentation?
How does this split affect other later splits?
Does this split overflow the column limit?
For debugging, to retrace from which case in Router this split originates.
A partial formatting solution up to splits.length number of tokens.
For convenience when experimenting with different hashing strategies.
(ugly) Utility to collect data about formatter.
(ugly) Utility to collect data about formatter.
Only used during development.
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.