-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Encoders for all config options
- Loading branch information
Showing
24 changed files
with
77 additions
and
38 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
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
4 changes: 2 additions & 2 deletions
4
scalafmt-core/shared/src/main/scala/org/scalafmt/config/Docstrings.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
4 changes: 2 additions & 2 deletions
4
scalafmt-core/shared/src/main/scala/org/scalafmt/config/LineEndings.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
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
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
29 changes: 17 additions & 12 deletions
29
scalafmt-core/shared/src/main/scala/org/scalafmt/config/SpaceBeforeContextBound.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,30 @@ | ||
package org.scalafmt.config | ||
|
||
import metaconfig.ConfCodec | ||
import metaconfig.ConfEncoder | ||
import metaconfig.Configured.Ok | ||
import metaconfig.{Conf, ConfDecoder} | ||
import org.scalafmt.config.SpaceBeforeContextBound.{Always, IfMultipleBounds} | ||
|
||
sealed trait SpaceBeforeContextBound { | ||
def isIfMultipleBounds = this == IfMultipleBounds | ||
def isAlways = this == Always | ||
} | ||
|
||
object SpaceBeforeContextBound { | ||
|
||
implicit val reader = ConfDecoder.instance[SpaceBeforeContextBound] { | ||
case Conf.Bool(true) => Ok(Always) | ||
case Conf.Bool(false) => Ok(Never) | ||
case x => | ||
ReaderUtil | ||
.oneOf[SpaceBeforeContextBound](Always, Never, IfMultipleBounds) | ||
.read(x) | ||
} | ||
val codec: ConfCodec[SpaceBeforeContextBound] = | ||
ReaderUtil.oneOf[SpaceBeforeContextBound](Always, Never, IfMultipleBounds) | ||
|
||
implicit val encoder: ConfEncoder[SpaceBeforeContextBound] = codec | ||
implicit val reader: ConfDecoder[SpaceBeforeContextBound] = | ||
ConfDecoder.instance[SpaceBeforeContextBound] { | ||
case Conf.Bool(true) => Ok(Always) | ||
case Conf.Bool(false) => Ok(Never) | ||
case x => codec.read(x) | ||
} | ||
|
||
case object Always extends SpaceBeforeContextBound | ||
case object Never extends SpaceBeforeContextBound | ||
case object IfMultipleBounds extends SpaceBeforeContextBound | ||
} | ||
sealed trait SpaceBeforeContextBound { | ||
def isIfMultipleBounds = this == IfMultipleBounds | ||
def isAlways = this == Always | ||
} |
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