src/Tools/jEdit/src/prover/Prover.scala
author wenzelm
Mon, 29 Dec 2008 17:44:58 +0100
changeset 34453 dfa99a91951b
parent 34452 eea0eae5f773
child 34454 feeab430c3eb
permissions -rw-r--r--
eliminated hardwired string constants; removed unused allInfo; replaced workerThread by EventBus handler (cf. Isar process results); unified handle_result function, slightly more general/robust patterns; use existing Isar.create_command etc.; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34407
aad6834ba380 added some headers and comments;
wenzelm
parents: 34404
diff changeset
     1
/*
aad6834ba380 added some headers and comments;
wenzelm
parents: 34404
diff changeset
     2
 * Higher-level prover communication
aad6834ba380 added some headers and comments;
wenzelm
parents: 34404
diff changeset
     3
 *
aad6834ba380 added some headers and comments;
wenzelm
parents: 34404
diff changeset
     4
 * @author Johannes Hölzl, TU Munich
aad6834ba380 added some headers and comments;
wenzelm
parents: 34404
diff changeset
     5
 * @author Fabian Immler, TU Munich
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
     6
 * @author Makarius
34407
aad6834ba380 added some headers and comments;
wenzelm
parents: 34404
diff changeset
     7
 */
aad6834ba380 added some headers and comments;
wenzelm
parents: 34404
diff changeset
     8
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
     9
package isabelle.prover
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    10
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    11
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    12
import java.util.Properties
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    13
import javax.swing.SwingUtilities
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    14
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    15
import scala.collection.mutable.{HashMap, HashSet}
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    16
34443
f2e13329cc49 dynamic instances Isabelle.system, Isabelle.symbols;
wenzelm
parents: 34410
diff changeset
    17
import isabelle.proofdocument.{ProofDocument, Text, Token}
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    18
import isabelle.{Symbol, IsabelleSyntax}
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    19
import isabelle.utils.EventSource
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    20
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    21
import Command.Phase
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    22
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    23
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    24
class Prover(isabelle_system: IsabelleSystem, isabelle_symbols: Symbol.Interpretation)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    25
{
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    26
  private var _logic = isabelle_system.getenv_strict("ISABELLE_LOGIC")
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    27
  private var process: Isar = null
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    28
  private var commands = new HashMap[String, Command]
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    29
34399
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34397
diff changeset
    30
  val command_decls = new HashSet[String]
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34397
diff changeset
    31
  val keyword_decls = new HashSet[String]
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    32
  private var initialized = false
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    33
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    34
  val activated = new EventSource[Unit]
34452
eea0eae5f773 removed redundant CommandChangeInfo;
wenzelm
parents: 34451
diff changeset
    35
  val commandInfo = new EventSource[Command]
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    36
  val outputInfo = new EventSource[String]
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    37
  var document: Document = null
34399
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34397
diff changeset
    38
34444
a245f6cc3105 replaced inUIThread by scala-style swing/swing_async combinators;
wenzelm
parents: 34443
diff changeset
    39
a245f6cc3105 replaced inUIThread by scala-style swing/swing_async combinators;
wenzelm
parents: 34443
diff changeset
    40
  def swing(body: => Unit) =
a245f6cc3105 replaced inUIThread by scala-style swing/swing_async combinators;
wenzelm
parents: 34443
diff changeset
    41
    SwingUtilities.invokeAndWait(new Runnable { def run = body })
a245f6cc3105 replaced inUIThread by scala-style swing/swing_async combinators;
wenzelm
parents: 34443
diff changeset
    42
a245f6cc3105 replaced inUIThread by scala-style swing/swing_async combinators;
wenzelm
parents: 34443
diff changeset
    43
  def swing_async(body: => Unit) =
a245f6cc3105 replaced inUIThread by scala-style swing/swing_async combinators;
wenzelm
parents: 34443
diff changeset
    44
    SwingUtilities.invokeLater(new Runnable { def run = body })
a245f6cc3105 replaced inUIThread by scala-style swing/swing_async combinators;
wenzelm
parents: 34443
diff changeset
    45
a245f6cc3105 replaced inUIThread by scala-style swing/swing_async combinators;
wenzelm
parents: 34443
diff changeset
    46
34452
eea0eae5f773 removed redundant CommandChangeInfo;
wenzelm
parents: 34451
diff changeset
    47
  def fireChange(c: Command) = swing { commandInfo.fire(c) }
34399
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34397
diff changeset
    48
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    49
  private def handle_result(r: IsabelleProcess.Result) = {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    50
    val id = if (r.props != null) r.props.getProperty(Markup.ID) else null
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    51
    val st = if (id != null) commands.getOrElse(id, null) else null
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    52
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    53
    if (r.kind == IsabelleProcess.Kind.STDOUT || r.kind == IsabelleProcess.Kind.STDIN)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    54
      swing { outputInfo.fire(r.result) }
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    55
    else if (r.kind == IsabelleProcess.Kind.WRITELN && !initialized) {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    56
      initialized = true
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    57
      swing {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    58
        if (document != null) {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    59
          document.activate()
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    60
          activated.fire(())
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
    61
        }
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    62
      }
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    63
    }
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    64
    else {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    65
      val tree = YXML.parse_failsafe(isabelle_symbols.decode(r.result))
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    66
      if (st == null || (st.phase != Phase.REMOVED && st.phase != Phase.REMOVE)) {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    67
        r.kind match {
34404
98155c35d252 delayed repainting new phase in buffer and overview;
immler@in.tum.de
parents: 34401
diff changeset
    68
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    69
          case IsabelleProcess.Kind.STATUS =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    70
            //{{{ handle all kinds of status messages here
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    71
            System.err.println(tree)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    72
            tree match {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    73
              case XML.Elem(Markup.MESSAGE, _, elems) =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    74
                for (elem <- elems) {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    75
                  elem match {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    76
                    //{{{
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    77
                    // command status
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    78
                    case XML.Elem(Markup.FINISHED, _, _) =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    79
                      st.phase = Phase.FINISHED
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    80
                      fireChange(st)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    81
                    case XML.Elem(Markup.UNPROCESSED, _, _) =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    82
                      st.phase = Phase.UNPROCESSED
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    83
                      fireChange(st)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    84
                    case XML.Elem(Markup.FAILED, _, _) =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    85
                      st.phase = Phase.FAILED
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    86
                      fireChange(st)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    87
                    case XML.Elem(Markup.DISPOSED, _, _) =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    88
                      document.prover.commands.removeKey(st.id)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    89
                      st.phase = Phase.REMOVED
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    90
                      fireChange(st)
34399
5b8b89b7e597 interpretation of STATUS messages in one place, deleting inner syntax
immler@in.tum.de
parents: 34397
diff changeset
    91
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    92
                    // command and keyword declarations
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    93
                    case XML.Elem(Markup.COMMAND_DECL, List((Markup.NAME, name), (Markup.KIND, _)), _) =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    94
                      command_decls.addEntry(name)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    95
                    case XML.Elem(Markup.KEYWORD_DECL, List((Markup.NAME, name)), _) =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    96
                      keyword_decls.addEntry(name)
34404
98155c35d252 delayed repainting new phase in buffer and overview;
immler@in.tum.de
parents: 34401
diff changeset
    97
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    98
                    // other markup
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
    99
                    case XML.Elem(kind,
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   100
                        (Markup.OFFSET, offset) :: (Markup.END_OFFSET, end_offset) ::
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   101
                             (Markup.ID, markup_id) :: _, _) =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   102
                      val begin = Int.unbox(java.lang.Integer.valueOf(offset)) - 1
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   103
                      val end = Int.unbox(java.lang.Integer.valueOf(end_offset)) - 1
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   104
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   105
                      val command =
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   106
                        // outer syntax: no id in props
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   107
                        if (st == null) commands.getOrElse(markup_id, null)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   108
                        // inner syntax: id from props
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   109
                        else st
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   110
                      command.root_node.insert(command.node_from(kind, begin, end))
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   111
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   112
                    case _ =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   113
                    //}}}
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   114
                  }
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   115
                }
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   116
              case _ =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   117
            }
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   118
            //}}}
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   119
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   120
          case IsabelleProcess.Kind.ERROR if st != null =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   121
            if (st.phase != Phase.REMOVED && st.phase != Phase.REMOVE)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   122
              st.phase = Phase.FAILED
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   123
            st.add_result(tree)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   124
            fireChange(st)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   125
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   126
          case IsabelleProcess.Kind.WRITELN | IsabelleProcess.Kind.PRIORITY
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   127
            | IsabelleProcess.Kind.WARNING if st != null =>
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   128
            st.add_result(tree)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   129
            fireChange(st)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   130
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   131
          case _ =>
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   132
        }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   133
      }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   134
    }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   135
  }
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   136
34370
e0679b361a0e register to buffer all messages
immler@in.tum.de
parents: 34359
diff changeset
   137
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   138
  def start(logic: String) {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   139
    val results = new EventBus[IsabelleProcess.Result] + handle_result
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   140
    if (logic != null) _logic = logic
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   141
    process = new Isar(isabelle_system, results, "-m", "xsymbols", _logic)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   142
  }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   143
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   144
  def stop() {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   145
    process.kill
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   146
  }
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   147
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   148
  def setDocument(text: Text, path: String) {
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   149
    this.document = new Document(text, this)
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   150
    process.ML("ThyLoad.add_path " + IsabelleSyntax.encode_string(path))
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   151
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   152
    document.structuralChanges.add(changes => {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   153
      for (cmd <- changes.removedCommands) remove(cmd)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   154
      for (cmd <- changes.addedCommands) send(cmd)
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   155
    })
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   156
    if (initialized) {
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   157
      document.activate()
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   158
      activated.fire(())
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   159
    }
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   160
  }
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   161
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   162
  private def send(cmd: Command) {
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   163
    cmd.phase = Phase.UNPROCESSED
34451
3b9d0074ed44 command id via Isabelle.plugin;
wenzelm
parents: 34444
diff changeset
   164
    commands.put(cmd.id, cmd)
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   165
34451
3b9d0074ed44 command id via Isabelle.plugin;
wenzelm
parents: 34444
diff changeset
   166
    val props = new Properties
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   167
    props.setProperty(Markup.ID, cmd.id)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   168
    props.setProperty(Markup.OFFSET, "1")
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   169
34443
f2e13329cc49 dynamic instances Isabelle.system, Isabelle.symbols;
wenzelm
parents: 34410
diff changeset
   170
    val content = isabelle_symbols.encode(document.getContent(cmd))
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   171
    process.create_command(props, content)
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   172
    process.insert_command(if (cmd.previous == null) "" else cmd.previous.id, cmd.id)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   173
  }
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   174
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   175
  def remove(cmd: Command) {
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   176
    cmd.phase = Phase.REMOVE
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   177
    process.remove_command(cmd.id)
34318
c13e168a8ae6 original sources from Johannes Hölzl a48e0c6ab1aea77c52d596f7efc007a543d3d10c with minor modifications of directory layout;
wenzelm
parents:
diff changeset
   178
  }
34453
dfa99a91951b eliminated hardwired string constants;
wenzelm
parents: 34452
diff changeset
   179
}