Skip to content

Commit 3dc29f2

Browse files
Update scalafmt-core to 3.2.1 (#479)
* Update scalafmt-core to 3.2.1 * Reformat with scalafmt 3.2.1
1 parent b691cde commit 3dc29f2

File tree

33 files changed

+1268
-1225
lines changed

33 files changed

+1268
-1225
lines changed

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
runner.dialect = "scala213"
2-
version = "3.1.2"
2+
version = "3.2.1"
33
maxColumn = 120

Dsl/src/main/scala/com/thoughtworks/dsl/Dsl.scala

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@ import scala.util.{Failure, Success, Try}
1313
import scala.util.control.{NonFatal, TailCalls}
1414
import scala.util.control.TailCalls.TailRec
1515

16-
/** The domain-specific interpreter for `Keyword` in `Domain`,
17-
* which is a dependent type type class that registers an asynchronous callback function,
18-
* to handle the `Value` inside `Keyword`.
16+
/** The domain-specific interpreter for `Keyword` in `Domain`, which is a dependent type type class that registers an
17+
* asynchronous callback function, to handle the `Value` inside `Keyword`.
1918
*
20-
* @tparam Value The value held inside `Keyword`.
21-
* @author 杨博 (Yang Bo)
22-
* @example Creating a collaborative DSL in [[https://github.com/ThoughtWorksInc/Dsl.scala Dsl.scala]] is easy.
23-
* Only two steps are required:
19+
* @tparam Value
20+
* The value held inside `Keyword`.
21+
* @author
22+
* 杨博 (Yang Bo)
23+
* @example
24+
* Creating a collaborative DSL in [[https://github.com/ThoughtWorksInc/Dsl.scala Dsl.scala]] is easy. Only two steps
25+
* are required:
2426
*
25-
* - Defining their domain-specific [[com.thoughtworks.dsl.Dsl.Keyword Keyword]].
26-
* - Implementing this [[Dsl]] type class, which is an interpreter for an [[com.thoughtworks.dsl.Dsl.Keyword Keyword]].
27+
* - Defining their domain-specific [[com.thoughtworks.dsl.Dsl.Keyword Keyword]].
28+
* - Implementing this [[Dsl]] type class, which is an interpreter for an
29+
* [[com.thoughtworks.dsl.Dsl.Keyword Keyword]].
2730
*/
2831
@implicitNotFound("The keyword ${Keyword} is not supported inside a function that returns ${Domain}.")
2932
trait Dsl[-Keyword, Domain, +Value] {
@@ -236,8 +239,9 @@ object Dsl extends LowPriorityDsl0 {
236239

237240
/** An annotation to explicitly perform reset control operator on a code block.
238241
*
239-
* @note This annotation can be automatically added
240-
* if [[compilerplugins.ResetEverywhere ResetEverywhere]] compiler plug-in is enabled.
242+
* @note
243+
* This annotation can be automatically added if [[compilerplugins.ResetEverywhere ResetEverywhere]] compiler
244+
* plug-in is enabled.
241245
*/
242246
final class reset extends ResetAnnotation with StaticAnnotation with TypeConstraint
243247

@@ -247,9 +251,11 @@ object Dsl extends LowPriorityDsl0 {
247251
def apply[Keyword, Domain, Value](implicit typeClass: Dsl[Keyword, Domain, Value]): Dsl[Keyword, Domain, Value] =
248252
typeClass
249253

250-
/** @tparam Self the self type
251-
* @see [[https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern Curiously recurring template pattern]]
252-
* for the reason why we need the `Self` type parameter
254+
/** @tparam Self
255+
* the self type
256+
* @see
257+
* [[https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern Curiously recurring template pattern]] for
258+
* the reason why we need the `Self` type parameter
253259
*/
254260
trait Keyword[Self, Value] extends Any { this: Self =>
255261

@@ -287,8 +293,8 @@ object Dsl extends LowPriorityDsl0 {
287293

288294
/** The type class to support `try` ... `catch` ... `finally` expression for `OutputDomain`.
289295
*
290-
* !-notation is allowed by default for `? !! Throwable` and [[scala.concurrent.Future Future]] domains,
291-
* with the help of this type class.
296+
* !-notation is allowed by default for `? !! Throwable` and [[scala.concurrent.Future Future]] domains, with the
297+
* help of this type class.
292298
*/
293299
@implicitNotFound(
294300
"The `try` ... `catch` ... `finally` expression cannot contain !-notation inside a function that returns ${OuterDomain}."

compilerplugins-BangNotation/src/main/scala/com/thoughtworks/dsl/compilerplugins/BangNotation.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@ private object BangNotation {
1616

1717
}
1818

19-
/** The Scala compiler plug-in to convert ordinary Scala control flows to continuation-passing style,
20-
* which will then be interpreted by [[Dsl]].
19+
/** The Scala compiler plug-in to convert ordinary Scala control flows to continuation-passing style, which will then be
20+
* interpreted by [[Dsl]].
2121
*
22-
* = Usage =
22+
* =Usage=
2323
*
24-
* `<pre>
25-
* // In your build.sbt
26-
* addCompilerPlugin("com.thoughtworks.dsl" %% "compilerplugins-bangnotation" % "latest.release")
27-
* </pre>`
24+
* `<pre> // In your build.sbt addCompilerPlugin("com.thoughtworks.dsl" %% "compilerplugins-bangnotation" %
25+
* "latest.release") </pre>`
2826
*
29-
* @author 杨博 (Yang Bo)
27+
* @author
28+
* 杨博 (Yang Bo)
3029
*/
3130
final class BangNotation(override val global: Global) extends Plugin {
3231
import global._
@@ -65,7 +64,8 @@ final class BangNotation(override val global: Global) extends Plugin {
6564

6665
/** Avoid [[UnApply]] in `tree` to suppress compiler crash due to `unexpected UnApply xxx`.
6766
*
68-
* @see https://github.com/scala/bug/issues/8825
67+
* @see
68+
* https://github.com/scala/bug/issues/8825
6969
*/
7070
private def scalaBug8825Workaround(tree: Tree): Tree = {
7171
val transformer = new Transformer {

compilerplugins-BangNotation/src/test/scala/com/thoughtworks/dsl/compilerplugin/BangNotationSpec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import com.thoughtworks.dsl.Dsl.shift
44
import org.scalatest.freespec.AnyFreeSpec
55
import org.scalatest.matchers.should.Matchers
66

7-
/** @author 杨博 (Yang Bo)
7+
/** @author
8+
* 杨博 (Yang Bo)
89
*/
910
class BangNotationSpec extends AnyFreeSpec with Matchers {
1011

compilerplugins-ResetEverywhere/src/main/scala/com/thoughtworks/dsl/compilerplugins/ResetEverywhere.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ import scala.tools.nsc.{Global, Mode, Phase}
1212
*
1313
* Add the following setting in your `build.sbt` to enable this plug-in.
1414
*
15-
* `<pre>
16-
* // build.sbt
17-
* addCompilerPlugin("com.thoughtworks.dsl" %% "compilerplugins-reseteverywhere" % "latest.release")
18-
* </pre>`
15+
* `<pre> // build.sbt addCompilerPlugin("com.thoughtworks.dsl" %% "compilerplugins-reseteverywhere" %
16+
* "latest.release") </pre>`
1917
*
20-
* @note Once this [[ResetEverywhere]] plug-in is enabled,
21-
* the `@[[Dsl.reset reset]]` annotations are added to class fields, every methods and every functions automatically.
22-
* Some other macros or compiler plug-ins may conflict with those `@[[Dsl.reset reset]]` annotations.
18+
* @note
19+
* Once this [[ResetEverywhere]] plug-in is enabled, the `@[[Dsl.reset reset]]` annotations are added to class
20+
* fields, every methods and every functions automatically. Some other macros or compiler plug-ins may conflict with
21+
* those `@[[Dsl.reset reset]]` annotations.
2322
*
24-
* @author 杨博 (Yang Bo)
23+
* @author
24+
* 杨博 (Yang Bo)
2525
*/
2626
final class ResetEverywhere(override val global: Global) extends Plugin {
2727
import global._

comprehension/src/main/scala/com/thoughtworks/dsl/comprehension.scala

Lines changed: 98 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -21,99 +21,104 @@ private[dsl] sealed trait LowPriorityComprehension0 {
2121
* import com.thoughtworks.dsl.comprehension._
2222
* }}}
2323
*
24-
* @example `for` / `yield` expressions can be used on keywords.
25-
*
26-
* {{{
27-
* import com.thoughtworks.dsl.keywords._
28-
*
29-
* def cartesianProduct = for {
30-
* i <- Each(Array(1, 2, 3))
31-
* j <- Each(Vector(1, 10, 100, 1000))
32-
* } yield i * j
33-
* }}}
34-
*
35-
* The results of `for` / `yield` expressions are also keywords.
36-
*
37-
* {{{
38-
* cartesianProduct should be(a[Dsl.Keyword[_, _]])
39-
* }}}
40-
*
41-
* You can use !-notation extract the value from the produced keyword.
42-
*
43-
* {{{
44-
* def resultAsList = List(!cartesianProduct)
45-
* resultAsList should be(List(1, 10, 100, 1000, 2, 20, 200, 2000, 3, 30, 300, 3000))
46-
*
47-
* def resultAsSet: Set[Int] = !Return(!cartesianProduct)
48-
* resultAsSet should be(Set(1, 10, 100, 1000, 2, 20, 200, 2000, 3, 30, 300, 3000))
49-
* }}}
50-
*
51-
* Alternatively, [[comprehension.ComprehensionOps.to]] can be used to convert the result of a keyword to other types of values as well.
52-
*
53-
* {{{
54-
* cartesianProduct.to[List] should be(List(1, 10, 100, 1000, 2, 20, 200, 2000, 3, 30, 300, 3000))
55-
* }}}
56-
* @example This example implements the same feature as the example on Scaladoc of [[keywords.Yield]],
57-
* except this example use `for`-comprehension instead of !-notation.
58-
*
59-
* {{{
60-
* import com.thoughtworks.dsl.Dsl
61-
* import com.thoughtworks.dsl.keywords._
62-
* import com.thoughtworks.dsl.comprehension._
63-
*
64-
* def gccFlagBuilder(sourceFile: String, includes: String*) = {
65-
* for {
66-
* _ <- Yield("gcc")
67-
* _ <- Yield("-c")
68-
* _ <- Yield(sourceFile)
69-
* include <- Each(includes)
70-
* _ <- Yield("-I")
71-
* _ <- Yield(include)
72-
* r <- Continue
73-
* } yield r: String
74-
* }
75-
*
76-
* gccFlagBuilder("main.c", "lib1/include", "lib2/include").to[Stream] should be(Stream("gcc", "-c", "main.c", "-I", "lib1/include", "-I", "lib2/include"))
77-
* }}}
78-
*
79-
* Alternatively, you can use Scala native `yield` keyword to produce the last value.
80-
*
81-
* {{{
82-
* def gccFlagBuilder2(sourceFile: String, includes: String*) = {
83-
* for {
84-
* _ <- Yield("gcc")
85-
* _ <- Yield("-c")
86-
* _ <- Yield(sourceFile)
87-
* include <- Each(includes)
88-
* _ <- Yield("-I")
89-
* } yield include
90-
* }
91-
* gccFlagBuilder2("main.c", "lib1/include", "lib2/include").to[Stream] should be(Stream("gcc", "-c", "main.c", "-I", "lib1/include", "-I", "lib2/include"))
92-
* }}}
93-
*
94-
* You can also omit the explicit constructor of [[keywords.Yield]] with the help of implicit conversion [[keywords.Yield.implicitYield]].
95-
*
96-
* {{{
97-
* import com.thoughtworks.dsl.keywords.Yield.implicitYield
98-
*
99-
* def augmentString = ()
100-
* def wrapString = ()
101-
* }}}
102-
*
103-
* Note that [[scala.Predef.augmentString]] and [[scala.Predef.wrapString]] must be disabled in order to use `flatMap` for [[keywords.Yield]].
104-
*
105-
* {{{
106-
* def gccFlagBuilder3(sourceFile: String, includes: String*) = {
107-
* for {
108-
* _ <- "gcc"
109-
* _ <- "-c"
110-
* _ <- sourceFile
111-
* include <- Each(includes)
112-
* _ <- "-I"
113-
* } yield include
114-
* }
115-
* gccFlagBuilder3("main.c", "lib1/include", "lib2/include").to[Stream] should be(Stream("gcc", "-c", "main.c", "-I", "lib1/include", "-I", "lib2/include"))
116-
* }}}
24+
* @example
25+
* `for` / `yield` expressions can be used on keywords.
26+
*
27+
* {{{
28+
* import com.thoughtworks.dsl.keywords._
29+
*
30+
* def cartesianProduct = for {
31+
* i <- Each(Array(1, 2, 3))
32+
* j <- Each(Vector(1, 10, 100, 1000))
33+
* } yield i * j
34+
* }}}
35+
*
36+
* The results of `for` / `yield` expressions are also keywords.
37+
*
38+
* {{{
39+
* cartesianProduct should be(a[Dsl.Keyword[_, _]])
40+
* }}}
41+
*
42+
* You can use !-notation extract the value from the produced keyword.
43+
*
44+
* {{{
45+
* def resultAsList = List(!cartesianProduct)
46+
* resultAsList should be(List(1, 10, 100, 1000, 2, 20, 200, 2000, 3, 30, 300, 3000))
47+
*
48+
* def resultAsSet: Set[Int] = !Return(!cartesianProduct)
49+
* resultAsSet should be(Set(1, 10, 100, 1000, 2, 20, 200, 2000, 3, 30, 300, 3000))
50+
* }}}
51+
*
52+
* Alternatively, [[comprehension.ComprehensionOps.to]] can be used to convert the result of a keyword to other types
53+
* of values as well.
54+
*
55+
* {{{
56+
* cartesianProduct.to[List] should be(List(1, 10, 100, 1000, 2, 20, 200, 2000, 3, 30, 300, 3000))
57+
* }}}
58+
* @example
59+
* This example implements the same feature as the example on Scaladoc of [[keywords.Yield]], except this example use
60+
* `for`-comprehension instead of !-notation.
61+
*
62+
* {{{
63+
* import com.thoughtworks.dsl.Dsl
64+
* import com.thoughtworks.dsl.keywords._
65+
* import com.thoughtworks.dsl.comprehension._
66+
*
67+
* def gccFlagBuilder(sourceFile: String, includes: String*) = {
68+
* for {
69+
* _ <- Yield("gcc")
70+
* _ <- Yield("-c")
71+
* _ <- Yield(sourceFile)
72+
* include <- Each(includes)
73+
* _ <- Yield("-I")
74+
* _ <- Yield(include)
75+
* r <- Continue
76+
* } yield r: String
77+
* }
78+
*
79+
* gccFlagBuilder("main.c", "lib1/include", "lib2/include").to[Stream] should be(Stream("gcc", "-c", "main.c", "-I", "lib1/include", "-I", "lib2/include"))
80+
* }}}
81+
*
82+
* Alternatively, you can use Scala native `yield` keyword to produce the last value.
83+
*
84+
* {{{
85+
* def gccFlagBuilder2(sourceFile: String, includes: String*) = {
86+
* for {
87+
* _ <- Yield("gcc")
88+
* _ <- Yield("-c")
89+
* _ <- Yield(sourceFile)
90+
* include <- Each(includes)
91+
* _ <- Yield("-I")
92+
* } yield include
93+
* }
94+
* gccFlagBuilder2("main.c", "lib1/include", "lib2/include").to[Stream] should be(Stream("gcc", "-c", "main.c", "-I", "lib1/include", "-I", "lib2/include"))
95+
* }}}
96+
*
97+
* You can also omit the explicit constructor of [[keywords.Yield]] with the help of implicit conversion
98+
* [[keywords.Yield.implicitYield]].
99+
*
100+
* {{{
101+
* import com.thoughtworks.dsl.keywords.Yield.implicitYield
102+
*
103+
* def augmentString = ()
104+
* def wrapString = ()
105+
* }}}
106+
*
107+
* Note that [[scala.Predef.augmentString]] and [[scala.Predef.wrapString]] must be disabled in order to use `flatMap`
108+
* for [[keywords.Yield]].
109+
*
110+
* {{{
111+
* def gccFlagBuilder3(sourceFile: String, includes: String*) = {
112+
* for {
113+
* _ <- "gcc"
114+
* _ <- "-c"
115+
* _ <- sourceFile
116+
* include <- Each(includes)
117+
* _ <- "-I"
118+
* } yield include
119+
* }
120+
* gccFlagBuilder3("main.c", "lib1/include", "lib2/include").to[Stream] should be(Stream("gcc", "-c", "main.c", "-I", "lib1/include", "-I", "lib2/include"))
121+
* }}}
117122
*/
118123
object comprehension extends LowPriorityComprehension0 {
119124

domains-scalaz/.jvm/src/test/scala/com/thoughtworks/dsl/domains/scalazSpec.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import com.thoughtworks.dsl.keywords.{Monadic, Shift, Yield}
99
import org.scalatest.freespec.AnyFreeSpec
1010
import org.scalatest.matchers.should.Matchers
1111

12-
/** @author 杨博 (Yang Bo)
12+
/** @author
13+
* 杨博 (Yang Bo)
1314
*/
1415
class scalazSpec extends AnyFreeSpec with Matchers {
1516

0 commit comments

Comments
 (0)