src/Pure/System/session.scala
changeset 44157 a21d3e1e64fd
parent 44156 6aa25b80e1a5
child 44159 9a35e88d9dc9
equal deleted inserted replaced
44156:6aa25b80e1a5 44157:a21d3e1e64fd
   166   private case class Init_Node(name: String, header: Document.Node.Header, text: String)
   166   private case class Init_Node(name: String, header: Document.Node.Header, text: String)
   167   private case class Edit_Node(name: String, header: Document.Node.Header, edits: List[Text.Edit])
   167   private case class Edit_Node(name: String, header: Document.Node.Header, edits: List[Text.Edit])
   168   private case class Change_Node(
   168   private case class Change_Node(
   169     name: String,
   169     name: String,
   170     doc_edits: List[Document.Edit_Command],
   170     doc_edits: List[Document.Edit_Command],
   171     header_edits: List[(String, Thy_Header.Header)],
       
   172     previous: Document.Version,
   171     previous: Document.Version,
   173     version: Document.Version)
   172     version: Document.Version)
   174 
   173 
   175   private val (_, session_actor) = Simple_Thread.actor("session_actor", daemon = true)
   174   private val (_, session_actor) = Simple_Thread.actor("session_actor", daemon = true)
   176   {
   175   {
   184         header: Document.Node.Header, edits: List[Document.Node.Edit[Text.Edit]])
   183         header: Document.Node.Header, edits: List[Document.Node.Edit[Text.Edit]])
   185     //{{{
   184     //{{{
   186     {
   185     {
   187       val syntax = current_syntax()
   186       val syntax = current_syntax()
   188       val previous = global_state().history.tip.version
   187       val previous = global_state().history.tip.version
   189       val doc_edits = edits.map(edit => (name, edit))
   188       val doc_edits =
   190       val result = Future.fork {
   189         (name, Document.Node.Update_Header[Text.Edit](header)) :: edits.map(edit => (name, edit))
   191         Thy_Syntax.text_edits(syntax, previous.join, doc_edits, List((name, header)))
   190       val result = Future.fork { Thy_Syntax.text_edits(syntax, previous.join, doc_edits) }
   192       }
       
   193       val change =
   191       val change =
   194         global_state.change_yield(_.extend_history(previous, doc_edits, result.map(_._3)))
   192         global_state.change_yield(_.extend_history(previous, doc_edits, result.map(_._2)))
   195 
   193 
   196       result.map {
   194       result.map {
   197         case (doc_edits, header_edits, _) =>
   195         case (doc_edits, _) =>
   198           assignments.await { global_state().is_assigned(previous.get_finished) }
   196           assignments.await { global_state().is_assigned(previous.get_finished) }
   199           this_actor !
   197           this_actor ! Change_Node(name, doc_edits, previous.join, change.version.join)
   200             Change_Node(name, doc_edits, header_edits, previous.join, change.version.join)
       
   201       }
   198       }
   202     }
   199     }
   203     //}}}
   200     //}}}
   204 
   201 
   205 
   202 
   210     {
   207     {
   211       val previous = change.previous
   208       val previous = change.previous
   212       val version = change.version
   209       val version = change.version
   213       val name = change.name
   210       val name = change.name
   214       val doc_edits = change.doc_edits
   211       val doc_edits = change.doc_edits
   215       val header_edits = change.header_edits
       
   216 
   212 
   217       var former_assignment = global_state().the_assignment(previous).get_finished
   213       var former_assignment = global_state().the_assignment(previous).get_finished
   218       for {
   214       for {
   219         (name, Document.Node.Edits(cmd_edits)) <- doc_edits  // FIXME proper coverage!?
   215         (name, Document.Node.Edits(cmd_edits)) <- doc_edits  // FIXME proper coverage!?
   220         (prev, None) <- cmd_edits
   216         (prev, None) <- cmd_edits
   234           case (name, edit) =>
   230           case (name, edit) =>
   235             (name, edit.map({ case (c1, c2) => (c1.map(id_command), c2.map(id_command)) }))
   231             (name, edit.map({ case (c1, c2) => (c1.map(id_command), c2.map(id_command)) }))
   236         }
   232         }
   237 
   233 
   238       global_state.change(_.define_version(version, former_assignment))
   234       global_state.change(_.define_version(version, former_assignment))
   239       prover.get.edit_version(previous.id, version.id, id_edits, header_edits)
   235       prover.get.edit_version(previous.id, version.id, id_edits)
   240     }
   236     }
   241     //}}}
   237     //}}}
   242 
   238 
   243 
   239 
   244     /* prover results */
   240     /* prover results */