forked from scalacenter/scalafix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scalacenter#907 from Jacoby6000/feature/better-regex
Improve regex integration with DisableSyntax
- Loading branch information
Showing
8 changed files
with
143 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package scalafix.config | ||
|
||
import metaconfig.Conf | ||
import metaconfig.ConfDecoder | ||
import java.util.regex.Pattern | ||
import scalafix.internal.config.ScalafixMetaconfigReaders._ | ||
|
||
class Regex( | ||
val pattern: Pattern, | ||
val captureGroup: Option[Int] | ||
) | ||
|
||
object Regex { | ||
implicit val regexDecoder: ConfDecoder[Regex] = | ||
ConfDecoder.instance[Regex] { | ||
case obj: Conf.Obj => | ||
(obj.get[Pattern]("pattern") |@| obj.getOption[Int]("captureGroup")) | ||
.map { | ||
case (pattern, groupIndex) => new Regex(pattern, groupIndex) | ||
} | ||
} | ||
|
||
implicit val customMessageRegexDecoder: ConfDecoder[CustomMessage[Regex]] = | ||
CustomMessage.decoder[Regex](field = "regex") | ||
} |
2 changes: 2 additions & 0 deletions
2
scalafix-core/src/main/scala/scalafix/internal/config/ScalafixConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters