turn back syntax classes into traits

This commit is contained in:
Eugene Yokota 2017-07-12 08:02:25 -04:00
parent 7844190964
commit 358b750dde
3 changed files with 35 additions and 7 deletions

View File

@ -8,7 +8,12 @@ import sbt.internal.librarymanagement.StringUtilities.nonEmpty
/**
* DependencyBuilders implements the implicits for % and %% DSL.
*/
abstract class DependencyBuilders {
trait DependencyBuilders {
// See http://www.scala-lang.org/news/2.12.0#traits-compile-to-interfaces
// Avoid defining fields (val or var, but a constant is ok final val without result type)
// Avoid calling super
// Avoid initializer statements in the body
import DependencyBuilders._
implicit def stringToOrganization(organization: String): Organization = {

View File

@ -6,6 +6,11 @@ package sbt.librarymanagement
import sbt.io.{ AllPassFilter, NameFilter }
trait DependencyFilterExtra {
// See http://www.scala-lang.org/news/2.12.0#traits-compile-to-interfaces
// Avoid defining fields (val or var, but a constant is ok final val without result type)
// Avoid calling super
// Avoid initializer statements in the body
def moduleFilter(
organization: NameFilter = AllPassFilter,
name: NameFilter = AllPassFilter,
@ -15,6 +20,7 @@ trait DependencyFilterExtra {
def apply(m: ModuleID): Boolean =
organization.accept(m.organization) && name.accept(m.name) && revision.accept(m.revision)
}
def artifactFilter(
name: NameFilter = AllPassFilter,
`type`: NameFilter = AllPassFilter,
@ -26,11 +32,13 @@ trait DependencyFilterExtra {
name.accept(a.name) && `type`.accept(a.`type`) && extension.accept(a.extension) && classifier
.accept(a.classifier getOrElse "")
}
def configurationFilter(name: NameFilter = AllPassFilter): ConfigurationFilter =
new ConfigurationFilter {
def apply(c: ConfigRef): Boolean = name.accept(c.name)
}
}
object DependencyFilter extends DependencyFilterExtra {
def make(
configuration: ConfigurationFilter = configurationFilter(),

View File

@ -1,13 +1,28 @@
package sbt.librarymanagement
abstract class LibraryManagementSyntax extends DependencyBuilders {
type ExclusionRule = InclExclRule
val ExclusionRule = InclExclRule
type InclusionRule = InclExclRule
val InclusionRule = InclExclRule
trait LibraryManagementSyntax0 {
// See http://www.scala-lang.org/news/2.12.0#traits-compile-to-interfaces
// Avoid defining fields (val or var, but a constant is ok final val without result type)
// Avoid calling super
// Avoid initializer statements in the body
implicit def richUpdateReport(ur: UpdateReport): RichUpdateReport = new RichUpdateReport(ur)
}
trait LibraryManagementSyntax
extends LibraryManagementSyntax0
with DependencyBuilders
with DependencyFilterExtra {
// See http://www.scala-lang.org/news/2.12.0#traits-compile-to-interfaces
// Avoid defining fields (val or var, but a constant is ok final val without result type)
// Avoid calling super
// Avoid initializer statements in the body
type ExclusionRule = InclExclRule
final val ExclusionRule = InclExclRule
type InclusionRule = InclExclRule
final val InclusionRule = InclExclRule
import sbt.librarymanagement.{ Configurations => C }
final val Compile = C.Compile