Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NeverInfixPattern: rename from ambiguous Pattern #3702

Merged
merged 1 commit into from
Nov 23, 2023
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 @@ -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
Loading