| author | wenzelm |
| Wed, 29 Oct 2025 14:48:25 +0100 | |
| changeset 83427 | 1ebb11300c08 |
| parent 83226 | 37b61794a93a |
| child 83428 | cb4f950f4fbd |
| permissions | -rw-r--r-- |
|
45709
87017fcbad83
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
wenzelm
parents:
45672
diff
changeset
|
1 |
/* Title: Pure/PIDE/protocol.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 |
|
|
45709
87017fcbad83
clarified modules (again) -- NB: both Document and Protocol are specific to this particular prover;
wenzelm
parents:
45672
diff
changeset
|
4 |
Protocol message formats for interactive proof 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 |
|
| 75393 | 10 |
object Protocol {
|
|
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
11 |
/* markers for inlined messages */ |
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
12 |
|
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
13 |
val Loading_Theory_Marker = Protocol_Message.Marker("loading_theory")
|
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
14 |
val Meta_Info_Marker = Protocol_Message.Marker("meta_info")
|
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
15 |
val Command_Timing_Marker = Protocol_Message.Marker("command_timing")
|
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
16 |
val Theory_Timing_Marker = Protocol_Message.Marker("theory_timing")
|
| 72012 | 17 |
val Session_Timing_Marker = Protocol_Message.Marker("session_timing")
|
|
71630
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
18 |
val ML_Statistics_Marker = Protocol_Message.Marker("ML_statistics")
|
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
19 |
val Task_Statistics_Marker = Protocol_Message.Marker("task_statistics")
|
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
20 |
val Error_Message_Marker = Protocol_Message.Marker("error_message")
|
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
21 |
|
|
50425e4c3910
clarified modules: global quasi-scope for markers;
wenzelm
parents:
71624
diff
changeset
|
22 |
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
23 |
/* batch build */ |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
24 |
|
| 75393 | 25 |
object Loading_Theory {
|
| 83226 | 26 |
def unapply(props: Properties.T): Option[(Document.Node.Name, Document_ID.Exec, Int)] = |
| 83225 | 27 |
for {
|
28 |
theory <- Markup.Name.unapply(props) |
|
| 83226 | 29 |
commands <- Markup.Commands.unapply(props) |
| 83225 | 30 |
file <- Position.File.unapply(props) if Path.is_wellformed(file) |
31 |
id <- Position.Id.unapply(props) |
|
| 83226 | 32 |
} yield (Document.Node.Name(file, theory = theory), id, commands) |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
33 |
} |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
34 |
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
35 |
|
|
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
36 |
/* document editing */ |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
37 |
|
| 75393 | 38 |
object Commands_Accepted {
|
|
70665
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
39 |
def unapply(text: String): Option[List[Document_ID.Command]] = |
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
40 |
try { Some(space_explode(',', text).map(Value.Long.parse)) }
|
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
41 |
catch { case ERROR(_) => None }
|
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
42 |
|
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
43 |
val message: XML.Elem = XML.elem(Markup.STATUS, List(XML.elem(Markup.ACCEPTED))) |
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
44 |
} |
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
45 |
|
| 75393 | 46 |
object Assign_Update {
|
47 |
def unapply( |
|
48 |
text: String |
|
49 |
) : Option[(Document_ID.Version, List[String], Document.Assign_Update)] = {
|
|
|
44661
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
50 |
try {
|
|
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
51 |
import XML.Decode._ |
| 69846 | 52 |
def decode_upd(body: XML.Body): (Long, List[Long]) = |
53 |
space_explode(',', string(body)).map(Value.Long.parse) match {
|
|
54 |
case a :: bs => (a, bs) |
|
55 |
case _ => throw new XML.XML_Body(body) |
|
56 |
} |
|
| 71601 | 57 |
Some(triple(long, list(string), list(decode_upd))(Symbol.decode_yxml(text))) |
|
44661
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
58 |
} |
|
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
59 |
catch {
|
|
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
60 |
case ERROR(_) => None |
| 51987 | 61 |
case _: XML.Error => None |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
62 |
} |
|
70284
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69849
diff
changeset
|
63 |
} |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
64 |
} |
|
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
65 |
|
| 75393 | 66 |
object Removed {
|
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
67 |
def unapply(text: String): Option[List[Document_ID.Version]] = |
| 44676 | 68 |
try {
|
69 |
import XML.Decode._ |
|
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
70 |
Some(list(long)(Symbol.decode_yxml(text))) |
| 44676 | 71 |
} |
72 |
catch {
|
|
73 |
case ERROR(_) => None |
|
| 51987 | 74 |
case _: XML.Error => None |
| 44676 | 75 |
} |
76 |
} |
|
77 |
||
|
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
78 |
|
|
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
79 |
/* command timing */ |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
80 |
|
| 75393 | 81 |
object Command_Timing {
|
|
83198
7f46426e69ab
clarified protocol: post authentic properties from Protocol.Command_Timing, which includes positions from ML;
wenzelm
parents:
83168
diff
changeset
|
82 |
def unapply(props: Properties.T): Option[(Document_ID.Generic, Properties.T)] = |
|
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
83 |
props match {
|
|
83198
7f46426e69ab
clarified protocol: post authentic properties from Protocol.Command_Timing, which includes positions from ML;
wenzelm
parents:
83168
diff
changeset
|
84 |
case Markup.Command_Timing(args@Position.Id(id)) => Some((id, args)) |
|
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
85 |
case _ => None |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
86 |
} |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
87 |
} |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
88 |
|
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
89 |
|
|
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
90 |
/* 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
|
91 |
|
|
82316
83584916b6d7
support for writeln_urgent, which is shown in Output before state messages (reminiscent of old Output.urgent_message before 521cea5fa777);
wenzelm
parents:
81346
diff
changeset
|
92 |
def is_urgent(msg: XML.Tree): Boolean = |
|
83584916b6d7
support for writeln_urgent, which is shown in Output before state messages (reminiscent of old Output.urgent_message before 521cea5fa777);
wenzelm
parents:
81346
diff
changeset
|
93 |
msg match {
|
|
83584916b6d7
support for writeln_urgent, which is shown in Output before state messages (reminiscent of old Output.urgent_message before 521cea5fa777);
wenzelm
parents:
81346
diff
changeset
|
94 |
case XML.Elem(Markup(_, props), _) => Markup.Urgent.get(props) |
|
83584916b6d7
support for writeln_urgent, which is shown in Output before state messages (reminiscent of old Output.urgent_message before 521cea5fa777);
wenzelm
parents:
81346
diff
changeset
|
95 |
case _ => false |
|
83584916b6d7
support for writeln_urgent, which is shown in Output before state messages (reminiscent of old Output.urgent_message before 521cea5fa777);
wenzelm
parents:
81346
diff
changeset
|
96 |
} |
|
83584916b6d7
support for writeln_urgent, which is shown in Output before state messages (reminiscent of old Output.urgent_message before 521cea5fa777);
wenzelm
parents:
81346
diff
changeset
|
97 |
|
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
98 |
def is_result(msg: XML.Tree): Boolean = |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
99 |
msg match {
|
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
100 |
case XML.Elem(Markup(Markup.RESULT, _), _) => true |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
101 |
case _ => false |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
102 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
103 |
|
| 50157 | 104 |
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
|
105 |
msg match {
|
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
106 |
case XML.Elem(Markup(Markup.TRACING, _), _) => true |
|
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
107 |
case XML.Elem(Markup(Markup.TRACING_MESSAGE, _), _) => true |
|
39622
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
108 |
case _ => false |
|
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
109 |
} |
|
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
110 |
|
|
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
111 |
def is_state(msg: XML.Tree): Boolean = |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
112 |
msg match {
|
|
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
113 |
case XML.Elem(Markup(Markup.STATE, _), _) => true |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
114 |
case XML.Elem(Markup(Markup.STATE_MESSAGE, _), _) => true |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
115 |
case _ => false |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
116 |
} |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
117 |
|
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
118 |
def is_information(msg: XML.Tree): Boolean = |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
119 |
msg match {
|
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
120 |
case XML.Elem(Markup(Markup.INFORMATION, _), _) => true |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
121 |
case XML.Elem(Markup(Markup.INFORMATION_MESSAGE, _), _) => true |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
122 |
case _ => false |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
123 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
124 |
|
|
67923
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
125 |
def is_writeln(msg: XML.Tree): Boolean = |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
126 |
msg match {
|
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
127 |
case XML.Elem(Markup(Markup.WRITELN, _), _) => true |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
128 |
case XML.Elem(Markup(Markup.WRITELN_MESSAGE, _), _) => true |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
129 |
case _ => false |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
130 |
} |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
131 |
|
| 39511 | 132 |
def is_warning(msg: XML.Tree): Boolean = |
133 |
msg match {
|
|
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
134 |
case XML.Elem(Markup(Markup.WARNING, _), _) => true |
|
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
135 |
case XML.Elem(Markup(Markup.WARNING_MESSAGE, _), _) => true |
| 39511 | 136 |
case _ => false |
137 |
} |
|
138 |
||
|
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
139 |
def is_legacy(msg: XML.Tree): Boolean = |
|
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
140 |
msg match {
|
|
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
141 |
case XML.Elem(Markup(Markup.LEGACY, _), _) => true |
|
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
142 |
case XML.Elem(Markup(Markup.LEGACY_MESSAGE, _), _) => true |
|
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
143 |
case _ => false |
|
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
144 |
} |
|
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
145 |
|
| 39511 | 146 |
def is_error(msg: XML.Tree): Boolean = |
147 |
msg match {
|
|
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
148 |
case XML.Elem(Markup(Markup.ERROR, _), _) => true |
|
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
149 |
case XML.Elem(Markup(Markup.ERROR_MESSAGE, _), _) => true |
| 39511 | 150 |
case _ => false |
151 |
} |
|
|
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
|
152 |
|
| 83168 | 153 |
def is_warning_or_legacy(msg: XML.Tree): Boolean = |
154 |
is_warning(msg) || is_legacy(msg) |
|
155 |
||
| 56495 | 156 |
def is_inlined(msg: XML.Tree): Boolean = |
|
76070
cf13b2147c48
inline markup for Output.state (in contrast to c94bba7906d2): make messages available via Rendering.text_messages and thus "isabelle log" (see cb0c407fbc6e), while Rendering.output_messages of Isabelle/jEdit/VSCode is unaffected;
wenzelm
parents:
76022
diff
changeset
|
157 |
!(is_result(msg) || is_tracing(msg)) |
| 56495 | 158 |
|
|
67923
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
159 |
def is_exported(msg: XML.Tree): Boolean = |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
160 |
is_writeln(msg) || is_warning(msg) || is_legacy(msg) || is_error(msg) |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
161 |
|
| 76087 | 162 |
def message_heading(elem: XML.Elem, pos: Position.T): String = {
|
163 |
val h = |
|
| 83168 | 164 |
if (is_warning_or_legacy(elem)) "Warning" |
| 76087 | 165 |
else if (is_error(elem)) "Error" |
166 |
else if (is_information(elem)) "Information" |
|
167 |
else if (is_tracing(elem)) "Tracing" |
|
168 |
else if (is_state(elem)) "State" |
|
169 |
else "Output" |
|
170 |
h + Position.here(pos) |
|
171 |
} |
|
172 |
||
| 72874 | 173 |
def message_text(elem: XML.Elem, |
| 72875 | 174 |
heading: Boolean = false, |
175 |
pos: Position.T = Position.none, |
|
|
82988
71ffc2c22348
explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents:
82948
diff
changeset
|
176 |
recode: String => String = identity, |
| 71649 | 177 |
margin: Double = Pretty.default_margin, |
178 |
breakgain: Double = Pretty.default_breakgain, |
|
| 81346 | 179 |
metric: Pretty.Metric = Codepoint.Metric |
| 75393 | 180 |
): String = {
|
|
82988
71ffc2c22348
explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents:
82948
diff
changeset
|
181 |
val text1 = if (heading) "\n" + recode(message_heading(elem, pos)) + ":\n" else "" |
| 72877 | 182 |
|
183 |
val body = |
|
|
82988
71ffc2c22348
explicit "isabelle process_theories -U" as in "isabelle build_log";
wenzelm
parents:
82948
diff
changeset
|
184 |
Pretty.string_of(List(elem), recode = recode, margin = margin, breakgain = breakgain, |
| 80872 | 185 |
metric = metric, pure = true) |
| 71649 | 186 |
|
| 72877 | 187 |
val text2 = |
| 83168 | 188 |
if (is_warning_or_legacy(elem)) Output.warning_prefix(body) |
| 77501 | 189 |
else if (is_error(elem)) Output.error_message_prefix(body) |
| 72877 | 190 |
else body |
191 |
||
192 |
text1 + text2 |
|
| 71165 | 193 |
} |
194 |
||
| 76680 | 195 |
def make_message(body: XML.Body, kind: String, props: Properties.T = Nil): XML.Elem = |
196 |
XML.Elem(Markup(Markup.message(kind), props), body) |
|
| 76022 | 197 |
|
| 76680 | 198 |
def writeln_message(body: XML.Body): XML.Elem = make_message(body, Markup.WRITELN) |
199 |
def warning_message(body: XML.Body): XML.Elem = make_message(body, Markup.WARNING) |
|
200 |
def error_message(body: XML.Body): XML.Elem = make_message(body, Markup.ERROR) |
|
201 |
||
202 |
def writeln_message(msg: String): XML.Elem = writeln_message(XML.string(msg)) |
|
203 |
def warning_message(msg: String): XML.Elem = warning_message(XML.string(msg)) |
|
204 |
def error_message(msg: String): XML.Elem = error_message(XML.string(msg)) |
|
| 76022 | 205 |
|
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
206 |
|
| 73835 | 207 |
/* ML profiling */ |
208 |
||
| 75393 | 209 |
object ML_Profiling {
|
| 73835 | 210 |
def unapply(msg: XML.Tree): Option[isabelle.ML_Profiling.Report] = |
211 |
msg match {
|
|
| 73838 | 212 |
case XML.Elem(_, List(tree)) if is_tracing(msg) => |
| 73835 | 213 |
Markup.ML_Profiling.unapply_report(tree) |
214 |
case _ => None |
|
215 |
} |
|
216 |
} |
|
217 |
||
218 |
||
| 71624 | 219 |
/* export */ |
220 |
||
| 75393 | 221 |
object Export {
|
| 71624 | 222 |
sealed case class Args( |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
223 |
id: Option[String] = None, |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
224 |
serial: Long = 0L, |
| 71624 | 225 |
theory_name: String, |
226 |
name: String, |
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
227 |
executable: Boolean = false, |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
228 |
compress: Boolean = true, |
| 75393 | 229 |
strict: Boolean = true |
230 |
) {
|
|
| 71624 | 231 |
def compound_name: String = isabelle.Export.compound_name(theory_name, name) |
232 |
} |
|
233 |
||
234 |
def unapply(props: Properties.T): Option[Args] = |
|
235 |
props match {
|
|
236 |
case |
|
237 |
List( |
|
238 |
(Markup.FUNCTION, Markup.EXPORT), |
|
239 |
(Markup.ID, id), |
|
240 |
(Markup.SERIAL, Value.Long(serial)), |
|
241 |
(Markup.THEORY_NAME, theory_name), |
|
242 |
(Markup.NAME, name), |
|
243 |
(Markup.EXECUTABLE, Value.Boolean(executable)), |
|
244 |
(Markup.COMPRESS, Value.Boolean(compress)), |
|
245 |
(Markup.STRICT, Value.Boolean(strict))) => |
|
246 |
Some(Args(proper_string(id), serial, theory_name, name, executable, compress, strict)) |
|
247 |
case _ => None |
|
248 |
} |
|
249 |
} |
|
250 |
||
251 |
||
| 83427 | 252 |
/* sendback snippets */ |
253 |
||
254 |
def senback_snippets(body: XML.Body): List[(String, Properties.T)] = {
|
|
255 |
body match {
|
|
256 |
case XML.Elem(Markup(Markup.SENDBACK, props), b) :: rest => |
|
257 |
(XML.content(b), props) :: senback_snippets(rest) |
|
258 |
case XML.Elem(_, b) :: rest => senback_snippets(b ::: rest) |
|
259 |
case _ :: rest => senback_snippets(rest) |
|
260 |
case Nil => Nil |
|
261 |
} |
|
262 |
} |
|
263 |
||
264 |
||
| 60882 | 265 |
/* breakpoints */ |
266 |
||
| 75393 | 267 |
object ML_Breakpoint {
|
| 60882 | 268 |
def unapply(tree: XML.Tree): Option[Long] = |
269 |
tree match {
|
|
270 |
case XML.Elem(Markup(Markup.ML_BREAKPOINT, Markup.Serial(breakpoint)), _) => Some(breakpoint) |
|
271 |
case _ => None |
|
272 |
} |
|
273 |
} |
|
274 |
||
275 |
||
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
276 |
/* dialogs */ |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
277 |
|
| 75393 | 278 |
object Dialog_Args {
|
| 52531 | 279 |
def unapply(props: Properties.T): Option[(Document_ID.Generic, Long, String)] = |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
280 |
(props, props, props) match {
|
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
281 |
case (Position.Id(id), Markup.Serial(serial), Markup.Result(result)) => |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
282 |
Some((id, serial, result)) |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
283 |
case _ => None |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
284 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
285 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
286 |
|
| 75393 | 287 |
object Dialog {
|
| 52531 | 288 |
def unapply(tree: XML.Tree): Option[(Document_ID.Generic, Long, String)] = |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
289 |
tree match {
|
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
290 |
case XML.Elem(Markup(Markup.DIALOG, Dialog_Args(id, serial, result)), _) => |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
291 |
Some((id, serial, result)) |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
292 |
case _ => None |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
293 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
294 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
295 |
|
| 75393 | 296 |
object Dialog_Result {
|
297 |
def apply(id: Document_ID.Generic, serial: Long, result: String): XML.Elem = {
|
|
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
298 |
val props = Position.Id(id) ::: Markup.Serial(serial) |
|
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
299 |
XML.Elem(Markup(Markup.RESULT, props), List(XML.Text(result))) |
|
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
300 |
} |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
301 |
|
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
302 |
def unapply(tree: XML.Tree): Option[String] = |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
303 |
tree match {
|
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
304 |
case XML.Elem(Markup(Markup.RESULT, _), List(XML.Text(result))) => Some(result) |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
305 |
case _ => None |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
306 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
307 |
} |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
308 |
} |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
309 |
|
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
310 |
|
| 75393 | 311 |
trait Protocol {
|
| 57916 | 312 |
/* protocol commands */ |
313 |
||
| 70661 | 314 |
def protocol_command_raw(name: String, args: List[Bytes]): Unit |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
315 |
def protocol_command_args(name: String, args: List[XML.Body]): Unit |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
316 |
def protocol_command(name: String, args: XML.Body*): Unit |
| 57916 | 317 |
|
318 |
||
| 56387 | 319 |
/* options */ |
320 |
||
321 |
def options(opts: Options): Unit = |
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
322 |
protocol_command("Prover.options", opts.encode)
|
| 56387 | 323 |
|
324 |
||
| 72637 | 325 |
/* resources */ |
|
67493
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
326 |
|
| 72637 | 327 |
def init_session(resources: Resources): Unit = |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
328 |
protocol_command("Prover.init_session", resources.init_session_xml)
|
| 65470 | 329 |
|
330 |
||
| 56387 | 331 |
/* interned items */ |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
332 |
|
|
56335
8953d4cc060a
store blob content within document node: aux. files that were once open are made persistent;
wenzelm
parents:
56306
diff
changeset
|
333 |
def define_blob(digest: SHA1.Digest, bytes: Bytes): Unit = |
| 70661 | 334 |
protocol_command_raw("Document.define_blob", List(Bytes(digest.toString), bytes))
|
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
335 |
|
| 75393 | 336 |
private def encode_command( |
337 |
resources: Resources, |
|
338 |
command: Command |
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
339 |
) : (XML.Body, XML.Body, XML.Body, XML.Body, XML.Body, List[XML.Body]) = {
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
340 |
import XML.Encode._ |
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
341 |
|
| 72946 | 342 |
val parents = command.theory_parents(resources).map(name => File.standard_url(name.node)) |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
343 |
val parents_xml: XML.Body = list(string)(parents) |
| 72946 | 344 |
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
345 |
val blobs_xml: XML.Body = {
|
| 72745 | 346 |
val encode_blob: T[Exn.Result[Command.Blob]] = |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
347 |
variant(List( |
|
82948
e2e43992f339
more detailed export "PIDE/files": store offset of the load command, within the pro-forma loaded_theory_command --- this allows to restrict output messages for blobs;
wenzelm
parents:
82316
diff
changeset
|
348 |
{ case Exn.Res(Command.Blob(_, a, b, c)) =>
|
|
72747
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
wenzelm
parents:
72745
diff
changeset
|
349 |
(Nil, triple(string, string, option(string))( |
|
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
wenzelm
parents:
72745
diff
changeset
|
350 |
(a.node, b.implode, c.map(p => p._1.toString)))) }, |
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
351 |
{ case Exn.Exn(e) => (Nil, string(Exn.message(e))) }))
|
|
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
352 |
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
353 |
pair(list(encode_blob), int)(command.blobs, command.blobs_index) |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
354 |
} |
|
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
355 |
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
356 |
val toks_xml: XML.Body = {
|
| 64616 | 357 |
val encode_tok: T[Token] = (tok => pair(int, int)((tok.kind.id, Symbol.length(tok.source)))) |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
358 |
list(encode_tok)(command.span.content) |
|
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
359 |
} |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
360 |
val toks_sources_xml: List[XML.Body] = command.span.content.map(tok => XML.string(tok.source)) |
|
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
361 |
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
362 |
(Document_ID.encode(command.id), XML.string(command.span.name), |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
363 |
parents_xml, blobs_xml, toks_xml, toks_sources_xml) |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
364 |
} |
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
365 |
|
| 75393 | 366 |
def define_command(resources: Resources, command: Command): Unit = {
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
367 |
val (a, b, c, d, e, rest) = encode_command(resources, command) |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
368 |
protocol_command_args("Document.define_command", a :: b :: c :: d :: e :: rest)
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
369 |
} |
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
370 |
|
| 75394 | 371 |
def define_commands(resources: Resources, commands: List[Command]): Unit = |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
372 |
protocol_command_args("Document.define_commands",
|
| 75394 | 373 |
commands.map { command =>
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
374 |
import XML.Encode._ |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
375 |
val (a, b, c, d, e, rest) = encode_command(resources, command) |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
376 |
pair(self, pair(self, pair(self, pair(self, pair(self, list(self))))))( |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
377 |
a, (b, (c, (d, (e, rest))))) |
| 75394 | 378 |
}) |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
379 |
|
| 75393 | 380 |
def define_commands_bulk(resources: Resources, commands: List[Command]): Unit = {
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
381 |
val (irregular, regular) = commands.partition(command => YXML.detect(command.source)) |
| 72946 | 382 |
irregular.foreach(define_command(resources, _)) |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
383 |
regular match {
|
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
384 |
case Nil => |
| 72946 | 385 |
case List(command) => define_command(resources, command) |
386 |
case _ => define_commands(resources, regular) |
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
387 |
} |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
388 |
} |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
389 |
|
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
390 |
|
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
391 |
/* execution */ |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
392 |
|
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
393 |
def discontinue_execution(): Unit = |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
394 |
protocol_command("Document.discontinue_execution")
|
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
395 |
|
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
396 |
def cancel_exec(id: Document_ID.Exec): Unit = |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
397 |
protocol_command("Document.cancel_exec", Document_ID.encode(id))
|
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
398 |
|
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
399 |
|
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
400 |
/* document versions */ |
|
47343
b8aeab386414
less aggressive discontinue_execution before document update, to avoid unstable execs that need to be re-assigned;
wenzelm
parents:
46938
diff
changeset
|
401 |
|
| 75393 | 402 |
def update( |
403 |
old_id: Document_ID.Version, |
|
404 |
new_id: Document_ID.Version, |
|
405 |
edits: List[Document.Edit_Command], |
|
406 |
consolidate: List[Document.Node.Name] |
|
407 |
): Unit = {
|
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
408 |
val consolidate_xml = { import XML.Encode._; list(string)(consolidate.map(_.node)) }
|
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
409 |
val edits_xml = {
|
| 69849 | 410 |
import XML.Encode._ |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
411 |
|
| 44383 | 412 |
def id: T[Command] = (cmd => long(cmd.id)) |
| 46737 | 413 |
def encode_edit(name: Document.Node.Name) |
| 52849 | 414 |
: T[Document.Node.Edit[Command.Edit, Command.Perspective]] = |
|
44979
68b990e950b1
explicit master_dir as part of header -- still required (for Cygwin) since Scala layer does not pass file content yet;
wenzelm
parents:
44866
diff
changeset
|
415 |
variant(List( |
|
68b990e950b1
explicit master_dir as part of header -- still required (for Cygwin) since Scala layer does not pass file content yet;
wenzelm
parents:
44866
diff
changeset
|
416 |
{ case Document.Node.Edits(a) => (Nil, list(pair(option(id), option(id)))(a)) },
|
|
48707
ba531af91148
simplified Document.Node.Header -- internalized errors;
wenzelm
parents:
48705
diff
changeset
|
417 |
{ case Document.Node.Deps(header) =>
|
| 60992 | 418 |
val master_dir = File.standard_url(name.master_dir) |
|
70638
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
70284
diff
changeset
|
419 |
val imports = header.imports.map(_.node) |
| 72764 | 420 |
val keywords = header.keywords.map({ case (a, spec) => (a, (spec.kind, spec.tags)) })
|
|
44979
68b990e950b1
explicit master_dir as part of header -- still required (for Cygwin) since Scala layer does not pass file content yet;
wenzelm
parents:
44866
diff
changeset
|
421 |
(Nil, |
|
72747
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
wenzelm
parents:
72745
diff
changeset
|
422 |
pair(string, pair(string, pair(list(string), |
|
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
wenzelm
parents:
72745
diff
changeset
|
423 |
pair(list(pair(string, pair(string, list(string)))), list(string)))))( |
|
65445
e9e7f5f5794c
more qualifier treatment, but in the end it is still ignored;
wenzelm
parents:
65439
diff
changeset
|
424 |
(master_dir, (name.theory, (imports, (keywords, header.errors)))))) }, |
| 52849 | 425 |
{ case Document.Node.Perspective(a, b, c) =>
|
426 |
(bool_atom(a) :: b.commands.map(cmd => long_atom(cmd.id)), |
|
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
427 |
list(pair(id, pair(string, list(string))))(c.dest)) })) |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
428 |
edits.map({ case (name, edit) => pair(string, encode_edit(name))(name.node, edit) })
|
|
68381
2fd3a6d6ba2e
less wasteful consolidation, based on PIDE front-end state and recent changes;
wenzelm
parents:
68336
diff
changeset
|
429 |
} |
| 70661 | 430 |
protocol_command_args("Document.update",
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
431 |
Document_ID.encode(old_id) :: Document_ID.encode(new_id) :: consolidate_xml :: edits_xml) |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
432 |
} |
| 43748 | 433 |
|
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
434 |
def remove_versions(versions: List[Document.Version]): Unit = |
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
435 |
protocol_command("Document.remove_versions",
|
|
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
436 |
XML.Encode.list(Document_ID.encode)(versions.map(_.id))) |
| 44673 | 437 |
|
| 43748 | 438 |
|
| 50498 | 439 |
/* dialog via document content */ |
440 |
||
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
441 |
def dialog_result(serial: Long, result: String): Unit = |
|
80462
7a1f9e571046
clarified signature: more explicit XML.Body types, more uniform Symbol.encode_yxml;
wenzelm
parents:
77501
diff
changeset
|
442 |
protocol_command("Document.dialog_result", XML.Encode.long(serial), XML.string(result))
|
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
443 |
} |