Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add space between constructor parameters #1535

Merged
merged 1 commit into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)