Skip to content

Commit

Permalink
NeverInfixPattern: rename from ambiguous Pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Nov 23, 2023
1 parent a09480a commit b156f7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.scalafmt.config
import metaconfig._
import metaconfig.generic.Surface

case class Pattern(
case class NeverInfixPattern(
includeFilters: Seq[String],
excludeFilters: Seq[String]
) {
Expand All @@ -12,18 +12,18 @@ case class Pattern(
FilterMatcher.mkRegexp(excludeFilters, true)
)

private[config] def forSbt: Option[Pattern] =
private[config] def forSbt: Option[NeverInfixPattern] =
// if the user customized these, we don't touch
if (excludeFilters ne Pattern.neverInfix.excludeFilters) None
else Some(copy(excludeFilters = Pattern.sbtExclude))
if (excludeFilters ne NeverInfixPattern.default.excludeFilters) None
else Some(copy(excludeFilters = NeverInfixPattern.sbtExclude))
}

object Pattern {
implicit lazy val surface: Surface[Pattern] =
object NeverInfixPattern {
implicit lazy val surface: Surface[NeverInfixPattern] =
generic.deriveSurface
implicit lazy val codec: ConfCodecEx[Pattern] =
generic.deriveCodecEx(neverInfix).noTypos
val neverInfix = Pattern(
implicit lazy val codec: ConfCodecEx[NeverInfixPattern] =
generic.deriveCodecEx(default).noTypos
val default = NeverInfixPattern(
Seq("[\\w\\d_]+"),
Seq(
"until",
Expand Down Expand Up @@ -57,5 +57,5 @@ object Pattern {

private val sbtExclude = Seq(
"cross"
) ++ neverInfix.excludeFilters
) ++ default.excludeFilters
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ case class RewriteSettings(
preferCurlyFors: PreferCurlyFors.Settings = PreferCurlyFors.Settings(),
trailingCommas: TrailingCommas = TrailingCommas(),
allowInfixPlaceholderArg: Boolean = true,
neverInfix: Pattern = Pattern.neverInfix
neverInfix: NeverInfixPattern = NeverInfixPattern.default
) {
def withoutRewrites: RewriteSettings =
copy(rules = Nil, trailingCommas = trailingCommas.withoutRewrites)
Expand Down

0 comments on commit b156f7e

Please # to comment.