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

Newlines: split SourceHints and IgnoreSourceSplit #3288

Merged
merged 1 commit into from
Aug 11, 2022
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 @@ -333,10 +333,14 @@ object Newlines {
implicit lazy val codec: ConfCodecEx[Newlines] =
generic.deriveCodecEx(Newlines()).noTypos

sealed abstract class SourceHints(val ignoreSourceSplit: Boolean) {
sealed abstract class IgnoreSourceSplit {
val ignoreSourceSplit: Boolean
@inline
final def in(hints: SourceHints*): Boolean = hints.contains(this)
final def in(hints: IgnoreSourceSplit*): Boolean = hints.contains(this)
}

sealed abstract class SourceHints(val ignoreSourceSplit: Boolean)
extends IgnoreSourceSplit
// the classic handler of source newlines
case object classic extends SourceHints(ignoreSourceSplit = false)
// try to keep newlines
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ object ScalafmtConfig {
if (newlines.sourceIgnored) {
addIf(optIn.configStyleArguments && align.openParenCallSite && newlines.beforeOpenParenCallSite.isEmpty)
addIf(optIn.configStyleArguments && align.openParenDefnSite && newlines.beforeOpenParenDefnSite.isEmpty)
def mustIgnoreSourceSplit(what: sourcecode.Text[Option[Newlines.SourceHints]]) =
def mustIgnoreSourceSplit(what: sourcecode.Text[Option[Newlines.IgnoreSourceSplit]]) =
what.value.foreach(x => addIfDirect(!x.ignoreSourceSplit, s"${what.source}=$x"))
mustIgnoreSourceSplit(newlines.beforeMultiline)
mustIgnoreSourceSplit(newlines.beforeMultilineDef)
Expand Down