Skip to content

Commit

Permalink
Newlines: split SourceHints and IgnoreSourceSplit
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Aug 11, 2022
1 parent f2ac9e4 commit 13d8250
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
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

0 comments on commit 13d8250

Please sign in to comment.