-
Notifications
You must be signed in to change notification settings - Fork 185
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 #500 from MasseGuillaume/feature/495-custom-id
Add id for CustomMessage (fix #495)
- Loading branch information
Showing
10 changed files
with
65 additions
and
45 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
38 changes: 38 additions & 0 deletions
38
scalafix-core/shared/src/main/scala/scalafix/config/CustomMessage.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package scalafix | ||
package config | ||
|
||
import metaconfig.{Conf, ConfError, ConfDecoder, Configured, Metaconfig} | ||
import org.langmeta._ | ||
import scalafix.internal.config.MetaconfigPendingUpstream.XtensionConfScalafix | ||
|
||
import scala.language.implicitConversions | ||
|
||
class CustomMessage[T]( | ||
val value: T, | ||
val message: Option[String], | ||
val id: Option[String]) | ||
|
||
object CustomMessage { | ||
def decoder[T](field: String)( | ||
implicit ev: ConfDecoder[T]): ConfDecoder[CustomMessage[T]] = | ||
ConfDecoder.instance[CustomMessage[T]] { | ||
case obj: Conf.Obj => { | ||
(obj.get[T](field) |@| | ||
obj.getOption[String]("message") |@| | ||
obj.getOption[String]("id")).map { | ||
case ((value, message0), id) => | ||
val message = | ||
message0.map(msg => | ||
if (msg.isMultiline) { | ||
"\n" + msg.stripMargin | ||
} else { | ||
msg | ||
}) | ||
|
||
new CustomMessage(value, message, id) | ||
} | ||
} | ||
case els => | ||
ev.read(els).map(value => new CustomMessage(value, None, None)) | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
scalafix-core/shared/src/main/scala/scalafix/internal/config/CustomMessage.scala
This file was deleted.
Oops, something went wrong.
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
3 changes: 2 additions & 1 deletion
3
scalafix-core/shared/src/main/scala/scalafix/internal/config/DisableSyntaxConfig.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