author | wenzelm |
Sat, 03 Sep 2011 21:15:35 +0200 | |
changeset 44676 | 7de87f1ae965 |
parent 44673 | 2fa51ac191bc |
child 44866 | 0eb8284a64bd |
permissions | -rw-r--r-- |
38483 | 1 |
/* Title: Pure/PIDE/isar_document.scala |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
3 |
|
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
4 |
Protocol message formats for interactive Isar documents. |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
6 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
8 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
9 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
10 |
object Isar_Document |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
11 |
{ |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
12 |
/* document editing */ |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
13 |
|
44476
e8a87398f35d
propagate information about last command with exec state assignment through document model;
wenzelm
parents:
44474
diff
changeset
|
14 |
object Assign |
e8a87398f35d
propagate information about last command with exec state assignment through document model;
wenzelm
parents:
44474
diff
changeset
|
15 |
{ |
44661
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
16 |
def unapply(text: String): Option[(Document.Version_ID, Document.Assign)] = |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
17 |
try { |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
18 |
import XML.Decode._ |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
19 |
val body = YXML.parse_body(text) |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
20 |
Some(pair(long, pair(list(pair(long, option(long))), list(pair(string, option(long)))))(body)) |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
21 |
} |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
22 |
catch { |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
23 |
case ERROR(_) => None |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
24 |
case _: XML.XML_Atom => None |
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
25 |
case _: XML.XML_Body => None |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
26 |
} |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
27 |
} |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
28 |
|
44676 | 29 |
object Removed |
30 |
{ |
|
31 |
def unapply(text: String): Option[List[Document.Version_ID]] = |
|
32 |
try { |
|
33 |
import XML.Decode._ |
|
34 |
Some(list(long)(YXML.parse_body(text))) |
|
35 |
} |
|
36 |
catch { |
|
37 |
case ERROR(_) => None |
|
38 |
case _: XML.XML_Atom => None |
|
39 |
case _: XML.XML_Body => None |
|
40 |
} |
|
41 |
} |
|
42 |
||
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
43 |
|
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
44 |
/* toplevel transactions */ |
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
45 |
|
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
46 |
sealed abstract class Status |
44613 | 47 |
case object Unprocessed extends Status |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
48 |
case class Forked(forks: Int) extends Status |
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
49 |
case object Finished extends Status |
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
50 |
case object Failed extends Status |
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
51 |
|
38581
d503a0912e14
simplified Command.status again, reverting most of e5eed57913d0 (note that more complex information can be represented with full markup reports);
wenzelm
parents:
38567
diff
changeset
|
52 |
def command_status(markup: List[Markup]): Status = |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
53 |
{ |
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
54 |
val forks = (0 /: markup) { |
38581
d503a0912e14
simplified Command.status again, reverting most of e5eed57913d0 (note that more complex information can be represented with full markup reports);
wenzelm
parents:
38567
diff
changeset
|
55 |
case (i, Markup(Markup.FORKED, _)) => i + 1 |
d503a0912e14
simplified Command.status again, reverting most of e5eed57913d0 (note that more complex information can be represented with full markup reports);
wenzelm
parents:
38567
diff
changeset
|
56 |
case (i, Markup(Markup.JOINED, _)) => i - 1 |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
57 |
case (i, _) => i |
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
58 |
} |
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
59 |
if (forks != 0) Forked(forks) |
38581
d503a0912e14
simplified Command.status again, reverting most of e5eed57913d0 (note that more complex information can be represented with full markup reports);
wenzelm
parents:
38567
diff
changeset
|
60 |
else if (markup.exists(_.name == Markup.FAILED)) Failed |
d503a0912e14
simplified Command.status again, reverting most of e5eed57913d0 (note that more complex information can be represented with full markup reports);
wenzelm
parents:
38567
diff
changeset
|
61 |
else if (markup.exists(_.name == Markup.FINISHED)) Finished |
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
62 |
else Unprocessed |
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
63 |
} |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
64 |
|
44613 | 65 |
sealed case class Node_Status(unprocessed: Int, running: Int, finished: Int, failed: Int) |
66 |
||
67 |
def node_status( |
|
68 |
state: Document.State, version: Document.Version, node: Document.Node): Node_Status = |
|
69 |
{ |
|
70 |
var unprocessed = 0 |
|
71 |
var running = 0 |
|
72 |
var finished = 0 |
|
73 |
var failed = 0 |
|
74 |
node.commands.foreach(command => |
|
75 |
command_status(state.command_state(version, command).status) match { |
|
76 |
case Unprocessed => unprocessed += 1 |
|
77 |
case Forked(_) => running += 1 |
|
78 |
case Finished => finished += 1 |
|
79 |
case Failed => failed += 1 |
|
80 |
}) |
|
81 |
Node_Status(unprocessed, running, finished, failed) |
|
82 |
} |
|
83 |
||
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
84 |
|
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
85 |
/* result messages */ |
39439
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
86 |
|
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
87 |
def clean_message(body: XML.Body): XML.Body = |
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
88 |
body filter { case XML.Elem(Markup(Markup.NO_REPORT, _), _) => false case _ => true } map |
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
89 |
{ case XML.Elem(markup, ts) => XML.Elem(markup, clean_message(ts)) case t => t } |
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
90 |
|
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
91 |
def message_reports(msg: XML.Tree): List[XML.Elem] = |
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
92 |
msg match { |
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
93 |
case elem @ XML.Elem(Markup(Markup.REPORT, _), _) => List(elem) |
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
94 |
case XML.Elem(_, body) => body.flatMap(message_reports) |
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
95 |
case XML.Text(_) => Nil |
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
96 |
} |
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
97 |
|
39439
1c294d150ded
eliminated markup "location" in favour of more explicit "no_report", which is actually deleted from messages;
wenzelm
parents:
39181
diff
changeset
|
98 |
|
39511 | 99 |
/* specific messages */ |
100 |
||
39625 | 101 |
def is_ready(msg: XML.Tree): Boolean = |
102 |
msg match { |
|
103 |
case XML.Elem(Markup(Markup.STATUS, _), |
|
104 |
List(XML.Elem(Markup(Markup.READY, _), _))) => true |
|
105 |
case _ => false |
|
106 |
} |
|
107 |
||
108 |
def is_tracing(msg: XML.Tree): Boolean = |
|
39622
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
109 |
msg match { |
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
110 |
case XML.Elem(Markup(Markup.TRACING, _), _) => true |
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
111 |
case _ => false |
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
112 |
} |
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
113 |
|
39511 | 114 |
def is_warning(msg: XML.Tree): Boolean = |
115 |
msg match { |
|
116 |
case XML.Elem(Markup(Markup.WARNING, _), _) => true |
|
117 |
case _ => false |
|
118 |
} |
|
119 |
||
120 |
def is_error(msg: XML.Tree): Boolean = |
|
121 |
msg match { |
|
122 |
case XML.Elem(Markup(Markup.ERROR, _), _) => true |
|
123 |
case _ => false |
|
124 |
} |
|
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
125 |
|
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
126 |
def is_state(msg: XML.Tree): Boolean = |
39170
04ad0fed81f5
Isar_Document.reported_positions: exclude proof state output;
wenzelm
parents:
39042
diff
changeset
|
127 |
msg match { |
39627 | 128 |
case XML.Elem(Markup(Markup.WRITELN, _), |
129 |
List(XML.Elem(Markup(Markup.STATE, _), _))) => true |
|
39170
04ad0fed81f5
Isar_Document.reported_positions: exclude proof state output;
wenzelm
parents:
39042
diff
changeset
|
130 |
case _ => false |
04ad0fed81f5
Isar_Document.reported_positions: exclude proof state output;
wenzelm
parents:
39042
diff
changeset
|
131 |
} |
04ad0fed81f5
Isar_Document.reported_positions: exclude proof state output;
wenzelm
parents:
39042
diff
changeset
|
132 |
|
39511 | 133 |
|
134 |
/* reported positions */ |
|
135 |
||
39627 | 136 |
private val include_pos = |
137 |
Set(Markup.BINDING, Markup.ENTITY, Markup.REPORT, Markup.POSITION) |
|
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
138 |
|
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
139 |
def message_positions(command: Command, message: XML.Elem): Set[Text.Range] = |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
140 |
{ |
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
141 |
def positions(set: Set[Text.Range], tree: XML.Tree): Set[Text.Range] = |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
142 |
tree match { |
39172
31b95e0da7b7
Isar_Document.reported_positions: slightly more robust treatment of positions outside the command range, notably parsing beyond EOF;
wenzelm
parents:
39170
diff
changeset
|
143 |
case XML.Elem(Markup(name, Position.Id_Range(id, raw_range)), body) |
31b95e0da7b7
Isar_Document.reported_positions: slightly more robust treatment of positions outside the command range, notably parsing beyond EOF;
wenzelm
parents:
39170
diff
changeset
|
144 |
if include_pos(name) && id == command.id => |
31b95e0da7b7
Isar_Document.reported_positions: slightly more robust treatment of positions outside the command range, notably parsing beyond EOF;
wenzelm
parents:
39170
diff
changeset
|
145 |
val range = command.decode(raw_range).restrict(command.range) |
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
146 |
body.foldLeft(if (range.is_singularity) set else set + range)(positions) |
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
147 |
case XML.Elem(Markup(name, _), body) => body.foldLeft(set)(positions) |
39042
470fd769ae53
Isar_Document.reported_positions: more precise include/exclude, include root as last resort only;
wenzelm
parents:
38887
diff
changeset
|
148 |
case _ => set |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
149 |
} |
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
150 |
val set = positions(Set.empty, message) |
39170
04ad0fed81f5
Isar_Document.reported_positions: exclude proof state output;
wenzelm
parents:
39042
diff
changeset
|
151 |
if (set.isEmpty && !is_state(message)) |
39172
31b95e0da7b7
Isar_Document.reported_positions: slightly more robust treatment of positions outside the command range, notably parsing beyond EOF;
wenzelm
parents:
39170
diff
changeset
|
152 |
set ++ Position.Range.unapply(message.markup.properties).map(command.decode(_)) |
39042
470fd769ae53
Isar_Document.reported_positions: more precise include/exclude, include root as last resort only;
wenzelm
parents:
38887
diff
changeset
|
153 |
else set |
38887
1261481ef5e5
Command.State: add reported positions to markup tree, according main message position or Markup.binding/entity/report occurrences in body;
wenzelm
parents:
38581
diff
changeset
|
154 |
} |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
155 |
} |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
156 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
157 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
158 |
trait Isar_Document extends Isabelle_Process |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
159 |
{ |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
160 |
/* commands */ |
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
161 |
|
44644
317e4962dd0f
clarified define_command: store name as structural information;
wenzelm
parents:
44615
diff
changeset
|
162 |
def define_command(command: Command): Unit = |
317e4962dd0f
clarified define_command: store name as structural information;
wenzelm
parents:
44615
diff
changeset
|
163 |
input("Isar_Document.define_command", |
317e4962dd0f
clarified define_command: store name as structural information;
wenzelm
parents:
44615
diff
changeset
|
164 |
Document.ID(command.id), Symbol.encode(command.name), Symbol.encode(command.source)) |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
165 |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
166 |
|
38417 | 167 |
/* document versions */ |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
168 |
|
44612
990ac978854c
explicit cancel_execution before queueing new edits -- potential performance improvement for machines with few cores;
wenzelm
parents:
44481
diff
changeset
|
169 |
def cancel_execution() |
990ac978854c
explicit cancel_execution before queueing new edits -- potential performance improvement for machines with few cores;
wenzelm
parents:
44481
diff
changeset
|
170 |
{ |
990ac978854c
explicit cancel_execution before queueing new edits -- potential performance improvement for machines with few cores;
wenzelm
parents:
44481
diff
changeset
|
171 |
input("Isar_Document.cancel_execution") |
990ac978854c
explicit cancel_execution before queueing new edits -- potential performance improvement for machines with few cores;
wenzelm
parents:
44481
diff
changeset
|
172 |
} |
990ac978854c
explicit cancel_execution before queueing new edits -- potential performance improvement for machines with few cores;
wenzelm
parents:
44481
diff
changeset
|
173 |
|
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44384
diff
changeset
|
174 |
def update_perspective(old_id: Document.Version_ID, new_id: Document.Version_ID, |
44615 | 175 |
name: Document.Node.Name, perspective: Command.Perspective) |
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44384
diff
changeset
|
176 |
{ |
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44384
diff
changeset
|
177 |
val ids = |
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44384
diff
changeset
|
178 |
{ import XML.Encode._ |
44474 | 179 |
list(long)(perspective.commands.map(_.id)) } |
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44384
diff
changeset
|
180 |
|
44615 | 181 |
input("Isar_Document.update_perspective", Document.ID(old_id), Document.ID(new_id), |
182 |
name.node, YXML.string_of_body(ids)) |
|
44436
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44384
diff
changeset
|
183 |
} |
546adfa8a6fc
update_perspective without actual edits, bypassing the full state assignment protocol;
wenzelm
parents:
44384
diff
changeset
|
184 |
|
44481 | 185 |
def update(old_id: Document.Version_ID, new_id: Document.Version_ID, |
44383 | 186 |
edits: List[Document.Edit_Command]) |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
187 |
{ |
44157
a21d3e1e64fd
uniform treatment of header edits as document edits;
wenzelm
parents:
44156
diff
changeset
|
188 |
val edits_yxml = |
43767 | 189 |
{ import XML.Encode._ |
44383 | 190 |
def id: T[Command] = (cmd => long(cmd.id)) |
191 |
def encode: T[List[Document.Edit_Command]] = |
|
44615 | 192 |
list(pair((name => string(name.node)), |
44156 | 193 |
variant(List( |
44185 | 194 |
{ case Document.Node.Clear() => (Nil, Nil) }, |
44383 | 195 |
{ case Document.Node.Edits(a) => (Nil, list(pair(option(id), option(id)))(a)) }, |
44182 | 196 |
{ case Document.Node.Header(Exn.Res(Thy_Header(a, b, c))) => |
44185 | 197 |
(Nil, triple(string, list(string), list(pair(string, bool)))(a, b, c)) }, |
44384 | 198 |
{ case Document.Node.Header(Exn.Exn(e)) => (List(Exn.message(e)), Nil) }, |
44474 | 199 |
{ case Document.Node.Perspective(a) => (a.commands.map(c => long_atom(c.id)), Nil) })))) |
44157
a21d3e1e64fd
uniform treatment of header edits as document edits;
wenzelm
parents:
44156
diff
changeset
|
200 |
YXML.string_of_body(encode(edits)) } |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
201 |
|
44481 | 202 |
input("Isar_Document.update", Document.ID(old_id), Document.ID(new_id), edits_yxml) |
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
203 |
} |
43748 | 204 |
|
44673 | 205 |
def remove_versions(versions: List[Document.Version]) |
206 |
{ |
|
207 |
val versions_yxml = |
|
208 |
{ import XML.Encode._ |
|
209 |
YXML.string_of_body(list(long)(versions.map(_.id))) } |
|
210 |
input("Isar_Document.remove_versions", versions_yxml) |
|
211 |
} |
|
212 |
||
43748 | 213 |
|
214 |
/* method invocation service */ |
|
215 |
||
216 |
def invoke_scala(id: String, tag: Invoke_Scala.Tag.Value, res: String) |
|
217 |
{ |
|
218 |
input("Isar_Document.invoke_scala", id, tag.toString, res) |
|
219 |
} |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
220 |
} |