Change to suggested plugin style#1
Conversation
| )( | ||
| implicit logger: Logger, transientCache: java.util.Map[AnyRef,AnyRef], classLoaderCache: ClassLoaderCache | ||
| ){ | ||
| case class config( version: String = "0.2.4", options: Seq[SplainOption] = Seq( all() ) ){ |
There was a problem hiding this comment.
Having this case class apply and a nested case class config is a bit unusual, but allows for some very nice properties as far as I can tell. Many of the non stage2 plugins are following this style for a while. (Also see doc/plugin-author-guide.md for more info about this pattern). But basically it allows plugins to occupy only a single field in the trait and allowing for it to be configurable by:
override def splain = super.splain.copy(
version = "0.2.5",
options = super.splain.options :+ Splain.color(false)
)
it also now allows less prefixing names with "splain", because they are already scoped in the relevant object/class as members or arguments.
There was a problem hiding this comment.
case class apply is basically for argument that shouldn't be changed by the user. case class config is for those that should. sort of private / public.
| * A scala compiler plugin for more concise errors | ||
| * See: https://github.com/tek/splain | ||
| */ | ||
| trait Splain extends BaseBuild{ |
There was a problem hiding this comment.
none of the other traits end in Plugin right now, so I removed that
|
|
||
| object Splain{ | ||
| abstract class SplainOption( name: String, value: String ){ | ||
| def scalacOption = "-P:splain:" ~ name ~ ":" ~ value |
| case class tree( value: Boolean = true ) extends SplainOption( "tree", value.toString ) | ||
| case class compact( value: Boolean = false ) extends SplainOption( "compact", if( value ) "on" else "off" ) | ||
| case class boundsimplicits( value: Boolean = true ) extends SplainOption( "boundsimplicits", value.toString ) | ||
| case class truncrefined( value: Int = 0 ) extends SplainOption( "truncrefined", value.toString ) |
There was a problem hiding this comment.
lower cased them to be consistent how splain calls them. Not 100% sure about this, but tend to rather adhere to the pattern of the library instead of Scala's kindof fragile naming, where terms are sometimes lower case (defs, vals) and sometimes upper case (objects), but all can behave like functions.
|
an example/test demonstrating it actually works would be great for this one as well |
102d015 to
c5c5ec5
Compare
@megri how do you feel about this?