mirror of https://github.com/sbt/sbt.git
make completion cross product lazier
This commit is contained in:
parent
6688918349
commit
63c8fd715d
|
|
@ -11,7 +11,7 @@ package sbt.complete
|
|||
sealed trait Completions
|
||||
{
|
||||
def get: Set[Completion]
|
||||
final def x(o: Completions): Completions = Completions( for(cs <- get; os <- o.get) yield cs ++ os )
|
||||
final def x(o: Completions): Completions = flatMap(_ x o)
|
||||
final def ++(o: Completions): Completions = Completions( get ++ o.get )
|
||||
final def +:(o: Completion): Completions = Completions(get + o)
|
||||
final def filter(f: Completion => Boolean): Completions = Completions(get filter f)
|
||||
|
|
@ -68,7 +68,7 @@ sealed trait Completion
|
|||
|
||||
/** Appends the completions in `o` with the completions in this Completion.*/
|
||||
def ++(o: Completion): Completion = Completion.concat(this, o)
|
||||
final def x(o: Completions): Completions = o.map(this ++ _)
|
||||
final def x(o: Completions): Completions = if(Completion evaluatesRight this) o.map(this ++ _) else Completions.strict(Set.empty + this)
|
||||
override final lazy val hashCode = Completion.hashCode(this)
|
||||
override final def equals(o: Any) = o match { case c: Completion => Completion.equal(this, c); case _ => false }
|
||||
}
|
||||
|
|
@ -103,6 +103,13 @@ object Completion
|
|||
case _ if a.isEmpty => b
|
||||
case _ => a
|
||||
}
|
||||
def evaluatesRight(a: Completion): Boolean =
|
||||
a match
|
||||
{
|
||||
case _: Suggestion => true
|
||||
case at: Token if at.append.isEmpty => true
|
||||
case _ => a.isEmpty
|
||||
}
|
||||
|
||||
def equal(a: Completion, b: Completion): Boolean =
|
||||
(a,b) match
|
||||
|
|
|
|||
Loading…
Reference in New Issue