src/Pure/PIDE/protocol.scala
author wenzelm
Tue Apr 08 16:07:02 2014 +0200 (2014-04-08)
changeset 56469 ffc94a271633
parent 56468 30128d1acfbc
child 56470 8eda56033203
permissions -rw-r--r--
avoid data redundancy;
wenzelm@45709
     1
/*  Title:      Pure/PIDE/protocol.scala
wenzelm@38412
     2
    Author:     Makarius
wenzelm@38412
     3
wenzelm@45709
     4
Protocol message formats for interactive proof documents.
wenzelm@38412
     5
*/
wenzelm@38412
     6
wenzelm@38412
     7
package isabelle
wenzelm@38412
     8
wenzelm@38412
     9
wenzelm@45709
    10
object Protocol
wenzelm@38412
    11
{
wenzelm@38567
    12
  /* document editing */
wenzelm@38412
    13
wenzelm@52563
    14
  object Assign_Update
wenzelm@44476
    15
  {
wenzelm@52563
    16
    def unapply(text: String): Option[(Document_ID.Version, Document.Assign_Update)] =
wenzelm@44661
    17
      try {
wenzelm@44661
    18
        import XML.Decode._
wenzelm@44661
    19
        val body = YXML.parse_body(text)
wenzelm@52527
    20
        Some(pair(long, list(pair(long, list(long))))(body))
wenzelm@44661
    21
      }
wenzelm@44661
    22
      catch {
wenzelm@44661
    23
        case ERROR(_) => None
wenzelm@51987
    24
        case _: XML.Error => None
wenzelm@38412
    25
      }
wenzelm@38412
    26
  }
wenzelm@38567
    27
wenzelm@44676
    28
  object Removed
wenzelm@44676
    29
  {
wenzelm@52530
    30
    def unapply(text: String): Option[List[Document_ID.Version]] =
wenzelm@44676
    31
      try {
wenzelm@44676
    32
        import XML.Decode._
wenzelm@44676
    33
        Some(list(long)(YXML.parse_body(text)))
wenzelm@44676
    34
      }
wenzelm@44676
    35
      catch {
wenzelm@44676
    36
        case ERROR(_) => None
wenzelm@51987
    37
        case _: XML.Error => None
wenzelm@44676
    38
      }
wenzelm@44676
    39
  }
wenzelm@44676
    40
wenzelm@38567
    41
wenzelm@46209
    42
  /* command status */
wenzelm@38567
    43
wenzelm@56359
    44
  object Status
wenzelm@56359
    45
  {
wenzelm@56359
    46
    def make(markup_iterator: Iterator[Markup]): Status =
wenzelm@56359
    47
    {
wenzelm@56359
    48
      var touched = false
wenzelm@56359
    49
      var accepted = false
wenzelm@56395
    50
      var warned = false
wenzelm@56359
    51
      var failed = false
wenzelm@56359
    52
      var forks = 0
wenzelm@56359
    53
      var runs = 0
wenzelm@56359
    54
      for (markup <- markup_iterator) {
wenzelm@56359
    55
        markup.name match {
wenzelm@56359
    56
          case Markup.ACCEPTED => accepted = true
wenzelm@56359
    57
          case Markup.FORKED => touched = true; forks += 1
wenzelm@56359
    58
          case Markup.JOINED => forks -= 1
wenzelm@56359
    59
          case Markup.RUNNING => touched = true; runs += 1
wenzelm@56359
    60
          case Markup.FINISHED => runs -= 1
wenzelm@56395
    61
          case Markup.WARNING => warned = true
wenzelm@56395
    62
          case Markup.FAILED | Markup.ERROR => failed = true
wenzelm@56359
    63
          case _ =>
wenzelm@56359
    64
        }
wenzelm@56359
    65
      }
wenzelm@56395
    66
      Status(touched, accepted, warned, failed, forks, runs)
wenzelm@56359
    67
    }
wenzelm@56359
    68
wenzelm@56359
    69
    val empty = make(Iterator.empty)
wenzelm@56359
    70
wenzelm@56359
    71
    def merge(status_iterator: Iterator[Status]): Status =
wenzelm@56359
    72
      if (status_iterator.hasNext) {
wenzelm@56359
    73
        val status0 = status_iterator.next
wenzelm@56359
    74
        (status0 /: status_iterator)(_ + _)
wenzelm@56359
    75
      }
wenzelm@56359
    76
      else empty
wenzelm@56359
    77
  }
wenzelm@56359
    78
wenzelm@46166
    79
  sealed case class Status(
wenzelm@56352
    80
    private val touched: Boolean,
wenzelm@56352
    81
    private val accepted: Boolean,
wenzelm@56395
    82
    private val warned: Boolean,
wenzelm@56352
    83
    private val failed: Boolean,
wenzelm@56352
    84
    forks: Int,
wenzelm@56352
    85
    runs: Int)
wenzelm@38567
    86
  {
wenzelm@56359
    87
    def + (that: Status): Status =
wenzelm@56395
    88
      Status(
wenzelm@56395
    89
        touched || that.touched,
wenzelm@56395
    90
        accepted || that.accepted,
wenzelm@56395
    91
        warned || that.warned,
wenzelm@56395
    92
        failed || that.failed,
wenzelm@56395
    93
        forks + that.forks,
wenzelm@56395
    94
        runs + that.runs)
wenzelm@56359
    95
wenzelm@49036
    96
    def is_unprocessed: Boolean = accepted && !failed && (!touched || (forks != 0 && runs == 0))
wenzelm@49036
    97
    def is_running: Boolean = runs != 0
wenzelm@49039
    98
    def is_finished: Boolean = !failed && touched && forks == 0 && runs == 0
wenzelm@56395
    99
    def is_warned: Boolean = is_finished && warned
wenzelm@49036
   100
    def is_failed: Boolean = failed
wenzelm@46166
   101
  }
wenzelm@46166
   102
wenzelm@56395
   103
  val proper_status_elements =
wenzelm@55820
   104
    Document.Elements(Markup.ACCEPTED, Markup.FORKED, Markup.JOINED, Markup.RUNNING,
wenzelm@55646
   105
      Markup.FINISHED, Markup.FAILED)
wenzelm@55646
   106
wenzelm@56395
   107
  val liberal_status_elements =
wenzelm@56395
   108
    proper_status_elements + Markup.WARNING + Markup.ERROR
wenzelm@55646
   109
wenzelm@46209
   110
wenzelm@51818
   111
  /* command timing */
wenzelm@51818
   112
wenzelm@51818
   113
  object Command_Timing
wenzelm@51818
   114
  {
wenzelm@52531
   115
    def unapply(props: Properties.T): Option[(Document_ID.Generic, isabelle.Timing)] =
wenzelm@51818
   116
      props match {
wenzelm@51818
   117
        case (Markup.FUNCTION, Markup.COMMAND_TIMING) :: args =>
wenzelm@51818
   118
          (args, args) match {
wenzelm@51818
   119
            case (Position.Id(id), Markup.Timing_Properties(timing)) => Some((id, timing))
wenzelm@51818
   120
            case _ => None
wenzelm@51818
   121
          }
wenzelm@51818
   122
        case _ => None
wenzelm@51818
   123
      }
wenzelm@51818
   124
  }
wenzelm@51818
   125
wenzelm@51818
   126
wenzelm@46209
   127
  /* node status */
wenzelm@46209
   128
wenzelm@46688
   129
  sealed case class Node_Status(
wenzelm@46688
   130
    unprocessed: Int, running: Int, finished: Int, warned: Int, failed: Int)
wenzelm@44866
   131
  {
wenzelm@46688
   132
    def total: Int = unprocessed + running + finished + warned + failed
wenzelm@44866
   133
  }
wenzelm@44613
   134
wenzelm@44613
   135
  def node_status(
wenzelm@44613
   136
    state: Document.State, version: Document.Version, node: Document.Node): Node_Status =
wenzelm@44613
   137
  {
wenzelm@44613
   138
    var unprocessed = 0
wenzelm@44613
   139
    var running = 0
wenzelm@44613
   140
    var finished = 0
wenzelm@46688
   141
    var warned = 0
wenzelm@44613
   142
    var failed = 0
wenzelm@56356
   143
    for (command <- node.commands.iterator) {
wenzelm@56355
   144
      val states = state.command_states(version, command)
wenzelm@56359
   145
      val status = Status.merge(states.iterator.map(_.protocol_status))
wenzelm@56355
   146
wenzelm@56299
   147
      if (status.is_running) running += 1
wenzelm@56395
   148
      else if (status.is_warned) warned += 1
wenzelm@56395
   149
      else if (status.is_finished) finished += 1
wenzelm@56299
   150
      else if (status.is_failed) failed += 1
wenzelm@56299
   151
      else unprocessed += 1
wenzelm@56299
   152
    }
wenzelm@46688
   153
    Node_Status(unprocessed, running, finished, warned, failed)
wenzelm@44613
   154
  }
wenzelm@44613
   155
wenzelm@38887
   156
wenzelm@51533
   157
  /* node timing */
wenzelm@51533
   158
wenzelm@51533
   159
  sealed case class Node_Timing(total: Double, commands: Map[Command, Double])
wenzelm@51533
   160
wenzelm@51533
   161
  val empty_node_timing = Node_Timing(0.0, Map.empty)
wenzelm@51533
   162
wenzelm@51533
   163
  def node_timing(
wenzelm@51533
   164
    state: Document.State,
wenzelm@51533
   165
    version: Document.Version,
wenzelm@51533
   166
    node: Document.Node,
wenzelm@51533
   167
    threshold: Double): Node_Timing =
wenzelm@51533
   168
  {
wenzelm@51533
   169
    var total = 0.0
wenzelm@51533
   170
    var commands = Map.empty[Command, Double]
wenzelm@51533
   171
    for {
wenzelm@51533
   172
      command <- node.commands.iterator
wenzelm@56299
   173
      st <- state.command_states(version, command)
wenzelm@56356
   174
    } {
wenzelm@56356
   175
      val command_timing =
wenzelm@51533
   176
        (0.0 /: st.status)({
wenzelm@51533
   177
          case (timing, Markup.Timing(t)) => timing + t.elapsed.seconds
wenzelm@51533
   178
          case (timing, _) => timing
wenzelm@51533
   179
        })
wenzelm@51533
   180
      total += command_timing
wenzelm@51533
   181
      if (command_timing >= threshold) commands += (command -> command_timing)
wenzelm@51533
   182
    }
wenzelm@51533
   183
    Node_Timing(total, commands)
wenzelm@51533
   184
  }
wenzelm@51533
   185
wenzelm@51533
   186
wenzelm@39441
   187
  /* result messages */
wenzelm@39439
   188
wenzelm@55820
   189
  private val clean_elements =
wenzelm@55820
   190
    Document.Elements(Markup.REPORT, Markup.NO_REPORT)
wenzelm@50450
   191
wenzelm@39439
   192
  def clean_message(body: XML.Body): XML.Body =
wenzelm@49445
   193
    body filter {
wenzelm@55646
   194
      case XML.Wrapped_Elem(Markup(name, _), _, _) => !clean_elements(name)
wenzelm@55646
   195
      case XML.Elem(Markup(name, _), _) => !clean_elements(name)
wenzelm@49445
   196
      case _ => true
wenzelm@49650
   197
    } map {
wenzelm@49650
   198
      case XML.Wrapped_Elem(markup, body, ts) => XML.Wrapped_Elem(markup, body, clean_message(ts))
wenzelm@49650
   199
      case XML.Elem(markup, ts) => XML.Elem(markup, clean_message(ts))
wenzelm@49650
   200
      case t => t
wenzelm@49650
   201
    }
wenzelm@39439
   202
wenzelm@49445
   203
  def message_reports(props: Properties.T, body: XML.Body): List[XML.Elem] =
wenzelm@49445
   204
    body flatMap {
wenzelm@50450
   205
      case XML.Wrapped_Elem(Markup(Markup.REPORT, ps), body, ts) =>
wenzelm@50450
   206
        List(XML.Wrapped_Elem(Markup(Markup.REPORT, props ::: ps), body, ts))
wenzelm@50201
   207
      case XML.Elem(Markup(Markup.REPORT, ps), ts) =>
wenzelm@50201
   208
        List(XML.Elem(Markup(Markup.REPORT, props ::: ps), ts))
wenzelm@49650
   209
      case XML.Wrapped_Elem(_, _, ts) => message_reports(props, ts)
wenzelm@49445
   210
      case XML.Elem(_, ts) => message_reports(props, ts)
wenzelm@39441
   211
      case XML.Text(_) => Nil
wenzelm@39441
   212
    }
wenzelm@39441
   213
wenzelm@39439
   214
wenzelm@39511
   215
  /* specific messages */
wenzelm@39511
   216
wenzelm@50500
   217
  def is_inlined(msg: XML.Tree): Boolean =
wenzelm@50500
   218
    !(is_result(msg) || is_tracing(msg) || is_state(msg))
wenzelm@50500
   219
wenzelm@50500
   220
  def is_result(msg: XML.Tree): Boolean =
wenzelm@50500
   221
    msg match {
wenzelm@50500
   222
      case XML.Elem(Markup(Markup.RESULT, _), _) => true
wenzelm@50500
   223
      case _ => false
wenzelm@50500
   224
    }
wenzelm@50500
   225
wenzelm@50157
   226
  def is_tracing(msg: XML.Tree): Boolean =
wenzelm@39622
   227
    msg match {
wenzelm@50201
   228
      case XML.Elem(Markup(Markup.TRACING, _), _) => true
wenzelm@50201
   229
      case XML.Elem(Markup(Markup.TRACING_MESSAGE, _), _) => true
wenzelm@39622
   230
      case _ => false
wenzelm@39622
   231
    }
wenzelm@39622
   232
wenzelm@52650
   233
  def is_writeln_markup(msg: XML.Tree, name: String): Boolean =
wenzelm@50500
   234
    msg match {
wenzelm@50500
   235
      case XML.Elem(Markup(Markup.WRITELN, _),
wenzelm@52650
   236
        List(XML.Elem(markup, _))) => markup.name == name
wenzelm@50500
   237
      case XML.Elem(Markup(Markup.WRITELN_MESSAGE, _),
wenzelm@52650
   238
        List(XML.Elem(markup, _))) => markup.name == name
wenzelm@50500
   239
      case _ => false
wenzelm@50500
   240
    }
wenzelm@50500
   241
wenzelm@52650
   242
  def is_state(msg: XML.Tree): Boolean = is_writeln_markup(msg, Markup.STATE)
wenzelm@52650
   243
  def is_information(msg: XML.Tree): Boolean = is_writeln_markup(msg, Markup.INFORMATION)
wenzelm@52650
   244
wenzelm@39511
   245
  def is_warning(msg: XML.Tree): Boolean =
wenzelm@39511
   246
    msg match {
wenzelm@50201
   247
      case XML.Elem(Markup(Markup.WARNING, _), _) => true
wenzelm@50201
   248
      case XML.Elem(Markup(Markup.WARNING_MESSAGE, _), _) => true
wenzelm@39511
   249
      case _ => false
wenzelm@39511
   250
    }
wenzelm@39511
   251
wenzelm@39511
   252
  def is_error(msg: XML.Tree): Boolean =
wenzelm@39511
   253
    msg match {
wenzelm@50201
   254
      case XML.Elem(Markup(Markup.ERROR, _), _) => true
wenzelm@50201
   255
      case XML.Elem(Markup(Markup.ERROR_MESSAGE, _), _) => true
wenzelm@39511
   256
      case _ => false
wenzelm@39511
   257
    }
wenzelm@38887
   258
wenzelm@50500
   259
wenzelm@50500
   260
  /* dialogs */
wenzelm@50500
   261
wenzelm@50500
   262
  object Dialog_Args
wenzelm@50500
   263
  {
wenzelm@52531
   264
    def unapply(props: Properties.T): Option[(Document_ID.Generic, Long, String)] =
wenzelm@50500
   265
      (props, props, props) match {
wenzelm@50500
   266
        case (Position.Id(id), Markup.Serial(serial), Markup.Result(result)) =>
wenzelm@50500
   267
          Some((id, serial, result))
wenzelm@50500
   268
        case _ => None
wenzelm@50500
   269
      }
wenzelm@50500
   270
  }
wenzelm@50500
   271
wenzelm@50500
   272
  object Dialog
wenzelm@50500
   273
  {
wenzelm@52531
   274
    def unapply(tree: XML.Tree): Option[(Document_ID.Generic, Long, String)] =
wenzelm@50500
   275
      tree match {
wenzelm@50500
   276
        case XML.Elem(Markup(Markup.DIALOG, Dialog_Args(id, serial, result)), _) =>
wenzelm@50500
   277
          Some((id, serial, result))
wenzelm@50500
   278
        case _ => None
wenzelm@50500
   279
      }
wenzelm@50500
   280
  }
wenzelm@50500
   281
wenzelm@50500
   282
  object Dialog_Result
wenzelm@50500
   283
  {
wenzelm@52531
   284
    def apply(id: Document_ID.Generic, serial: Long, result: String): XML.Elem =
wenzelm@50501
   285
    {
wenzelm@50501
   286
      val props = Position.Id(id) ::: Markup.Serial(serial)
wenzelm@50501
   287
      XML.Elem(Markup(Markup.RESULT, props), List(XML.Text(result)))
wenzelm@50501
   288
    }
wenzelm@50500
   289
wenzelm@50501
   290
    def unapply(tree: XML.Tree): Option[String] =
wenzelm@50500
   291
      tree match {
wenzelm@50501
   292
        case XML.Elem(Markup(Markup.RESULT, _), List(XML.Text(result))) => Some(result)
wenzelm@50500
   293
        case _ => None
wenzelm@50500
   294
      }
wenzelm@50500
   295
  }
wenzelm@39170
   296
wenzelm@39511
   297
wenzelm@39511
   298
  /* reported positions */
wenzelm@39511
   299
wenzelm@55646
   300
  private val position_elements =
wenzelm@55820
   301
    Document.Elements(Markup.BINDING, Markup.ENTITY, Markup.REPORT, Markup.POSITION)
wenzelm@39441
   302
wenzelm@55433
   303
  def message_positions(
wenzelm@56295
   304
    valid_id: Document_ID.Generic => Boolean,
wenzelm@56469
   305
    chunk_name: Text.Chunk.Name,
wenzelm@56468
   306
    chunk: Text.Chunk,
wenzelm@55433
   307
    message: XML.Elem): Set[Text.Range] =
wenzelm@38887
   308
  {
wenzelm@55433
   309
    def elem_positions(props: Properties.T, set: Set[Text.Range]): Set[Text.Range] =
wenzelm@55433
   310
      props match {
wenzelm@56469
   311
        case Position.Reported(id, name, symbol_range)
wenzelm@56469
   312
        if valid_id(id) && name == chunk_name =>
wenzelm@55884
   313
          chunk.incorporate(symbol_range) match {
wenzelm@55822
   314
            case Some(range) => set + range
wenzelm@55548
   315
            case _ => set
wenzelm@55548
   316
          }
wenzelm@55433
   317
        case _ => set
wenzelm@55433
   318
      }
wenzelm@50157
   319
wenzelm@39441
   320
    def positions(set: Set[Text.Range], tree: XML.Tree): Set[Text.Range] =
wenzelm@38887
   321
      tree match {
wenzelm@55433
   322
        case XML.Wrapped_Elem(Markup(name, props), _, body) =>
wenzelm@55646
   323
          body.foldLeft(if (position_elements(name)) elem_positions(props, set) else set)(positions)
wenzelm@55433
   324
        case XML.Elem(Markup(name, props), body) =>
wenzelm@55646
   325
          body.foldLeft(if (position_elements(name)) elem_positions(props, set) else set)(positions)
wenzelm@55433
   326
        case XML.Text(_) => set
wenzelm@38887
   327
      }
wenzelm@50157
   328
wenzelm@39441
   329
    val set = positions(Set.empty, message)
wenzelm@55433
   330
    if (set.isEmpty) elem_positions(message.markup.properties, set)
wenzelm@39042
   331
    else set
wenzelm@38887
   332
  }
wenzelm@38412
   333
}
wenzelm@38412
   334
wenzelm@38412
   335
wenzelm@56387
   336
trait Protocol extends Prover
wenzelm@38412
   337
{
wenzelm@56387
   338
  /* options */
wenzelm@56387
   339
wenzelm@56387
   340
  def options(opts: Options): Unit =
wenzelm@56387
   341
    protocol_command("Prover.options", YXML.string_of_body(opts.encode))
wenzelm@56387
   342
wenzelm@56387
   343
wenzelm@56387
   344
  /* interned items */
wenzelm@54519
   345
wenzelm@56335
   346
  def define_blob(digest: SHA1.Digest, bytes: Bytes): Unit =
wenzelm@56387
   347
    protocol_command_bytes("Document.define_blob", Bytes(digest.toString), bytes)
wenzelm@38412
   348
wenzelm@44644
   349
  def define_command(command: Command): Unit =
wenzelm@54519
   350
  {
wenzelm@54519
   351
    val blobs_yxml =
wenzelm@54519
   352
    { import XML.Encode._
wenzelm@54519
   353
      val encode_blob: T[Command.Blob] =
wenzelm@54519
   354
        variant(List(
wenzelm@54526
   355
          { case Exn.Res((a, b)) =>
wenzelm@56458
   356
              (Nil, pair(string, option(string))((a.node, b.map(p => p._1.toString)))) },
wenzelm@54526
   357
          { case Exn.Exn(e) => (Nil, string(Exn.message(e))) }))
wenzelm@54519
   358
      YXML.string_of_body(list(encode_blob)(command.blobs))
wenzelm@54519
   359
    }
wenzelm@52582
   360
    protocol_command("Document.define_command",
wenzelm@54519
   361
      Document_ID(command.id), encode(command.name), blobs_yxml, encode(command.source))
wenzelm@54519
   362
  }
wenzelm@38412
   363
wenzelm@38412
   364
wenzelm@52931
   365
  /* execution */
wenzelm@52931
   366
wenzelm@52931
   367
  def discontinue_execution(): Unit =
wenzelm@52931
   368
    protocol_command("Document.discontinue_execution")
wenzelm@38412
   369
wenzelm@52931
   370
  def cancel_exec(id: Document_ID.Exec): Unit =
wenzelm@52931
   371
    protocol_command("Document.cancel_exec", Document_ID(id))
wenzelm@52931
   372
wenzelm@52931
   373
wenzelm@52931
   374
  /* document versions */
wenzelm@47343
   375
wenzelm@52530
   376
  def update(old_id: Document_ID.Version, new_id: Document_ID.Version,
wenzelm@44383
   377
    edits: List[Document.Edit_Command])
wenzelm@38412
   378
  {
wenzelm@44157
   379
    val edits_yxml =
wenzelm@43767
   380
    { import XML.Encode._
wenzelm@44383
   381
      def id: T[Command] = (cmd => long(cmd.id))
wenzelm@46737
   382
      def encode_edit(name: Document.Node.Name)
wenzelm@52849
   383
          : T[Document.Node.Edit[Command.Edit, Command.Perspective]] =
wenzelm@44979
   384
        variant(List(
wenzelm@44979
   385
          { case Document.Node.Edits(a) => (Nil, list(pair(option(id), option(id)))(a)) },
wenzelm@48707
   386
          { case Document.Node.Deps(header) =>
wenzelm@56449
   387
              val master_dir = Isabelle_System.posix_path_url(name.master_dir)
wenzelm@48707
   388
              val imports = header.imports.map(_.node)
wenzelm@50128
   389
              val keywords = header.keywords.map({ case (a, b, _) => (a, b) })
wenzelm@44979
   390
              (Nil,
wenzelm@48707
   391
                pair(Encode.string, pair(Encode.string, pair(list(Encode.string),
wenzelm@48864
   392
                  pair(list(pair(Encode.string,
wenzelm@48864
   393
                    option(pair(pair(Encode.string, list(Encode.string)), list(Encode.string))))),
wenzelm@51294
   394
                  list(Encode.string)))))(
wenzelm@54515
   395
                (master_dir, (name.theory, (imports, (keywords, header.errors)))))) },
wenzelm@52849
   396
          { case Document.Node.Perspective(a, b, c) =>
wenzelm@52849
   397
              (bool_atom(a) :: b.commands.map(cmd => long_atom(cmd.id)),
wenzelm@52862
   398
                list(pair(id, pair(Encode.string, list(Encode.string))))(c.dest)) }))
wenzelm@48705
   399
      def encode_edits: T[List[Document.Edit_Command]] = list((node_edit: Document.Edit_Command) =>
wenzelm@44979
   400
      {
wenzelm@44979
   401
        val (name, edit) = node_edit
wenzelm@46737
   402
        pair(string, encode_edit(name))(name.node, edit)
wenzelm@44979
   403
      })
wenzelm@48705
   404
      YXML.string_of_body(encode_edits(edits)) }
wenzelm@52582
   405
    protocol_command("Document.update", Document_ID(old_id), Document_ID(new_id), edits_yxml)
wenzelm@38412
   406
  }
wenzelm@43748
   407
wenzelm@44673
   408
  def remove_versions(versions: List[Document.Version])
wenzelm@44673
   409
  {
wenzelm@44673
   410
    val versions_yxml =
wenzelm@44673
   411
      { import XML.Encode._
wenzelm@44673
   412
        YXML.string_of_body(list(long)(versions.map(_.id))) }
wenzelm@52582
   413
    protocol_command("Document.remove_versions", versions_yxml)
wenzelm@44673
   414
  }
wenzelm@44673
   415
wenzelm@43748
   416
wenzelm@50498
   417
  /* dialog via document content */
wenzelm@50498
   418
wenzelm@52931
   419
  def dialog_result(serial: Long, result: String): Unit =
wenzelm@52582
   420
    protocol_command("Document.dialog_result", Properties.Value.Long(serial), result)
wenzelm@38412
   421
}