Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

Commit

Permalink
Issue #13 - Corrected precise nature of CanBuildFromWithZipper
Browse files Browse the repository at this point in the history
  • Loading branch information
djspiewak committed May 13, 2011
1 parent 85ca4e3 commit 2d184ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ import scala.collection.mutable.Builder
* resolution, but still accessible without requiring an explicit import.
*/
trait CanBuildFromWithZipper[-From, -Elem, To] extends CanBuildFrom[From, Elem, To] {
def apply(from: From): Builder[Elem, To] = apply(from, Vector())
def apply(from: From): Builder[Elem, To] = apply(Vector())
def apply(): Builder[Elem, To] = apply(Vector())

def apply(from: From, map: =>Vector[Option[ZContext]]): Builder[Elem, To]
def apply(parent: From, map: =>Vector[Option[ZContext]]): Builder[Elem, To]
def apply(map: =>Vector[Option[ZContext]]): Builder[Elem, To]

/**
Expand Down Expand Up @@ -81,7 +81,7 @@ object CanBuildFromWithZipper {
* on [[com.codecommit.antixml.Group]].
*/
implicit def identityCanBuildFrom[From, Elem, To](implicit cbf: CanBuildFrom[From, Elem, To], coerce: To => Traversable[Elem]): CanBuildFromWithZipper[From, Elem, To] = new CanBuildFromWithZipper[From, Elem, To] {
def apply(from: From, map: =>Vector[Option[ZContext]]) = cbf(from)
def apply(parent: From, map: =>Vector[Option[ZContext]]) = cbf()
def apply(map: =>Vector[Option[ZContext]]) = cbf()

def append(left: To, right: To) = {
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/com/codecommit/antixml/Group.scala
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,17 @@ class Group[+A <: Node] private[antixml] (private[antixml] val nodes: VectorCase
object Group {
implicit def canBuildFromWithZipper[A <: Node]: CanBuildFromWithZipper[Group[_], A, Zipper[A]] = {
new CanBuildFromWithZipper[Group[_], A, Zipper[A]] {
def apply(from: Group[_], baseMap: =>Vector[Option[ZContext]]): Builder[A, Zipper[A]] = {
def apply(outerParent: Group[_], baseMap: =>Vector[Option[ZContext]]): Builder[A, Zipper[A]] = {
VectorCase.newBuilder[A] mapResult { vec =>
new Group(vec) with Zipper[A] {
lazy val map = baseMap

lazy val parent = from match {
lazy val parent = outerParent match {
case group: Group[Node] => group.toZipper
case _ => error("No zipper context available")
}

override val hasValidContext = from.isInstanceOf[Group[Node]]
override val hasValidContext = outerParent.isInstanceOf[Group[Node]]
}
}
}
Expand Down

0 comments on commit 2d184ea

Please sign in to comment.