diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-15 12:16:15 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-15 12:57:56 -0800 |
commit | 5e9d809c6eb566e8452bbe2f3a986f31c57e5438 (patch) | |
tree | 6e7c3bc9bee712d66a2575a4b8dfd18eae917b0a /core/src/main/scala | |
parent | e5c313e12faf3ccf90aa7f69eb2eb16f8add782f (diff) | |
download | mill-5e9d809c6eb566e8452bbe2f3a986f31c57e5438.tar.gz mill-5e9d809c6eb566e8452bbe2f3a986f31c57e5438.tar.bz2 mill-5e9d809c6eb566e8452bbe2f3a986f31c57e5438.zip |
- Collapse `Ctx#segments` and `Ctx#segments0` into one field, instead doing the prefix-stripping up-front in `BaseModule`
Diffstat (limited to 'core/src/main/scala')
-rw-r--r-- | core/src/main/scala/mill/define/Cross.scala | 2 | ||||
-rw-r--r-- | core/src/main/scala/mill/define/Ctx.scala | 7 | ||||
-rw-r--r-- | core/src/main/scala/mill/define/Module.scala | 15 | ||||
-rw-r--r-- | core/src/main/scala/mill/define/Task.scala | 6 |
4 files changed, 18 insertions, 12 deletions
diff --git a/core/src/main/scala/mill/define/Cross.scala b/core/src/main/scala/mill/define/Cross.scala index 8af8e2e3..0d799f19 100644 --- a/core/src/main/scala/mill/define/Cross.scala +++ b/core/src/main/scala/mill/define/Cross.scala @@ -63,7 +63,7 @@ class Cross[T](cases: Any*) val sub = ci.make( c, ctx.copy( - segments0 = ctx.segments0 ++ Seq(ctx.segment), + segments = ctx.segments ++ Seq(ctx.segment), basePath = ctx.basePath / relPath, segment = Segment.Cross(crossValues) ) diff --git a/core/src/main/scala/mill/define/Ctx.scala b/core/src/main/scala/mill/define/Ctx.scala index fc8bf85a..308c50ef 100644 --- a/core/src/main/scala/mill/define/Ctx.scala +++ b/core/src/main/scala/mill/define/Ctx.scala @@ -41,10 +41,9 @@ case class Ctx(enclosing: String, lineNum: Int, segment: Segment, basePath: Path, - segments0: Segments, - overrides: Int){ - def segments = Segments(segments0.value.drop(1):_*) -} + segments: Segments, + overrides: Int) + object Ctx{ implicit def make(implicit millModuleEnclosing0: sourcecode.Enclosing, millModuleLine0: sourcecode.Line, diff --git a/core/src/main/scala/mill/define/Module.scala b/core/src/main/scala/mill/define/Module.scala index 3d3bb87c..f7c84b6d 100644 --- a/core/src/main/scala/mill/define/Module.scala +++ b/core/src/main/scala/mill/define/Module.scala @@ -30,7 +30,7 @@ class Module(implicit outerCtx0: mill.define.Ctx) extends mill.moduledefs.Cacher }) implicit def millModuleBasePath: BasePath = BasePath(basePath) implicit def millModuleSegments: Segments = { - millOuterCtx.segments0 ++ Seq(millOuterCtx.segment) + millOuterCtx.segments ++ Seq(millOuterCtx.segment) } } @@ -90,11 +90,18 @@ trait TaskModule extends Module { def defaultCommandName(): String } -class BaseModule(basePath: Path) +class BaseModule(basePath0: Path) (implicit millModuleEnclosing0: sourcecode.Enclosing, millModuleLine0: sourcecode.Line, millName0: sourcecode.Name, overrides0: Overrides) extends Module()( - mill.define.Ctx.make(implicitly, implicitly, implicitly, BasePath(basePath), Segments(), implicitly) - )
\ No newline at end of file + mill.define.Ctx.make(implicitly, implicitly, implicitly, BasePath(basePath0), Segments(), implicitly) + ){ + // A BaseModule should provide an empty Segments list to it's children, since + // it is the root of the module tree, and thus must not include it's own + // sourcecode.Name as part of the list, + override implicit def millModuleSegments: Segments = Segments() + override implicit def millModuleBasePath: BasePath = BasePath(millOuterCtx.basePath) + override def basePath = millOuterCtx.basePath +}
\ No newline at end of file diff --git a/core/src/main/scala/mill/define/Task.scala b/core/src/main/scala/mill/define/Task.scala index c0892743..90908e4e 100644 --- a/core/src/main/scala/mill/define/Task.scala +++ b/core/src/main/scala/mill/define/Task.scala @@ -229,7 +229,7 @@ object Caller { class TargetImpl[+T](t: Task[T], ctx0: mill.define.Ctx, val readWrite: RW[_]) extends Target[T] { - val ctx = ctx0.copy(segments0 = ctx0.segments0 ++ Seq(ctx0.segment)) + val ctx = ctx0.copy(segments = ctx0.segments ++ Seq(ctx0.segment)) val inputs = Seq(t) def evaluate(args: mill.util.Ctx) = args[T](0) override def toString = ctx.enclosing + "@" + Integer.toHexString(System.identityHashCode(this)) @@ -237,7 +237,7 @@ class TargetImpl[+T](t: Task[T], class Command[+T](t: Task[T], ctx0: mill.define.Ctx, val writer: W[_]) extends NamedTask[T] { - val ctx = ctx0.copy(segments0 = ctx0.segments0 ++ Seq(ctx0.segment)) + val ctx = ctx0.copy(segments = ctx0.segments ++ Seq(ctx0.segment)) val inputs = Seq(t) def evaluate(args: mill.util.Ctx) = args[T](0) override def asCommand = Some(this) @@ -253,7 +253,7 @@ class Persistent[+T](t: Task[T], class Input[T](t: Task[T], ctx0: mill.define.Ctx, val readWrite: RW[_]) extends Target[T]{ - val ctx = ctx0.copy(segments0 = ctx0.segments0 ++ Seq(ctx0.segment)) + val ctx = ctx0.copy(segments = ctx0.segments ++ Seq(ctx0.segment)) val inputs = Seq(t) def evaluate(args: mill.util.Ctx) = args[T](0) override def sideHash = util.Random.nextInt() |