src/Pure/PIDE/protocol.scala
changeset 69849 09f200c658ed
parent 69846 e02e3763e7a4
child 70284 3e17c3a5fd39
equal deleted inserted replaced
69848:bf2cd27714fb 69849:09f200c658ed
   281   /* document versions */
   281   /* document versions */
   282 
   282 
   283   def update(old_id: Document_ID.Version, new_id: Document_ID.Version,
   283   def update(old_id: Document_ID.Version, new_id: Document_ID.Version,
   284     edits: List[Document.Edit_Command], consolidate: List[Document.Node.Name])
   284     edits: List[Document.Edit_Command], consolidate: List[Document.Node.Name])
   285   {
   285   {
       
   286     val consolidate_yxml =
       
   287     {
       
   288       import XML.Encode._
       
   289       Symbol.encode_yxml(list(string)(consolidate.map(_.node)))
       
   290     }
   286     val edits_yxml =
   291     val edits_yxml =
   287     {
   292     {
   288       import XML.Encode._
   293       import XML.Encode._
   289       def id: T[Command] = (cmd => long(cmd.id))
   294       def id: T[Command] = (cmd => long(cmd.id))
   290       def encode_edit(name: Document.Node.Name)
   295       def encode_edit(name: Document.Node.Name)
   301                     pair(pair(string, list(string)), list(string)))), list(string)))))(
   306                     pair(pair(string, list(string)), list(string)))), list(string)))))(
   302                 (master_dir, (name.theory, (imports, (keywords, header.errors)))))) },
   307                 (master_dir, (name.theory, (imports, (keywords, header.errors)))))) },
   303           { case Document.Node.Perspective(a, b, c) =>
   308           { case Document.Node.Perspective(a, b, c) =>
   304               (bool_atom(a) :: b.commands.map(cmd => long_atom(cmd.id)),
   309               (bool_atom(a) :: b.commands.map(cmd => long_atom(cmd.id)),
   305                 list(pair(id, pair(string, list(string))))(c.dest)) }))
   310                 list(pair(id, pair(string, list(string))))(c.dest)) }))
   306       def encode_edits: T[List[Document.Edit_Command]] = list((node_edit: Document.Edit_Command) =>
   311       edits.map({ case (name, edit) =>
   307       {
   312         Symbol.encode_yxml(pair(string, encode_edit(name))(name.node, edit)) })
   308         val (name, edit) = node_edit
   313     }
   309         pair(string, encode_edit(name))(name.node, edit)
   314     protocol_command("Document.update",
   310       })
   315       (Document_ID(old_id) :: Document_ID(new_id) :: consolidate_yxml :: edits_yxml): _*)
   311       Symbol.encode_yxml(encode_edits(edits))
       
   312     }
       
   313 
       
   314     val consolidate_yxml =
       
   315     {
       
   316       import XML.Encode._
       
   317       Symbol.encode_yxml(list(string)(consolidate.map(_.node)))
       
   318     }
       
   319 
       
   320     protocol_command(
       
   321       "Document.update", Document_ID(old_id), Document_ID(new_id), edits_yxml, consolidate_yxml)
       
   322   }
   316   }
   323 
   317 
   324   def remove_versions(versions: List[Document.Version])
   318   def remove_versions(versions: List[Document.Version])
   325   {
   319   {
   326     val versions_yxml =
   320     val versions_yxml =