diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/scala/mill/Main.scala | 19 | ||||
-rw-r--r-- | core/src/main/scala/mill/discover/Discovered.scala | 3 | ||||
-rw-r--r-- | core/src/main/scala/mill/discover/Mirror.scala | 9 |
3 files changed, 17 insertions, 14 deletions
diff --git a/core/src/main/scala/mill/Main.scala b/core/src/main/scala/mill/Main.scala index 1dbae4c3..db7a6c1a 100644 --- a/core/src/main/scala/mill/Main.scala +++ b/core/src/main/scala/mill/Main.scala @@ -26,14 +26,7 @@ object Main { query.parse(input) } - def renderSelector(selector: List[Mirror.Segment]) = { - val Mirror.Segment.Label(head) :: rest = selector - val stringSegments = rest.map{ - case Mirror.Segment.Label(s) => "." + s - case Mirror.Segment.Cross(vs) => "[" + vs.mkString(",") + "]" - } - head + stringSegments.mkString - } + def parseArgs(selectorString: String): Either[String, List[Mirror.Segment]] = { import fastparse.all.Parsed @@ -81,7 +74,7 @@ object Main { def command = invokeCommand(hierarchy, last) command orElse target orElse runDefault.headOption.flatten match{ - case None => Left("Cannot resolve task " + renderSelector( + case None => Left("Cannot resolve task " + Mirror.renderSelector( (Mirror.Segment.Label(last) :: revSelectorsSoFar).reverse) ) case Some(either) => either @@ -96,7 +89,7 @@ object Main { case (label, child) if label == singleLabel => child } match{ case Some(child) => resolve(tail, child, obj, rest, remainingCrossSelectors, newRevSelectorsSoFar) - case None => Left("Cannot resolve module " + renderSelector(newRevSelectorsSoFar.reverse)) + case None => Left("Cannot resolve module " + Mirror.renderSelector(newRevSelectorsSoFar.reverse)) } case Mirror.Segment.Cross(cross) => @@ -105,7 +98,7 @@ object Main { if (crossOptions.contains(cross)){ resolve(tail, childMirror, obj, rest, remainingCrossSelectors, newRevSelectorsSoFar) }else{ - Left("Cannot resolve cross " + renderSelector(newRevSelectorsSoFar.reverse)) + Left("Cannot resolve cross " + Mirror.renderSelector(newRevSelectorsSoFar.reverse)) } @@ -119,7 +112,7 @@ object Main { val discovered = implicitly[Discovered[T]] val consistencyErrors = Discovered.consistencyCheck(obj, discovered) if (consistencyErrors.nonEmpty) { - Left(s"Failed Discovered.consistencyCheck: $consistencyErrors") + Left(s"Failed Discovered.consistencyCheck: ${consistencyErrors.map(Mirror.renderSelector)}") } else { Right(discovered) } @@ -138,7 +131,7 @@ object Main { (for((k, fs) <- evaluated.failing.items()) yield { val ks = k match{ case Left(t) => t.toString - case Right(t) => renderSelector(t.segments.toList) + case Right(t) => Mirror.renderSelector(t.segments.toList) } val fss = fs.map{ case Result.Exception(t) => t.toString diff --git a/core/src/main/scala/mill/discover/Discovered.scala b/core/src/main/scala/mill/discover/Discovered.scala index aef5f14f..753ac141 100644 --- a/core/src/main/scala/mill/discover/Discovered.scala +++ b/core/src/main/scala/mill/discover/Discovered.scala @@ -47,7 +47,8 @@ object Discovered { if m.isMethod && m.typeSignature.paramLists.isEmpty && m.typeSignature.resultType <:< c.weakTypeOf[Target[_]] && - !m.name.toString.contains(' ') + !m.name.toString.contains(' ') && + m.isPublic } yield { val x = Ident(TermName(c.freshName())) val t = q"""mill.discover.Mirror.makeTargetPoint( diff --git a/core/src/main/scala/mill/discover/Mirror.scala b/core/src/main/scala/mill/discover/Mirror.scala index 4dfeaa25..6293e599 100644 --- a/core/src/main/scala/mill/discover/Mirror.scala +++ b/core/src/main/scala/mill/discover/Mirror.scala @@ -25,6 +25,15 @@ case class Mirror[-T, V](node: (T, List[List[Any]]) => V, } object Mirror{ + def renderSelector(selector: Seq[Mirror.Segment]) = { + val Mirror.Segment.Label(head) :: rest = selector.toList + val stringSegments = rest.map{ + case Mirror.Segment.Label(s) => "." + s + case Mirror.Segment.Cross(vs) => "[" + vs.mkString(",") + "]" + } + head + stringSegments.mkString + } + sealed trait Segment object Segment{ case class Label(value: String) extends Segment |