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

Another fix for verticalMultilineAtDefinitionSite #711

Merged
merged 6 commits into from
Feb 3, 2017
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
3 changes: 2 additions & 1 deletion core/src/main/scala/org/scalafmt/internal/Router.scala
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ class Router(formatOps: FormatOps) {
val oneLinePerArg = OneArgOneLineSplit(open).f
val paramGroupSplitter: PartialFunction[Decision, Decision] = {
// Indent seperators `)(` by `indentSep`
case Decision(t @ FormatToken(_, rp @ RightParen(), _), _) =>
case Decision(t @ FormatToken(_, rp @ RightParen(), _), _)
if owners(rp) == leftOwner =>
Decision(t,
Seq(
Split(Newline, 0)
Expand Down
45 changes: 45 additions & 0 deletions core/src/test/resources/test/VerticalMultiline.stat
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,51 @@ def format_![T <: Tree](
ev2: EC
): String

<<< should work with comments
def format_![T <: Tree](
code: String, // The code!
code2: String
)(implicit ev: Parse[T], // The Parser!!! Some very long comment that goes over limit
ex: D): String = 1
>>>
def format_![T <: Tree](
code: String, // The code!
code2: String
)(implicit ev: Parse[T], // The Parser!!! Some very long comment that goes over limit
ex: D
): String = 1

<<< should not modify into single line if it has comments
def format_!(
code: String, // The code!
code2: String
): String = 1
>>>
def format_!(
code: String, // The code!
code2: String
): String = 1

<<< should work with defaulted method
def format_![T <: Tree](
name: Name,
code: String = Defaults.code, updatedAt: Instant = Instant.now(),
user: User = new User { def someFunc(): RT = () },
createdAt: Instant = Default.getInstant(a)(b))
(implicit ev: Parse[T],
ev2: EC)
: String
>>>
def format_![T <: Tree](
name: Name,
code: String = Defaults.code,
updatedAt: Instant = Instant.now(),
user: User = new User { def someFunc(): RT = () },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have btw seen crazy code like this! iirc it was somewhere in twitter/summingbird ^_^

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can gladly say I've never seen this; wasn't even sure it would parse :\

createdAt: Instant = Default.getInstant(a)(b)
)(implicit ev: Parse[T],
ev2: EC
): String

<<< should not affect classes
final class UserProfile(name: String, age: Int, address: Address, profession: Profesion, school: School)
extends Profile with UserSettings
Expand Down