src/Pure/PIDE/headless.scala
changeset 70649 9a40720750dc
parent 70648 60cb2bfea2d2
child 70653 f7c5b30fc432
equal deleted inserted replaced
70648:60cb2bfea2d2 70649:9a40720750dc
   424       {
   424       {
   425         require(remove.forall(name => !is_required(name)))
   425         require(remove.forall(name => !is_required(name)))
   426         copy(theories = theories -- remove)
   426         copy(theories = theories -- remove)
   427       }
   427       }
   428 
   428 
   429       def unload_theories(session: Session, id: UUID.T, dep_theories: List[Document.Node.Name])
   429       def unload_theories(session: Session, id: UUID.T, theories: List[Document.Node.Name])
   430         : State =
   430         : State =
   431       {
   431       {
   432         val st1 = remove_required(id, dep_theories)
   432         val st1 = remove_required(id, theories)
   433         val theory_edits =
   433         val theory_edits =
   434           for {
   434           for {
   435             node_name <- dep_theories
   435             node_name <- theories
   436             theory <- st1.theories.get(node_name)
   436             theory <- st1.theories.get(node_name)
   437           }
   437           }
   438           yield {
   438           yield {
   439             val theory1 = theory.required(st1.is_required(node_name))
   439             val theory1 = theory.required(st1.is_required(node_name))
   440             val edits = theory1.node_edits(Some(theory))
   440             val edits = theory1.node_edits(Some(theory))
   524     private val state = Synchronized(Resources.State())
   524     private val state = Synchronized(Resources.State())
   525 
   525 
   526     def load_theories(
   526     def load_theories(
   527       session: Session,
   527       session: Session,
   528       id: UUID.T,
   528       id: UUID.T,
   529       dep_theories: List[Document.Node.Name],
   529       theories: List[Document.Node.Name],
   530       dep_files: List[Document.Node.Name],
   530       files: List[Document.Node.Name],
   531       unicode_symbols: Boolean,
   531       unicode_symbols: Boolean,
   532       share_common_data: Boolean,
   532       share_common_data: Boolean,
   533       progress: Progress)
   533       progress: Progress)
   534     {
   534     {
   535       val loaded_theories =
   535       val loaded_theories =
   536         for (node_name <- dep_theories)
   536         for (node_name <- theories)
   537         yield {
   537         yield {
   538           val path = node_name.path
   538           val path = node_name.path
   539           if (!node_name.is_theory) error("Not a theory file: " + path)
   539           if (!node_name.is_theory) error("Not a theory file: " + path)
   540 
   540 
   541           progress.expose_interrupt()
   541           progress.expose_interrupt()
   548       val loaded = loaded_theories.length
   548       val loaded = loaded_theories.length
   549       if (loaded > 1) progress.echo("Loading " + loaded + " theories ...")
   549       if (loaded > 1) progress.echo("Loading " + loaded + " theories ...")
   550 
   550 
   551       state.change(st =>
   551       state.change(st =>
   552         {
   552         {
   553           val (doc_blobs1, st1) = st.insert_required(id, dep_theories).update_blobs(dep_files)
   553           val (doc_blobs1, st1) = st.insert_required(id, theories).update_blobs(files)
   554           val theory_edits =
   554           val theory_edits =
   555             for (theory <- loaded_theories)
   555             for (theory <- loaded_theories)
   556             yield {
   556             yield {
   557               val node_name = theory.node_name
   557               val node_name = theory.node_name
   558               val theory1 = theory.required(st1.is_required(node_name))
   558               val theory1 = theory.required(st1.is_required(node_name))
   559               val edits = theory1.node_edits(st1.theories.get(node_name))
   559               val edits = theory1.node_edits(st1.theories.get(node_name))
   560               (edits, (node_name, theory1))
   560               (edits, (node_name, theory1))
   561             }
   561             }
   562           val file_edits =
   562           val file_edits =
   563             for { node_name <- dep_files if doc_blobs1.changed(node_name) }
   563             for { node_name <- files if doc_blobs1.changed(node_name) }
   564             yield st1.blob_edits(node_name, st.blobs.get(node_name))
   564             yield st1.blob_edits(node_name, st.blobs.get(node_name))
   565 
   565 
   566           session.update(doc_blobs1, theory_edits.flatMap(_._1) ::: file_edits.flatten,
   566           session.update(doc_blobs1, theory_edits.flatMap(_._1) ::: file_edits.flatten,
   567             share_common_data = share_common_data)
   567             share_common_data = share_common_data)
   568           st1.update_theories(theory_edits.map(_._2))
   568           st1.update_theories(theory_edits.map(_._2))
   569         })
   569         })
   570     }
   570     }
   571 
   571 
   572     def unload_theories(session: Session, id: UUID.T, dep_theories: List[Document.Node.Name])
   572     def unload_theories(session: Session, id: UUID.T, theories: List[Document.Node.Name])
   573     {
   573     {
   574       state.change(_.unload_theories(session, id, dep_theories))
   574       state.change(_.unload_theories(session, id, theories))
   575     }
   575     }
   576 
   576 
   577     def clean_theories(session: Session, id: UUID.T, clean: Set[Document.Node.Name])
   577     def clean_theories(session: Session, id: UUID.T, clean: Set[Document.Node.Name])
   578     {
   578     {
   579       state.change(st =>
   579       state.change(st =>