mirror of https://github.com/sbt/sbt.git
detect invalid project IDs
This commit is contained in:
parent
9d21c48f41
commit
f813256ced
|
|
@ -87,16 +87,20 @@ object Command
|
|||
def process(command: String, state: State): State =
|
||||
{
|
||||
val parser = combine(state.definedCommands)
|
||||
Parser.result(parser(state), command) match
|
||||
parse(command, parser(state)) match
|
||||
{
|
||||
case Right(s) => s() // apply command. command side effects happen here
|
||||
case Left(failures) =>
|
||||
val (msgs,pos) = failures()
|
||||
val errMsg = commandError(command, msgs, pos)
|
||||
case Left(errMsg) =>
|
||||
state.log.error(errMsg)
|
||||
state.fail
|
||||
}
|
||||
}
|
||||
def parse[T](str: String, parser: Parser[T]): Either[String, T] =
|
||||
Parser.result(parser, str).left.map { failures =>
|
||||
val (msgs,pos) = failures()
|
||||
commandError(str, msgs, pos)
|
||||
}
|
||||
|
||||
def commandError(command: String, msgs: Seq[String], index: Int): String =
|
||||
{
|
||||
val (line, modIndex) = extractLine(command, index)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ package sbt
|
|||
import Scope.{GlobalScope,ThisScope}
|
||||
import Load.BuildStructure
|
||||
import Types.{idFun, Id}
|
||||
import complete.DefaultParsers
|
||||
|
||||
sealed trait ProjectDefinition[PR <: ProjectReference]
|
||||
{
|
||||
|
|
@ -136,7 +137,10 @@ object Project extends Init[Scope] with ProjectExtra
|
|||
|
||||
def apply(id: String, base: File, aggregate: => Seq[ProjectReference] = Nil, dependencies: => Seq[ClasspathDep[ProjectReference]] = Nil, delegates: => Seq[ProjectReference] = Nil,
|
||||
settings: => Seq[Setting[_]] = defaultSettings, configurations: Seq[Configuration] = Configurations.default): Project =
|
||||
new ProjectDef[ProjectReference](id, base, aggregate, dependencies, delegates, settings, configurations) with Project
|
||||
{
|
||||
Command.parse(id, DefaultParsers.ID).left.foreach(errMsg => error("Invalid project ID: " + errMsg))
|
||||
new ProjectDef[ProjectReference](id, base, aggregate, dependencies, delegates, settings, configurations) with Project
|
||||
}
|
||||
|
||||
def resolved(id: String, base: File, aggregate: => Seq[ProjectRef], dependencies: => Seq[ResolvedClasspathDependency], delegates: => Seq[ProjectRef],
|
||||
settings: Seq[Setting[_]], configurations: Seq[Configuration]): ResolvedProject =
|
||||
|
|
@ -314,7 +318,7 @@ object Project extends Init[Scope] with ProjectExtra
|
|||
val Return, Current, Plugins = Value
|
||||
}
|
||||
import LoadAction._
|
||||
import complete.DefaultParsers._
|
||||
import DefaultParsers._
|
||||
|
||||
val loadActionParser = token(Space ~> ("plugins" ^^^ Plugins | "return" ^^^ Return)) ?? Current
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue