29 |
29 |
30 /** document structure **/ |
30 /** document structure **/ |
31 |
31 |
32 /* named nodes -- development graph */ |
32 /* named nodes -- development graph */ |
33 |
33 |
34 type Edit[A] = |
34 type Edit[A] = (String, Node.Edit[A]) |
35 (String, // node name |
|
36 Option[List[A]]) // None: remove node, Some: edit content |
|
37 |
|
38 type Edit_Text = Edit[Text.Edit] |
35 type Edit_Text = Edit[Text.Edit] |
39 type Edit_Command = Edit[(Option[Command], Option[Command])] |
36 type Edit_Command = Edit[(Option[Command], Option[Command])] |
40 type Edit_Command_ID = Edit[(Option[Command_ID], Option[Command_ID])] |
37 type Edit_Command_ID = Edit[(Option[Command_ID], Option[Command_ID])] |
41 |
38 |
42 object Node |
39 object Node |
43 { |
40 { |
|
41 sealed abstract class Edit[A] |
|
42 { |
|
43 def map[B](f: A => B): Edit[B] = |
|
44 this match { |
|
45 case Remove() => Remove() |
|
46 case Edits(es) => Edits(es.map(f)) |
|
47 } |
|
48 } |
|
49 case class Remove[A]() extends Edit[A] |
|
50 case class Edits[A](edits: List[A]) extends Edit[A] |
|
51 |
44 sealed case class Header(val master_dir: Path, val thy_header: Exn.Result[Thy_Header.Header]) |
52 sealed case class Header(val master_dir: Path, val thy_header: Exn.Result[Thy_Header.Header]) |
45 val empty_header = Header(Path.current, Exn.Exn(ERROR("Bad theory header"))) |
53 val empty_header = Header(Path.current, Exn.Exn(ERROR("Bad theory header"))) |
46 |
54 |
47 val empty: Node = Node(empty_header, Map(), Linear_Set()) |
55 val empty: Node = Node(empty_header, Map(), Linear_Set()) |
48 |
56 |
288 change.is_finished && is_assigned(change.version.get_finished)) |
296 change.is_finished && is_assigned(change.version.get_finished)) |
289 require(found_stable.isDefined) |
297 require(found_stable.isDefined) |
290 val stable = found_stable.get |
298 val stable = found_stable.get |
291 val latest = history.undo_list.head |
299 val latest = history.undo_list.head |
292 |
300 |
293 // FIXME proper treatment of deleted nodes |
301 // FIXME proper treatment of removed nodes |
294 val edits = |
302 val edits = |
295 (pending_edits /: history.undo_list.takeWhile(_ != stable))((edits, change) => |
303 (pending_edits /: history.undo_list.takeWhile(_ != stable))((edits, change) => |
296 (for ((a, Some(eds)) <- change.edits if a == name) yield eds).flatten ::: edits) |
304 (for ((a, Node.Edits(es)) <- change.edits if a == name) yield es).flatten ::: edits) |
297 lazy val reverse_edits = edits.reverse |
305 lazy val reverse_edits = edits.reverse |
298 |
306 |
299 new Snapshot |
307 new Snapshot |
300 { |
308 { |
301 val version = stable.version.get_finished |
309 val version = stable.version.get_finished |