| author | wenzelm |
| Mon, 19 Dec 2022 15:29:24 +0100 | |
| changeset 76714 | 95a926d483c5 |
| parent 76680 | e95b9c9e17ff |
| child 76843 | 3dfc89c8dd71 |
| 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 {
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
26 |
def unapply(props: Properties.T): Option[(Document.Node.Name, Document_ID.Exec)] = |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
27 |
(props, props, props) match {
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
28 |
case (Markup.Name(name), Position.File(file), Position.Id(id)) |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
29 |
if Path.is_wellformed(file) => |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
30 |
val master_dir = Path.explode(file).dir.implode |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
31 |
Some((Document.Node.Name(file, master_dir, name), id)) |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
32 |
case _ => None |
|
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 |
|
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
36 |
|
|
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
37 |
/* document editing */ |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
38 |
|
| 75393 | 39 |
object Commands_Accepted {
|
|
70665
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
40 |
def unapply(text: String): Option[List[Document_ID.Command]] = |
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
41 |
try { Some(space_explode(',', text).map(Value.Long.parse)) }
|
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
42 |
catch { case ERROR(_) => None }
|
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
43 |
|
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
44 |
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
|
45 |
} |
|
94442fce40a5
prefer commands_accepted: fewer protocol messages;
wenzelm
parents:
70664
diff
changeset
|
46 |
|
| 75393 | 47 |
object Assign_Update {
|
48 |
def unapply( |
|
49 |
text: String |
|
50 |
) : 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
|
51 |
try {
|
|
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
52 |
import XML.Decode._ |
| 69846 | 53 |
def decode_upd(body: XML.Body): (Long, List[Long]) = |
54 |
space_explode(',', string(body)).map(Value.Long.parse) match {
|
|
55 |
case a :: bs => (a, bs) |
|
56 |
case _ => throw new XML.XML_Body(body) |
|
57 |
} |
|
| 71601 | 58 |
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
|
59 |
} |
|
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
60 |
catch {
|
|
383c9d758a56
raw message function "assign_execs" avoids full overhead of decoding and caching message body;
wenzelm
parents:
44644
diff
changeset
|
61 |
case ERROR(_) => None |
| 51987 | 62 |
case _: XML.Error => None |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
63 |
} |
|
70284
3e17c3a5fd39
more thorough assignment, e.g. when "purge" removes commands that were not assigned;
wenzelm
parents:
69849
diff
changeset
|
64 |
} |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
65 |
} |
|
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
66 |
|
| 75393 | 67 |
object Removed {
|
|
52530
99dd8b4ef3fe
explicit module Document_ID as source of globally unique identifiers across ML/Scala;
wenzelm
parents:
52527
diff
changeset
|
68 |
def unapply(text: String): Option[List[Document_ID.Version]] = |
| 44676 | 69 |
try {
|
70 |
import XML.Decode._ |
|
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
71 |
Some(list(long)(Symbol.decode_yxml(text))) |
| 44676 | 72 |
} |
73 |
catch {
|
|
74 |
case ERROR(_) => None |
|
| 51987 | 75 |
case _: XML.Error => None |
| 44676 | 76 |
} |
77 |
} |
|
78 |
||
|
38567
b670faa807c9
concentrate protocol message formats in Isar_Document;
wenzelm
parents:
38483
diff
changeset
|
79 |
|
|
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
80 |
/* command timing */ |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
81 |
|
| 75393 | 82 |
object Command_Timing {
|
| 71673 | 83 |
def unapply(props: Properties.T): Option[(Properties.T, Document_ID.Generic, isabelle.Timing)] = |
|
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
84 |
props match {
|
| 71673 | 85 |
case Markup.Command_Timing(args) => |
|
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
86 |
(args, args) match {
|
| 71673 | 87 |
case (Position.Id(id), Markup.Timing_Properties(timing)) => Some((args, id, timing)) |
|
51818
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
88 |
case _ => None |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
89 |
} |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
90 |
case _ => None |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
91 |
} |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
92 |
} |
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
93 |
|
|
517f232e867d
clarified module dependencies: avoid Properties and Document introding minimal "PIDE";
wenzelm
parents:
51533
diff
changeset
|
94 |
|
|
66873
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
95 |
/* theory timing */ |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
96 |
|
| 75393 | 97 |
object Theory_Timing {
|
|
66873
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
98 |
def unapply(props: Properties.T): Option[(String, isabelle.Timing)] = |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
99 |
props match {
|
| 71673 | 100 |
case Markup.Theory_Timing(args) => |
|
66873
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
101 |
(args, args) match {
|
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
102 |
case (Markup.Name(name), Markup.Timing_Properties(timing)) => Some((name, timing)) |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
103 |
case _ => None |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
104 |
} |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
105 |
case _ => None |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
106 |
} |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
107 |
} |
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
108 |
|
|
9953ae603a23
provide theory timing information, similar to command timing but always considered relevant;
wenzelm
parents:
66717
diff
changeset
|
109 |
|
|
39441
4110cc1b8f9f
allow embedded reports in regular prover messages, to avoid side-effects for errors for example;
wenzelm
parents:
39439
diff
changeset
|
110 |
/* 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
|
111 |
|
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
112 |
def is_result(msg: XML.Tree): Boolean = |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
113 |
msg match {
|
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
114 |
case XML.Elem(Markup(Markup.RESULT, _), _) => true |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
115 |
case _ => false |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
116 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
117 |
|
| 50157 | 118 |
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
|
119 |
msg match {
|
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
120 |
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
|
121 |
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
|
122 |
case _ => false |
|
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
123 |
} |
|
53365ba766ac
Command.accumulate: refrain from adding tracing messages to markup tree -- potential scalability problem;
wenzelm
parents:
39511
diff
changeset
|
124 |
|
|
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
125 |
def is_state(msg: XML.Tree): Boolean = |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
126 |
msg match {
|
|
59184
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
127 |
case XML.Elem(Markup(Markup.STATE, _), _) => true |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
128 |
case XML.Elem(Markup(Markup.STATE_MESSAGE, _), _) => true |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
129 |
case _ => false |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
130 |
} |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
131 |
|
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
132 |
def is_information(msg: XML.Tree): Boolean = |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
133 |
msg match {
|
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
134 |
case XML.Elem(Markup(Markup.INFORMATION, _), _) => true |
|
830bb7ddb3ab
explicit message channels for "state", "information";
wenzelm
parents:
59085
diff
changeset
|
135 |
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
|
136 |
case _ => false |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
137 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
138 |
|
|
67923
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
139 |
def is_writeln(msg: XML.Tree): Boolean = |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
140 |
msg match {
|
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
141 |
case XML.Elem(Markup(Markup.WRITELN, _), _) => true |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
142 |
case XML.Elem(Markup(Markup.WRITELN_MESSAGE, _), _) => true |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
143 |
case _ => false |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
144 |
} |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
145 |
|
| 39511 | 146 |
def is_warning(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.WARNING, _), _) => 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.WARNING_MESSAGE, _), _) => true |
| 39511 | 150 |
case _ => false |
151 |
} |
|
152 |
||
|
59203
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
153 |
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
|
154 |
msg match {
|
|
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
case _ => false |
|
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
158 |
} |
|
5f0bd5afc16d
explicit message channel for "legacy", which is nonetheless a variant of "warning";
wenzelm
parents:
59184
diff
changeset
|
159 |
|
| 39511 | 160 |
def is_error(msg: XML.Tree): Boolean = |
161 |
msg match {
|
|
|
50201
c26369c9eda6
Isabelle-specific implementation of quasi-abstract markup elements -- back to module arrangement before d83797ef0d2d;
wenzelm
parents:
50157
diff
changeset
|
162 |
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
|
163 |
case XML.Elem(Markup(Markup.ERROR_MESSAGE, _), _) => true |
| 39511 | 164 |
case _ => false |
165 |
} |
|
|
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
|
166 |
|
| 56495 | 167 |
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
|
168 |
!(is_result(msg) || is_tracing(msg)) |
| 56495 | 169 |
|
|
67923
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
170 |
def is_exported(msg: XML.Tree): Boolean = |
|
3e072441c96a
clarified exported messages, e.g. suppress "information", "tracing";
wenzelm
parents:
67915
diff
changeset
|
171 |
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
|
172 |
|
| 76087 | 173 |
def message_heading(elem: XML.Elem, pos: Position.T): String = {
|
174 |
val h = |
|
175 |
if (is_warning(elem) || is_legacy(elem)) "Warning" |
|
176 |
else if (is_error(elem)) "Error" |
|
177 |
else if (is_information(elem)) "Information" |
|
178 |
else if (is_tracing(elem)) "Tracing" |
|
179 |
else if (is_state(elem)) "State" |
|
180 |
else "Output" |
|
181 |
h + Position.here(pos) |
|
182 |
} |
|
183 |
||
| 72874 | 184 |
def message_text(elem: XML.Elem, |
| 72875 | 185 |
heading: Boolean = false, |
186 |
pos: Position.T = Position.none, |
|
| 71649 | 187 |
margin: Double = Pretty.default_margin, |
188 |
breakgain: Double = Pretty.default_breakgain, |
|
| 75393 | 189 |
metric: Pretty.Metric = Pretty.Default_Metric |
190 |
): String = {
|
|
| 76087 | 191 |
val text1 = if (heading) "\n" + message_heading(elem, pos) + ":\n" else "" |
| 72877 | 192 |
|
193 |
val body = |
|
| 72874 | 194 |
Pretty.string_of(Protocol_Message.expose_no_reports(List(elem)), |
| 71649 | 195 |
margin = margin, breakgain = breakgain, metric = metric) |
196 |
||
| 72877 | 197 |
val text2 = |
198 |
if (is_warning(elem) || is_legacy(elem)) Output.warning_prefix(body) |
|
199 |
else if (is_error(elem)) Output.error_prefix(body) |
|
200 |
else body |
|
201 |
||
202 |
text1 + text2 |
|
| 71165 | 203 |
} |
204 |
||
| 76680 | 205 |
def make_message(body: XML.Body, kind: String, props: Properties.T = Nil): XML.Elem = |
206 |
XML.Elem(Markup(Markup.message(kind), props), body) |
|
| 76022 | 207 |
|
| 76680 | 208 |
def writeln_message(body: XML.Body): XML.Elem = make_message(body, Markup.WRITELN) |
209 |
def warning_message(body: XML.Body): XML.Elem = make_message(body, Markup.WARNING) |
|
210 |
def error_message(body: XML.Body): XML.Elem = make_message(body, Markup.ERROR) |
|
211 |
||
212 |
def writeln_message(msg: String): XML.Elem = writeln_message(XML.string(msg)) |
|
213 |
def warning_message(msg: String): XML.Elem = warning_message(XML.string(msg)) |
|
214 |
def error_message(msg: String): XML.Elem = error_message(XML.string(msg)) |
|
| 76022 | 215 |
|
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
216 |
|
| 73835 | 217 |
/* ML profiling */ |
218 |
||
| 75393 | 219 |
object ML_Profiling {
|
| 73835 | 220 |
def unapply(msg: XML.Tree): Option[isabelle.ML_Profiling.Report] = |
221 |
msg match {
|
|
| 73838 | 222 |
case XML.Elem(_, List(tree)) if is_tracing(msg) => |
| 73835 | 223 |
Markup.ML_Profiling.unapply_report(tree) |
224 |
case _ => None |
|
225 |
} |
|
226 |
} |
|
227 |
||
228 |
||
| 71624 | 229 |
/* export */ |
230 |
||
| 75393 | 231 |
object Export {
|
| 71624 | 232 |
sealed case class Args( |
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
233 |
id: Option[String] = None, |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
234 |
serial: Long = 0L, |
| 71624 | 235 |
theory_name: String, |
236 |
name: String, |
|
|
72692
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
237 |
executable: Boolean = false, |
|
22aeec526ffd
support for PIDE markup in batch build (inactive due to pide_reports=false);
wenzelm
parents:
72637
diff
changeset
|
238 |
compress: Boolean = true, |
| 75393 | 239 |
strict: Boolean = true |
240 |
) {
|
|
| 71624 | 241 |
def compound_name: String = isabelle.Export.compound_name(theory_name, name) |
242 |
} |
|
243 |
||
244 |
def unapply(props: Properties.T): Option[Args] = |
|
245 |
props match {
|
|
246 |
case |
|
247 |
List( |
|
248 |
(Markup.FUNCTION, Markup.EXPORT), |
|
249 |
(Markup.ID, id), |
|
250 |
(Markup.SERIAL, Value.Long(serial)), |
|
251 |
(Markup.THEORY_NAME, theory_name), |
|
252 |
(Markup.NAME, name), |
|
253 |
(Markup.EXECUTABLE, Value.Boolean(executable)), |
|
254 |
(Markup.COMPRESS, Value.Boolean(compress)), |
|
255 |
(Markup.STRICT, Value.Boolean(strict))) => |
|
256 |
Some(Args(proper_string(id), serial, theory_name, name, executable, compress, strict)) |
|
257 |
case _ => None |
|
258 |
} |
|
259 |
} |
|
260 |
||
261 |
||
| 60882 | 262 |
/* breakpoints */ |
263 |
||
| 75393 | 264 |
object ML_Breakpoint {
|
| 60882 | 265 |
def unapply(tree: XML.Tree): Option[Long] = |
266 |
tree match {
|
|
267 |
case XML.Elem(Markup(Markup.ML_BREAKPOINT, Markup.Serial(breakpoint)), _) => Some(breakpoint) |
|
268 |
case _ => None |
|
269 |
} |
|
270 |
} |
|
271 |
||
272 |
||
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
273 |
/* dialogs */ |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
274 |
|
| 75393 | 275 |
object Dialog_Args {
|
| 52531 | 276 |
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
|
277 |
(props, props, props) match {
|
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
278 |
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
|
279 |
Some((id, serial, result)) |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
280 |
case _ => None |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
281 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
282 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
283 |
|
| 75393 | 284 |
object Dialog {
|
| 52531 | 285 |
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
|
286 |
tree match {
|
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
287 |
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
|
288 |
Some((id, serial, result)) |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
289 |
case _ => None |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
290 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
291 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
292 |
|
| 75393 | 293 |
object Dialog_Result {
|
294 |
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
|
295 |
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
|
296 |
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
|
297 |
} |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
298 |
|
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
299 |
def unapply(tree: XML.Tree): Option[String] = |
|
50500
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
300 |
tree match {
|
|
50501
6f41f1646617
more careful handling of Dialog_Result, with active area and color feedback;
wenzelm
parents:
50500
diff
changeset
|
301 |
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
|
302 |
case _ => None |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
303 |
} |
|
c94bba7906d2
identify dialogs via official serial and maintain as result message;
wenzelm
parents:
50498
diff
changeset
|
304 |
} |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
305 |
} |
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
306 |
|
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
307 |
|
| 75393 | 308 |
trait Protocol {
|
| 57916 | 309 |
/* protocol commands */ |
310 |
||
| 70661 | 311 |
def protocol_command_raw(name: String, args: List[Bytes]): Unit |
| 73340 | 312 |
def protocol_command_args(name: String, args: List[String]): Unit |
| 57916 | 313 |
def protocol_command(name: String, args: String*): Unit |
314 |
||
315 |
||
| 56387 | 316 |
/* options */ |
317 |
||
318 |
def options(opts: Options): Unit = |
|
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
319 |
protocol_command("Prover.options", Symbol.encode_yxml(opts.encode))
|
| 56387 | 320 |
|
321 |
||
| 72637 | 322 |
/* resources */ |
|
67493
c4e9e0c50487
treat sessions as entities with defining position;
wenzelm
parents:
67471
diff
changeset
|
323 |
|
| 72637 | 324 |
def init_session(resources: Resources): Unit = |
325 |
protocol_command("Prover.init_session", resources.init_session_yxml)
|
|
| 65470 | 326 |
|
327 |
||
| 56387 | 328 |
/* interned items */ |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
329 |
|
|
56335
8953d4cc060a
store blob content within document node: aux. files that were once open are made persistent;
wenzelm
parents:
56306
diff
changeset
|
330 |
def define_blob(digest: SHA1.Digest, bytes: Bytes): Unit = |
| 70661 | 331 |
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
|
332 |
|
| 75393 | 333 |
private def encode_command( |
334 |
resources: Resources, |
|
335 |
command: Command |
|
336 |
) : (String, String, String, String, String, List[String]) = {
|
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
337 |
import XML.Encode._ |
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
338 |
|
| 72946 | 339 |
val parents = command.theory_parents(resources).map(name => File.standard_url(name.node)) |
340 |
val parents_yxml = Symbol.encode_yxml(list(string)(parents)) |
|
341 |
||
| 75393 | 342 |
val blobs_yxml = {
|
| 72745 | 343 |
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
|
344 |
variant(List( |
|
72747
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
wenzelm
parents:
72745
diff
changeset
|
345 |
{ case Exn.Res(Command.Blob(a, b, c)) =>
|
|
5f9d66155081
clarified theory keywords: loaded_files are determined statically in Scala, but ML needs to do it semantically;
wenzelm
parents:
72745
diff
changeset
|
346 |
(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
|
347 |
(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
|
348 |
{ 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
|
349 |
|
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
350 |
Symbol.encode_yxml(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
|
351 |
} |
|
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
352 |
|
| 75393 | 353 |
val toks_yxml = {
|
| 64616 | 354 |
val encode_tok: T[Token] = (tok => pair(int, int)((tok.kind.id, Symbol.length(tok.source)))) |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
355 |
Symbol.encode_yxml(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
|
356 |
} |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
357 |
val toks_sources = command.span.content.map(tok => Symbol.encode(tok.source)) |
|
59085
08a6901eb035
clarified define_command: send tokens more directly, without requiring keywords in ML;
wenzelm
parents:
58015
diff
changeset
|
358 |
|
| 72946 | 359 |
(Document_ID(command.id), Symbol.encode(command.span.name), parents_yxml, |
360 |
blobs_yxml, toks_yxml, toks_sources) |
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
361 |
} |
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
362 |
|
| 75393 | 363 |
def define_command(resources: Resources, command: Command): Unit = {
|
| 72946 | 364 |
val (command_id, name, parents_yxml, blobs_yxml, toks_yxml, toks_sources) = |
365 |
encode_command(resources, command) |
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
366 |
protocol_command_args( |
| 72946 | 367 |
"Document.define_command", command_id :: name :: parents_yxml :: blobs_yxml :: |
368 |
toks_yxml :: toks_sources) |
|
|
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._ |
| 72946 | 375 |
val (command_id, name, parents_yxml, blobs_yxml, toks_yxml, toks_sources) = |
376 |
encode_command(resources, command) |
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
377 |
val body = |
| 72946 | 378 |
pair(string, pair(string, pair(string, pair(string, pair(string, list(string))))))( |
379 |
command_id, (name, (parents_yxml, (blobs_yxml, (toks_yxml, toks_sources))))) |
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
380 |
YXML.string_of_body(body) |
| 75394 | 381 |
}) |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
382 |
|
| 75393 | 383 |
def define_commands_bulk(resources: Resources, commands: List[Command]): Unit = {
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
384 |
val (irregular, regular) = commands.partition(command => YXML.detect(command.source)) |
| 72946 | 385 |
irregular.foreach(define_command(resources, _)) |
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
386 |
regular match {
|
|
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
387 |
case Nil => |
| 72946 | 388 |
case List(command) => define_command(resources, command) |
389 |
case _ => define_commands(resources, regular) |
|
|
70664
2bd9e30183b1
prefer define_commands_bulk: fewer protocol messages;
wenzelm
parents:
70661
diff
changeset
|
390 |
} |
|
54519
5fed81762406
maintain blobs within document state: digest + text in ML, digest-only in Scala;
wenzelm
parents:
54515
diff
changeset
|
391 |
} |
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
392 |
|
|
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
393 |
|
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
394 |
/* execution */ |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
395 |
|
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
396 |
def discontinue_execution(): Unit = |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
397 |
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
|
398 |
|
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
399 |
def cancel_exec(id: Document_ID.Exec): Unit = |
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
400 |
protocol_command("Document.cancel_exec", Document_ID(id))
|
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
401 |
|
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
402 |
|
|
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
403 |
/* 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
|
404 |
|
| 75393 | 405 |
def update( |
406 |
old_id: Document_ID.Version, |
|
407 |
new_id: Document_ID.Version, |
|
408 |
edits: List[Document.Edit_Command], |
|
409 |
consolidate: List[Document.Node.Name] |
|
410 |
): Unit = {
|
|
411 |
val consolidate_yxml = {
|
|
| 69849 | 412 |
import XML.Encode._ |
413 |
Symbol.encode_yxml(list(string)(consolidate.map(_.node))) |
|
414 |
} |
|
| 75393 | 415 |
val edits_yxml = {
|
|
61376
93224745477f
output HTML text according to Isabelle/Scala Symbol.Interpretation;
wenzelm
parents:
60992
diff
changeset
|
416 |
import XML.Encode._ |
| 44383 | 417 |
def id: T[Command] = (cmd => long(cmd.id)) |
| 46737 | 418 |
def encode_edit(name: Document.Node.Name) |
| 52849 | 419 |
: 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
|
420 |
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
|
421 |
{ 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
|
422 |
{ case Document.Node.Deps(header) =>
|
| 60992 | 423 |
val master_dir = File.standard_url(name.master_dir) |
|
70638
f164cec7ac22
clarified signature: prefer operations without position;
wenzelm
parents:
70284
diff
changeset
|
424 |
val imports = header.imports.map(_.node) |
| 72764 | 425 |
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
|
426 |
(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
|
427 |
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
|
428 |
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
|
429 |
(master_dir, (name.theory, (imports, (keywords, header.errors)))))) }, |
| 52849 | 430 |
{ case Document.Node.Perspective(a, b, c) =>
|
431 |
(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
|
432 |
list(pair(id, pair(string, list(string))))(c.dest)) })) |
| 69849 | 433 |
edits.map({ case (name, edit) =>
|
434 |
Symbol.encode_yxml(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
|
435 |
} |
| 70661 | 436 |
protocol_command_args("Document.update",
|
437 |
Document_ID(old_id) :: Document_ID(new_id) :: consolidate_yxml :: edits_yxml) |
|
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
438 |
} |
| 43748 | 439 |
|
| 75393 | 440 |
def remove_versions(versions: List[Document.Version]): Unit = {
|
| 44673 | 441 |
val versions_yxml = |
| 59364 | 442 |
{ import XML.Encode._
|
|
65345
2fdd4431b30e
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65313
diff
changeset
|
443 |
Symbol.encode_yxml(list(long)(versions.map(_.id))) } |
| 52582 | 444 |
protocol_command("Document.remove_versions", versions_yxml)
|
| 44673 | 445 |
} |
446 |
||
| 43748 | 447 |
|
| 50498 | 448 |
/* dialog via document content */ |
449 |
||
|
52931
ac6648c0c0fb
cancel_query via direct access to the exec_id of the running query process;
wenzelm
parents:
52862
diff
changeset
|
450 |
def dialog_result(serial: Long, result: String): Unit = |
| 63805 | 451 |
protocol_command("Document.dialog_result", Value.Long(serial), result)
|
|
38412
c23f3abbf42d
moved isar_document.ML/scala to Pure/System/ -- side-by-side with isar.ML;
wenzelm
parents:
diff
changeset
|
452 |
} |