src/Tools/jEdit/src/proofdocument/session.scala
author wenzelm
Fri, 18 Dec 2009 21:46:29 +0100
changeset 34795 c97335b7e8c3
parent 34792 65130daf2883
child 34799 0330a4284a9b
permissions -rw-r--r--
cache results;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
     1
/*
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
     2
 * Isabelle session, potentially with running prover
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
     3
 *
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
     4
 * @author Makarius
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
     5
 */
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
     6
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
     7
package isabelle.proofdocument
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
     8
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
     9
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    10
import scala.actors.Actor._
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    11
34791
b97d5b38dea4 explicit object Session.Global_Settings;
wenzelm
parents: 34780
diff changeset
    12
object Session
b97d5b38dea4 explicit object Session.Global_Settings;
wenzelm
parents: 34780
diff changeset
    13
{
b97d5b38dea4 explicit object Session.Global_Settings;
wenzelm
parents: 34780
diff changeset
    14
  case object Global_Settings
b97d5b38dea4 explicit object Session.Global_Settings;
wenzelm
parents: 34780
diff changeset
    15
}
b97d5b38dea4 explicit object Session.Global_Settings;
wenzelm
parents: 34780
diff changeset
    16
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    17
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    18
class Session(system: Isabelle_System)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    19
{
34778
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
    20
  /* unique ids */
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
    21
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
    22
  private var id_count: BigInt = 0
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
    23
  def create_id(): String = synchronized { id_count += 1; "j" + id_count }
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
    24
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
    25
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    26
  /* main actor */
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    27
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34778
diff changeset
    28
  private case class Start(args: List[String])
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    29
  private case object Stop
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    30
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    31
  private var prover: Isabelle_Process with Isar_Document = null
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    32
  private var prover_ready = false
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    33
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    34
  private val session_actor = actor {
34795
c97335b7e8c3 cache results;
wenzelm
parents: 34792
diff changeset
    35
    val xml_cache = new XML.Cache(131071)
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    36
    loop {
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    37
      react {
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34778
diff changeset
    38
        case Start(args) =>
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    39
          if (prover == null) {
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34778
diff changeset
    40
            prover = new Isabelle_Process(system, self, args:_*) with Isar_Document
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    41
            reply(())
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    42
          }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    43
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    44
        case Stop =>
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    45
          if (prover != null)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    46
            prover.kill
34778
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
    47
          prover_ready = false
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    48
          
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    49
        case change: Change if prover_ready =>
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    50
          handle_change(change)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    51
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    52
        case result: Isabelle_Process.Result =>
34795
c97335b7e8c3 cache results;
wenzelm
parents: 34792
diff changeset
    53
          handle_result(result.cache(xml_cache))
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    54
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    55
        case bad if prover_ready =>
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    56
          System.err.println("session_actor: ignoring bad message " + bad)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    57
      }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    58
    }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    59
  }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    60
34780
d0ff1c3a91ea more serious command line handling;
wenzelm
parents: 34778
diff changeset
    61
  def start(args: List[String]) { session_actor !? Start(args) }
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    62
  def stop() { session_actor ! Stop }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    63
  def input(change: Change) { session_actor ! change }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    64
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    65
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    66
  /* pervasive event buses */
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    67
34791
b97d5b38dea4 explicit object Session.Global_Settings;
wenzelm
parents: 34780
diff changeset
    68
  val global_settings = new Event_Bus[Session.Global_Settings.type]
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    69
  val raw_results = new Event_Bus[Isabelle_Process.Result]
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    70
  val results = new Event_Bus[Command]
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    71
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    72
  val command_change = new Event_Bus[Command]
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    73
  val document_change = new Event_Bus[Proof_Document]
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    74
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    75
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    76
  /* selected state */  // FIXME!? races!?
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    77
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    78
  private var _selected_state: Command = null
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    79
  def selected_state = _selected_state
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    80
  def selected_state_=(state: Command) { _selected_state = state; results.event(state) }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    81
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    82
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    83
  /* outer syntax keywords and completion */
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    84
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    85
  @volatile private var _command_decls = Map[String, String]()
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    86
  def command_decls() = _command_decls
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    87
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    88
  @volatile private var _keyword_decls = Set[String]()
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    89
  def keyword_decls() = _keyword_decls
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    90
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    91
  @volatile private var _completion = new Completion + system.symbols
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    92
  def completion() = _completion
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    93
34778
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
    94
  def is_command_keyword(s: String): Boolean = command_decls().contains(s)
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
    95
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    96
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    97
  /* document state information */
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    98
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
    99
  @volatile private var states = Map[Isar_Document.State_ID, Command_State]()
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   100
  @volatile private var commands = Map[Isar_Document.Command_ID, Command]()
34778
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
   101
  val document_0 = Proof_Document.empty(create_id())  // FIXME fresh id (!??)
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   102
  @volatile private var document_versions = List(document_0)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   103
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   104
  def command(id: Isar_Document.Command_ID): Option[Command] = commands.get(id)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   105
  def document(id: Isar_Document.Document_ID): Option[Proof_Document] =
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   106
    document_versions.find(_.id == id)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   107
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   108
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   109
  /* document changes */
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   110
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   111
  def begin_document(path: String)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   112
  {
34778
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
   113
    prover.begin_document(document_0.id, path)   // FIXME fresh document!?!
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   114
  }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   115
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   116
  def handle_change(change: Change)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   117
  {
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   118
    val old = document(change.parent.get.id).get
34778
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
   119
    val (doc, changes) = old.text_changed(this, change)
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   120
    document_versions ::= doc
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   121
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   122
    val id_changes = changes map {
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   123
      case (c1, c2) =>
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   124
        (c1.map(_.id).getOrElse(document_0.id),
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   125
         c2 match {
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   126
            case None => None
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   127
            case Some(command) =>
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   128
              commands += (command.id -> command)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   129
              prover.define_command(command.id, system.symbols.encode(command.content))
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   130
              Some(command.id)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   131
          })
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   132
    }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   133
    prover.edit_document(old.id, doc.id, id_changes)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   134
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   135
    document_change.event(doc)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   136
  }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   137
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   138
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   139
  /* prover results */
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   140
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   141
  private def handle_result(result: Isabelle_Process.Result)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   142
  {
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   143
    raw_results.event(result)
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   144
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   145
    val state =
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   146
      Position.id_of(result.props) match {
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   147
        case None => None
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   148
        case Some(id) => commands.get(id) orElse states.get(id) orElse None
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   149
      }
34792
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   150
    if (state.isDefined) state.get ! (this, result.message)
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   151
    else if (result.kind == Isabelle_Process.Kind.STATUS) {
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   152
      //{{{ global status message
34792
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   153
      for (elem <- result.body) {
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   154
        elem match {
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   155
          // document edits
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   156
          case XML.Elem(Markup.EDITS, (Markup.ID, doc_id) :: _, edits) =>
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   157
            document_versions.find(_.id == doc_id) match {
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   158
              case Some(doc) =>
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   159
                for {
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   160
                  XML.Elem(Markup.EDIT, (Markup.ID, cmd_id) :: (Markup.STATE, state_id) :: _, _)
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   161
                  <- edits }
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   162
                {
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   163
                  commands.get(cmd_id) match {
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   164
                    case Some(cmd) =>
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   165
                      val state = new Command_State(cmd)
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   166
                      states += (state_id -> state)
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   167
                      doc.states += (cmd -> state)
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   168
                      command_change.event(cmd)   // FIXME really!?
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   169
                    case None =>
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   170
                  }
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   171
                }
34792
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   172
              case None =>
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   173
            }
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   174
34792
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   175
          // command and keyword declarations
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   176
          case XML.Elem(Markup.COMMAND_DECL, (Markup.NAME, name) :: (Markup.KIND, kind) :: _, _) =>
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   177
            _command_decls += (name -> kind)
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   178
            _completion += name
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   179
          case XML.Elem(Markup.KEYWORD_DECL, (Markup.NAME, name) :: _, _) =>
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   180
            _keyword_decls += name
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   181
            _completion += name
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   182
34792
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   183
          // process ready (after initialization)
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   184
          case XML.Elem(Markup.READY, _, _) => prover_ready = true
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   185
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   186
        case _ =>
34792
65130daf2883 simplified Isabelle_Process.Result;
wenzelm
parents: 34791
diff changeset
   187
        }
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   188
      }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   189
      //}}}
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   190
    }
34778
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
   191
    else if (result.kind == Isabelle_Process.Kind.EXIT)
8eccd35e975e removed unused Session.prover_logic;
wenzelm
parents: 34777
diff changeset
   192
      prover = null
34777
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   193
  }
91d6089cef88 class Session models full session, with or without prover process (cf. heaps, browser_info);
wenzelm
parents:
diff changeset
   194
}