Skip to content

Commit

Permalink
Do not add space between constructor parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishiking committed Oct 20, 2019
1 parent e0fde06 commit 268912c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,11 @@ class Router(formatOps: FormatOps) {
} =>
val modification: Modification = leftOwner match {
case _: Mod => Space
case _: Init => Space
// Add a space between constructor annotations and their parameter lists
// see:
// https://github.com/scalameta/scalafmt/pull/1516
// https://github.com/scalameta/scalafmt/issues/1528
case init: Init if init.parent.forall(_.is[Mod.Annot]) => Space
case t: Term.Name
if style.spaces.afterTripleEquals &&
t.tokens.map(_.syntax) == Seq("===") =>
Expand Down
15 changes: 15 additions & 0 deletions scalafmt-tests/src/test/resources/spaces/Constructor.stat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
maxColumn = 100
<<< Space between annotation and ctor argument list
class A @Inject()(b: C)
>>>
class A @Inject() (b: C)

<<< Space between annotation and ctor argument list (with multiple argument list)
class MyComponent @Inject()(ctx: Context)(ws: WSClient)
>>>
class MyComponent @Inject() (ctx: Context)(ws: WSClient)

<<< Do not add add a space when a constructor has multiple argument lists #1528
new ShardEntity(rts) (onMessage)
>>>
new ShardEntity(rts)(onMessage)
4 changes: 0 additions & 4 deletions scalafmt-tests/src/test/resources/spaces/Hacking.stat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@ maxColumn = 40
function(a, b, c)
>>>
function( a, b, c )
<<< Space between annotation and ctor argument list
class A @Inject()(b: C)
>>>
class A @Inject() (b: C)

0 comments on commit 268912c

Please sign in to comment.