Skip to content

Commit 8229ff9

Browse files
scala-stewardkitbellew
authored andcommitted
Reformat with scalafmt 3.0.0
1 parent 065819b commit 8229ff9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+556
-547
lines changed

readme/src/main/scala/org/scalafmt/readme/Readme.scala

+9-11
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ object Readme {
4343

4444
/** repl session, inspired by tut.
4545
*
46-
* Example: code="1 + 1" returns
47-
* "scala> 1 + 1
48-
* res0: Int = 2"
46+
* Example: code="1 + 1" returns "scala> 1 + 1 res0: Int = 2"
4947
*/
5048
def repl(code: String) = {
5149
import scala.meta._
@@ -232,16 +230,16 @@ object Readme {
232230
)
233231
)
234232

235-
/** This looks way too hacky. But can't seem to find a typeclass
236-
* that ought to "encode" the ``ModKey`` enum.
233+
/** This looks way too hacky. But can't seem to find a typeclass that ought to
234+
* "encode" the ``ModKey`` enum.
237235
*
238-
* Additionally, a Vector of Strings is simply concatenated, hence
239-
* the extra .mkString.
236+
* Additionally, a Vector of Strings is simply concatenated, hence the extra
237+
* .mkString.
240238
* {{{
241-
* [error] found : Vector[org.scalafmt.config.SortSettings.ModKey]
242-
* [error] required: scalatags.Text.Modifier
243-
* [error] (which expands to) scalatags.generic.Modifier[scalatags.text.Builder]
244-
* [error] @code{rewrite.sortModifiers.order} = @rewriteSortModifiers.rewrite.sortModifiers.order
239+
* [error] found : Vector[org.scalafmt.config.SortSettings.ModKey]
240+
* [error] required: scalatags.Text.Modifier
241+
* [error] (which expands to) scalatags.generic.Modifier[scalatags.text.Builder]
242+
* [error] @code{rewrite.sortModifiers.order} = @rewriteSortModifiers.rewrite.sortModifiers.order
245243
* }}}
246244
*/
247245
val rewriteSortModifiersDefaultString =

scalafmt-cli/src/main/scala/org/scalafmt/cli/CliOptions.scala

+19-17
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ object CliOptions {
1717

1818
/** Tries to read configuration from
1919
*
20-
* 1. .scalafmt.conf in root dir of current git repo
21-
* IF the following setting is enabled: project.git = true
22-
* 2. .scalafmt.conf from init.common.workingDirectory
20+
* 1. .scalafmt.conf in root dir of current git repo IF the following
21+
* setting is enabled: project.git = true 2. .scalafmt.conf from
22+
* init.common.workingDirectory
2323
*
2424
* I am happy to add alternative fallback methods for other VCS.
2525
*
2626
* WARNING. Throws an exception if the .scalafmt.conf error exists but
27-
* contains an error. Why? Because this method is only supposed to be
28-
* called directly from main.
27+
* contains an error. Why? Because this method is only supposed to be called
28+
* directly from main.
2929
*/
3030
def auto(parsed: CliOptions): CliOptions = {
3131
val auxOut =
@@ -109,8 +109,8 @@ case class CliOptions(
109109

110110
val writeMode: WriteMode = writeModeOpt.getOrElse(WriteMode.Override)
111111

112-
/** Create a temporary file that contains configuration string specified by `--config-str`.
113-
* This temporary file will be passed to `scalafmt-dynamic`.
112+
/** Create a temporary file that contains configuration string specified by
113+
* `--config-str`. This temporary file will be passed to `scalafmt-dynamic`.
114114
* See https://github.com/scalameta/scalafmt/pull/1367#issuecomment-464744077
115115
*/
116116
private[this] val tempConfigPath: Option[Path] = configStr.map { s =>
@@ -119,12 +119,13 @@ case class CliOptions(
119119
file
120120
}
121121

122-
/** - If --config-str is specified (and tempConfigPath is defined),
123-
* this returns the path to a temporary file.
124-
* - If both tempConfigPath and config are None,
125-
* this return the path to `.scalafmt.conf` on the working directory.
122+
/** - If --config-str is specified (and tempConfigPath is defined), this
123+
* returns the path to a temporary file.
124+
* - If both tempConfigPath and config are None, this return the path to
125+
* `.scalafmt.conf` on the working directory.
126126
*
127-
* @return A path to a configuration file
127+
* @return
128+
* A path to a configuration file
128129
*/
129130
def configPath: Path =
130131
configPathOpt.get
@@ -138,10 +139,12 @@ case class CliOptions(
138139
.orElse(gitOps.rootDir.flatMap(tryGetConfigFile))
139140

140141
/** Parse the scalafmt configuration and try to encode it to `ScalafmtConfig`.
141-
* If `--config-str` is specified, this will parse the configuration string specified by `--config-str`.
142-
* Otherwise, a contents of configuration file specified by `configPath` will be parsed.
142+
* If `--config-str` is specified, this will parse the configuration string
143+
* specified by `--config-str`. Otherwise, a contents of configuration file
144+
* specified by `configPath` will be parsed.
143145
*
144-
* If `--config-str` is not specified and configuration file is missing, this will return the default configuration
146+
* If `--config-str` is not specified and configuration file is missing, this
147+
* will return the default configuration
145148
*/
146149
def scalafmtConfig: Configured[ScalafmtConfig] =
147150
hoconOpt.fold(Configured.ok(ScalafmtConfig.default))(Config.fromConf(_))
@@ -215,8 +218,7 @@ case class CliOptions(
215218
.flatMap(x => Try(Codec(x)).toOption)
216219
.getOrElse(ScalafmtConfig.default.encoding)
217220

218-
/** Returns None if .scalafmt.conf is not found or
219-
* version setting is missing.
221+
/** Returns None if .scalafmt.conf is not found or version setting is missing.
220222
*/
221223
private[cli] def getVersionIfDifferent: Option[String] =
222224
getHoconValueOpt[String]("version").filter(_ != Versions.version)

scalafmt-cli/src/main/scala/org/scalafmt/cli/FileFetchMode.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ sealed trait FileFetchMode
88

99
object FileFetchMode {
1010

11-
/** The read instance is practically is not exhaustive due to the RecursiveSearch and GitFiles are the fallback used in the absence of
12-
* other options
11+
/** The read instance is practically is not exhaustive due to the
12+
* RecursiveSearch and GitFiles are the fallback used in the absence of other
13+
* options
1314
*/
1415
implicit val read: Read[FileFetchMode] = Read.reads {
1516
case "diff" => DiffFiles("master")

scalafmt-cli/src/main/scala/org/scalafmt/cli/TermDisplay.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,8 @@ object Terminal {
5555

5656
/** Clear the current line
5757
*
58-
* n=0: clear from cursor to end of line
59-
* n=1: clear from cursor to start of line
60-
* n=2: clear entire line
58+
* n=0: clear from cursor to end of line n=1: clear from cursor to start of
59+
* line n=2: clear entire line
6160
*/
6261
def clearLine(n: Int): Unit = control(n, 'K')
6362
}

scalafmt-cli/src/main/scala/org/scalafmt/cli/WriteMode.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package org.scalafmt.cli
22

33
/** Determines the mode in which Scalafmt will behave
44
*
5-
* Override = Replace the file with its formatted form
6-
* Stdout = Print the formatted file to Stdout (leaving the original file untouched)
5+
* Override = Replace the file with its formatted form Stdout = Print the
6+
* formatted file to Stdout (leaving the original file untouched)
77
*/
88
sealed trait WriteMode
99

scalafmt-core/jvm/src/main/scala/org/scalafmt/internal/PriorityQueue.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ package org.scalafmt.internal
66
* native-image compiler is unable to work with
77
* `scala.collection.mutable.PriorityQueue` currently.
88
*
9-
* @tparam T the values inside the queue
9+
* @tparam T
10+
* the values inside the queue
1011
*/
1112
class PriorityQueue[T](implicit ord: Ordering[T]) {
1213
private[this] val q = new java.util.PriorityQueue[T](11, ord.reversed())

scalafmt-core/shared/src/main/scala/org/scalafmt/Scalafmt.scala

+18-12
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ import org.scalafmt.internal.FormatWriter
2222
import org.scalafmt.rewrite.Rewrite
2323
import org.scalafmt.util.{FileOps, MarkdownFile, MarkdownPart}
2424

25-
/** WARNING. This API is discouraged when integrating with Scalafmt from a build tool
26-
* or editor plugin. It is recommended to use the `scalafmt-dynamic` module instead.
25+
/** WARNING. This API is discouraged when integrating with Scalafmt from a build
26+
* tool or editor plugin. It is recommended to use the `scalafmt-dynamic`
27+
* module instead.
2728
*/
2829
object Scalafmt {
2930

@@ -34,16 +35,20 @@ object Scalafmt {
3435
// XXX: don't modify signature, scalafmt-dynamic expects it via reflection
3536
/** Format Scala code using scalafmt.
3637
*
37-
* WARNING. This API is discouraged when integrating with Scalafmt from a build tool
38-
* or editor plugin. It is recommended to use the `scalafmt-dynamic` module instead.
38+
* WARNING. This API is discouraged when integrating with Scalafmt from a
39+
* build tool or editor plugin. It is recommended to use the
40+
* `scalafmt-dynamic` module instead.
3941
*
40-
* @param code Code string to format.
41-
* @param style Configuration for formatting output.
42-
* @param range EXPERIMENTAL. Format a subset of lines.
43-
* @return [[Formatted.Success]] if successful,
44-
* [[Formatted.Failure]] otherwise. If you are OK with throwing
45-
* exceptions, use [[Formatted.Success.get]] to get back a
46-
* string.
42+
* @param code
43+
* Code string to format.
44+
* @param style
45+
* Configuration for formatting output.
46+
* @param range
47+
* EXPERIMENTAL. Format a subset of lines.
48+
* @return
49+
* [[Formatted.Success]] if successful, [[Formatted.Failure]] otherwise. If
50+
* you are OK with throwing exceptions, use [[Formatted.Success.get]] to
51+
* get back a string.
4752
*/
4853
def format(
4954
code: String,
@@ -177,7 +182,8 @@ object Scalafmt {
177182

178183
/** Utility method to change dialect on ScalafmtConfig.
179184
*
180-
* Binary compatibility is guaranteed between releases, unlike with ScalafmtConfig.copy.
185+
* Binary compatibility is guaranteed between releases, unlike with
186+
* ScalafmtConfig.copy.
181187
*/
182188
def configWithDialect(
183189
config: ScalafmtConfig,

scalafmt-core/shared/src/main/scala/org/scalafmt/config/Align.scala

+31-35
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,55 @@ import metaconfig.annotation.ExtraName
55
import metaconfig.generic.Surface
66

77
/** @param openParenCallSite
8-
* If true AND bin-packing is true, then call-site
9-
* arguments won't be aligned by the opening
10-
* parenthesis. For example, this output
11-
* will be disallowed
8+
* If true AND bin-packing is true, then call-site arguments won't be aligned
9+
* by the opening parenthesis. For example, this output will be disallowed
1210
*
13-
* function(a,
14-
* b,
15-
* c)
16-
* @param openParenDefnSite Same as [[openParenCallSite]], except definition site.
17-
* @param tokens The tokens to vertically align by. The "owner" is the
18-
* scala.meta.Tree.getClass.getName of the deepest tree node
19-
* that "owns" the token to align by.
11+
* function(a, b, c)
12+
* @param openParenDefnSite
13+
* Same as [[openParenCallSite]], except definition site.
14+
* @param tokens
15+
* The tokens to vertically align by. The "owner" is the
16+
* scala.meta.Tree.getClass.getName of the deepest tree node that "owns" the
17+
* token to align by.
2018
*
21-
* Examples:
19+
* Examples:
2220
*
23-
* align.tokens = ["="] // align = owned by any tree node (not recommended)
21+
* align.tokens = ["="] // align = owned by any tree node (not recommended)
2422
*
25-
* align.tokens = [
26-
* { code = "=", owner = "Param" } // align = when owned by parameter tree nodes
27-
* ]
23+
* align.tokens = [ { code = "=", owner = "Param" } // align = when owned by
24+
* parameter tree nodes ]
2825
*
29-
* Pro tip. if you use for example
26+
* Pro tip. if you use for example
3027
*
31-
* preset = defaultWithAlign
28+
* preset = defaultWithAlign
3229
*
33-
* and want to add one extra token (for example "|>") to align by, write
30+
* and want to add one extra token (for example "|>") to align by, write
3431
*
35-
* align.tokens."+" = [ "|> ]
32+
* align.tokens."+" = [ "|> ]
3633
*
37-
* NOTE. Adding more alignment tokens may potentially decrease the
38-
* vertical alignment in formatted output. Customize at your own
39-
* risk, I recommend you try and stick to the default settings.
40-
* @param arrowEnumeratorGenerator If true, aligns by `<-` in for comprehensions.
34+
* NOTE. Adding more alignment tokens may potentially decrease the vertical
35+
* alignment in formatted output. Customize at your own risk, I recommend you
36+
* try and stick to the default settings.
37+
* @param arrowEnumeratorGenerator
38+
* If true, aligns by `<-` in for comprehensions.
4139
* @param openParenCtrlSite
42-
* If true, aligns by ( in if/while/for. If false,
43-
* indents by continuation indent at call site.
40+
* If true, aligns by ( in if/while/for. If false, indents by continuation
41+
* indent at call site.
4442
* @param tokenCategory
45-
* Customize which token kinds can align together. By default, only tokens with
46-
* the same `Token.productPrefix` align. To for example align = and <-,
47-
* set the values to:
48-
* Map("Equals" -> "Assign", "LeftArrow" -> "Assign")
43+
* Customize which token kinds can align together. By default, only tokens
44+
* with the same `Token.productPrefix` align. To for example align = and <-,
45+
* set the values to: Map("Equals" -> "Assign", "LeftArrow" -> "Assign")
4946
* Note. Requires mixedTokens to be true.
5047
* @param treeCategory
5148
* Customize which tree kinds can align together. By default, only trees with
5249
* the same `Tree.productPrefix` align. To for example align Defn.Val and
53-
* Defn.Var, set the values to:
54-
* Map("Defn.Var" -> "Assign", "Defn.Val" -> "Assign")
55-
* Note. Requires mixedOwners to be true.
50+
* Defn.Var, set the values to: Map("Defn.Var" -> "Assign", "Defn.Val" ->
51+
* "Assign") Note. Requires mixedOwners to be true.
5652
* @param stripMargin
5753
* If set, indent lines with a strip-margin character in a multiline string
5854
* constant relative to the opening quotes (or the strip-margin character if
59-
* present) on the first line; otherwise, indent relative to the beginning
60-
* of the first line, as usual.
55+
* present) on the first line; otherwise, indent relative to the beginning of
56+
* the first line, as usual.
6157
*/
6258
case class Align(
6359
allowOverflow: Boolean = false,

scalafmt-core/shared/src/main/scala/org/scalafmt/config/AlignToken.scala

+8-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ import metaconfig.generic.Surface
99

1010
/** Configuration option for aligning tokens.
1111
*
12-
* @param code string literal value of the token to align by.
13-
* @param owners array of owner specs.
12+
* @param code
13+
* string literal value of the token to align by.
14+
* @param owners
15+
* array of owner specs.
1416
*/
1517
case class AlignToken(
1618
code: String,
@@ -34,8 +36,10 @@ object AlignToken {
3436
private def pattern(value: String): jurPattern =
3537
value.r.pattern
3638

37-
/** @param regex regexp for class name of scala.meta.Tree "owner".
38-
* @param parent optional regexp for class name of owner's parent.
39+
/** @param regex
40+
* regexp for class name of scala.meta.Tree "owner".
41+
* @param parent
42+
* optional regexp for class name of owner's parent.
3943
*/
4044
case class Owner(
4145
regex: Option[String] = None,

scalafmt-core/shared/src/main/scala/org/scalafmt/config/BinPack.scala

+22-21
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@ package org.scalafmt.config
22

33
import metaconfig._
44

5-
/** @param unsafeCallSite DO NOT USE! This option is buggy for complicated expressions.
6-
* The only reason this option exists is to support
7-
* the [[literalArgumentLists]] option, which enables callSite
8-
* only for simple expressions.
5+
/** @param unsafeCallSite
6+
* DO NOT USE! This option is buggy for complicated expressions. The only
7+
* reason this option exists is to support the [[literalArgumentLists]]
8+
* option, which enables callSite only for simple expressions.
99
*
10-
* If true, will fit as many arguments on each line,
11-
* only breaking at commas. If false, a function
12-
* call's arguments will either be all on the same
13-
* line or will have one line each.
14-
* @param unsafeDefnSite Same as [[unsafeCallSite]], except for definition site.
10+
* If true, will fit as many arguments on each line, only breaking at commas.
11+
* If false, a function call's arguments will either be all on the same line or
12+
* will have one line each.
13+
* @param unsafeDefnSite
14+
* Same as [[unsafeCallSite]], except for definition site.
1515
* @param literalArgumentLists
16-
* If true, automatically sets the style to bin-pack for argument lists
17-
* that only consist of literals.
18-
* @param literalsMinArgCount Argument list must be longer than this setting
19-
* to be eligible for [[literalArgumentLists]].
20-
* @param literalsInclude Regexes for literal type names. For example, "Int"
21-
* or "Byte".
22-
* @param literalsExclude Regexes for literal to exclude from [[literalArgumentLists]].
23-
* @param parentConstructors Parent constructors are C and D in
24-
* "class A extends B with C and D". If "Always",
25-
* scalafmt will fit as many parent constructors
26-
* on a single line. If "Never", each parent
27-
* constructor gets its own line.
16+
* If true, automatically sets the style to bin-pack for argument lists that
17+
* only consist of literals.
18+
* @param literalsMinArgCount
19+
* Argument list must be longer than this setting to be eligible for
20+
* [[literalArgumentLists]].
21+
* @param literalsInclude
22+
* Regexes for literal type names. For example, "Int" or "Byte".
23+
* @param literalsExclude
24+
* Regexes for literal to exclude from [[literalArgumentLists]].
25+
* @param parentConstructors
26+
* Parent constructors are C and D in "class A extends B with C and D". If
27+
* "Always", scalafmt will fit as many parent constructors on a single line.
28+
* If "Never", each parent constructor gets its own line.
2829
*/
2930
case class BinPack(
3031
unsafeCallSite: BinPack.Unsafe = BinPack.Unsafe.Never,

0 commit comments

Comments
 (0)