src/Pure/System/session.scala
changeset 44442 cb18e4f09053
parent 44436 546adfa8a6fc
child 44446 f9334afb6945
equal deleted inserted replaced
44441:fe95e4306b4b 44442:cb18e4f09053
   156       (text, header)
   156       (text, header)
   157     }
   157     }
   158   }
   158   }
   159 
   159 
   160   val thy_info = new Thy_Info(thy_load)
   160   val thy_info = new Thy_Info(thy_load)
       
   161 
       
   162   def header_edit(name: String, master_dir: String,
       
   163     header: Document.Node_Header): Document.Edit_Text =
       
   164   {
       
   165     def norm_import(s: String): String =
       
   166     {
       
   167       val thy_name = Thy_Header.base_name(s)
       
   168       if (thy_load.is_loaded(thy_name)) thy_name
       
   169       else file_store.append(master_dir, Thy_Header.thy_path(Path.explode(s)))
       
   170     }
       
   171     def norm_use(s: String): String =
       
   172       file_store.append(master_dir, Path.explode(s))
       
   173 
       
   174     val header1: Document.Node_Header =
       
   175       header match {
       
   176         case Exn.Res(Thy_Header(thy_name, _, _))
       
   177         if (thy_load.is_loaded(thy_name)) =>
       
   178           Exn.Exn(ERROR("Attempt to update loaded theory " + quote(thy_name)))
       
   179         case _ => Document.Node.norm_header(norm_import, norm_use, header)
       
   180       }
       
   181     (name, Document.Node.Header(header1))
       
   182   }
   161 
   183 
   162 
   184 
   163   /* actor messages */
   185   /* actor messages */
   164 
   186 
   165   private case class Start(timeout: Time, args: List[String])
   187   private case class Start(timeout: Time, args: List[String])
   208     //{{{
   230     //{{{
   209     {
   231     {
   210       val syntax = current_syntax()
   232       val syntax = current_syntax()
   211       val previous = global_state().history.tip.version
   233       val previous = global_state().history.tip.version
   212 
   234 
   213       def norm_import(s: String): String =
   235       val text_edits = header_edit(name, master_dir, header) :: edits.map(edit => (name, edit))
   214       {
       
   215         val name = Thy_Header.base_name(s)
       
   216         if (thy_load.is_loaded(name)) name
       
   217         else file_store.append(master_dir, Thy_Header.thy_path(Path.explode(s)))
       
   218       }
       
   219       def norm_use(s: String): String = file_store.append(master_dir, Path.explode(s))
       
   220       val norm_header =
       
   221         Document.Node.norm_header[Text.Edit, Text.Perspective](norm_import, norm_use, header)
       
   222 
       
   223       val text_edits = (name, norm_header) :: edits.map(edit => (name, edit))
       
   224       val result = Future.fork { Thy_Syntax.text_edits(syntax, previous.join, text_edits) }
   236       val result = Future.fork { Thy_Syntax.text_edits(syntax, previous.join, text_edits) }
   225       val change =
   237       val change =
   226         global_state.change_yield(_.extend_history(previous, text_edits, result.map(_._2)))
   238         global_state.change_yield(_.extend_history(previous, text_edits, result.map(_._2)))
   227 
   239 
   228       result.map {
   240       result.map {