src/Pure/Thy/export.scala
changeset 77023 474a07221c27
parent 77005 86cc9b0e1b13
child 77026 808412ec2e13
equal deleted inserted replaced
77022:ac5ebdf19861 77023:474a07221c27
   432     }
   432     }
   433 
   433 
   434     def source_file(name: String): Sessions.Source_File =
   434     def source_file(name: String): Sessions.Source_File =
   435       get_source_file(name).getOrElse(error("Missing session source file " + quote(name)))
   435       get_source_file(name).getOrElse(error("Missing session source file " + quote(name)))
   436 
   436 
       
   437     def theory_source(theory: String, unicode_symbols: Boolean = false): String = {
       
   438       def snapshot_source: Option[String] =
       
   439         for {
       
   440           snapshot <- document_snapshot
       
   441           text <- snapshot.version.nodes.iterator.collectFirst(
       
   442             { case (name, node) if name.theory == theory => node.source })
       
   443           if text.nonEmpty
       
   444         } yield Symbol.output(unicode_symbols, text)
       
   445 
       
   446       def db_source: Option[String] = {
       
   447         val theory_context = session_context.theory(theory)
       
   448         for {
       
   449           name <- theory_context.files0(permissive = true).headOption
       
   450           file <- get_source_file(name)
       
   451         } yield {
       
   452           val text0 = file.bytes.text
       
   453           if (unicode_symbols) Symbol.decode(text0) else text0
       
   454         }
       
   455       }
       
   456 
       
   457       snapshot_source orElse db_source getOrElse ""
       
   458     }
       
   459 
   437     def classpath(): List[File.Content] = {
   460     def classpath(): List[File.Content] = {
   438       (for {
   461       (for {
   439         session <- session_stack.iterator
   462         session <- session_stack.iterator
   440         info <- sessions_structure.get(session).iterator
   463         info <- sessions_structure.get(session).iterator
   441         if info.export_classpath.nonEmpty
   464         if info.export_classpath.nonEmpty