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

State: don't waive comment overflow for binPack #2993

Merged
merged 2 commits into from
Dec 25, 2021
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 @@ -90,7 +90,15 @@ final case class State(
else
(style.comments.wrap eq Comments.Wrap.trailing) ||
style.comments.willWrap && nextSplit.isNL
}
} && (nextSplit.isNL || {
// do not waive overflow in binpacking case
val owner = tok.meta.rightOwner
val ownerLast = tokens.getLastNonTrivial(owner).left
val isBracket = ownerLast.is[Token.RightBracket]
!(isBracket || ownerLast.is[Token.RightParen]) ||
style.binPack.defnSite(isBracket).isNever && isDefnSite(owner) ||
style.binPack.callSite(isBracket).isNever && isCallSite(owner)
})
}
) {
(math.max(0, delayedPenalty), 0) // fits inside column
Expand Down
153 changes: 136 additions & 17 deletions scalafmt-tests/src/test/resources/unit/Comment.stat
Original file line number Diff line number Diff line change
Expand Up @@ -519,21 +519,51 @@ object a {
}
>>>
object a {
val requestedIds = Seq( /* First 2 will not be taken into account since this app for 'Do Not Sell'
* and 'ATT' only */
val requestedIds =
Seq( // First 2 will not be taken into account since this app for 'Do Not Sell' and 'ATT' only
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete),
/* Next 2 will not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
)
}
<<< binpack=oneline, with trailing-wrapped comment, narrower
maxColumn = 90
indent.callSite = 2
comments.wrap = trailing
binPack.unsafeCallSite = oneline
===
object a {
val foo = Seq( // First 2 will not be taken into account since this app for 'Do Not Sell'
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete), /* Next 2 will
* not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
)
}
>>>
object a {
val foo =
Seq( // First 2 will not be taken into account since this app for 'Do Not Sell'
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete),
/* Next 2 will not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
)
/* Only last record will be taken into account but not the next one since filtering
* of 'ATT' IDs is requsted for MD5 and SHA1 and not for LUID */
)
}
<<< binpack=oneline, with wrapped comment, narrower
<<< binpack=oneline, trailing-wrapped comment, narrower
maxColumn = 90
indent.callSite = 2
comments.wrap = trailing
comments.wrap = standalone
binPack.unsafeCallSite = oneline
===
object a {
Expand All @@ -549,18 +579,48 @@ object a {
}
>>>
object a {
val foo = Seq( /* First 2 will not be taken into account since this app for 'Do Not
* Sell' */
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete),
/* Next 2 will not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering of
* 'ATT' IDs is requsted for MD5 and SHA1 and not for LUID */
val foo =
Seq( // First 2 will not be taken into account since this app for 'Do Not Sell'
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete),
/* Next 2 will not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering
* of 'ATT' IDs is requsted for MD5 and SHA1 and not for LUID */
)
}
<<< binpack=oneline, no comment wrapping, narrower
maxColumn = 90
indent.callSite = 2
binPack.unsafeCallSite = oneline
===
object a {
val foo = Seq( // First 2 will not be taken into account since this app for 'Do Not Sell'
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete), /* Next 2 will
* not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
)
}
<<< binpack=oneline, defn, with wrapped comment, narrower
>>>
object a {
val foo =
Seq( // First 2 will not be taken into account since this app for 'Do Not Sell'
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete),
/* Next 2 will
* not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
)
}
<<< binpack=oneline, defn, with trailing-wrapped comment, narrower
maxColumn = 51
indent.callSite = 2
align.preset = none
Expand Down Expand Up @@ -592,3 +652,62 @@ object a {
* and SHA1 and not for LUID */
) = ???
}
<<< binpack=oneline, defn, with standalone-wrapped comment, narrower
maxColumn = 51
indent.callSite = 2
align.preset = none
comments.wrap = standalone
binPack.unsafeDefnSite = oneline
===
object a {
def foo( // First 2 will not be taken into account
foo1: Int,
foo2: String, /* Next 2 will
* not be taken into account since 'filterDoNotSellBy' is not set */
foo3: Map[Int, Int],
foo4: Set[Int]
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
) = ???
}
>>>
object a {
def foo( // First 2 will not be taken into account
foo1: Int, foo2: String,
/* Next 2 will not be taken into account
* since 'filterDoNotSellBy' is not set */
foo3: Map[Int, Int], foo4: Set[Int]
/* Only last record will be taken into
* account but not the next one since
* filtering of 'ATT' IDs is requsted for MD5
* and SHA1 and not for LUID */
) = ???
}
<<< binpack=oneline, defn, no comment wrapping, narrower
maxColumn = 51
indent.callSite = 2
align.preset = none
binPack.unsafeDefnSite = oneline
===
object a {
def foo( // First 2 will not be taken into account
foo1: Int,
foo2: String, /* Next 2 will
* not be taken into account since 'filterDoNotSellBy' is not set */
foo3: Map[Int, Int],
foo4: Set[Int]
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
) = ???
}
>>>
object a {
def foo( // First 2 will not be taken into account
foo1: Int, foo2: String,
/* Next 2 will
* not be taken into account since 'filterDoNotSellBy' is not set */
foo3: Map[Int, Int], foo4: Set[Int]
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
) = ???
}